Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Utils {
- public static void fullscreen(){
- UnityPlayer.currentActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
- }
- public static void toast(String text){
- Toast.makeText(UnityPlayer.currentActivity, text, Toast.LENGTH_SHORT).show();
- }
- public static boolean test1(int code,String[] text){
- return true;
- }
- public static int test2(){
- return 1;
- }
- }
- using UnityEngine;
- public class Utils : MonoBehaviour {
- private void Init(){
- #if UNITY_ANDROID && !UNITY_EDITOR
- javaClass = new AndroidJavaClass("com.unity.plugin.Utils");
- #endif
- }
- void Awake () {
- Init();
- Fullscreen ();
- }
- public void Fullscreen(){
- #if UNITY_ANDROID && !UNITY_EDITOR
- if (javaClass != null)
- javaClass.CallStatic ("fullscreen");
- #endif
- }
- public void Toast(string text){
- #if UNITY_ANDROID && !UNITY_EDITOR
- if (javaClass != null)
- javaClass.CallStatic ("toast",text);
- #endif
- }
- public bool Test1(int code,string[] text){
- #if UNITY_ANDROID && !UNITY_EDITOR
- if (javaClass != null)
- return javaClass.CallStatic<bool> ("test1",code,text);
- #endif
- return false;
- }
- public int Test2(){
- #if UNITY_ANDROID && !UNITY_EDITOR
- if (javaClass != null)
- return javaClass.CallStatic<int> ("test2");
- #endif
- return 0;
- }
- public void clickBtn1(){
- if (Test1 (11, new string[]{ "text" }))
- Toast ("true clickBtn1");
- else
- Toast ("false clickBtn1");
- }
- public void clickBtn2(){
- if (Test2 () == 1)
- Toast ("Равно 1 clickBtn2");
- else
- Toast ("Неравно clickBtn2");
- }
- public void clickBtn3(){
- Fullscreen ();
- Toast ("Fullscreen clickBtn3");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement