Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. public class Utils {
  2. public static void fullscreen(){
  3. UnityPlayer.currentActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
  4. }
  5.  
  6. public static void toast(String text){
  7. Toast.makeText(UnityPlayer.currentActivity, text, Toast.LENGTH_SHORT).show();
  8. }
  9.  
  10. public static boolean test1(int code,String[] text){
  11. return true;
  12. }
  13.  
  14. public static int test2(){
  15. return 1;
  16. }
  17. }
  18.  
  19. using UnityEngine;
  20.  
  21. public class Utils : MonoBehaviour {
  22. private void Init(){
  23. #if UNITY_ANDROID && !UNITY_EDITOR
  24. javaClass = new AndroidJavaClass("com.unity.plugin.Utils");
  25. #endif
  26. }
  27.  
  28. void Awake () {
  29. Init();
  30. Fullscreen ();
  31. }
  32.  
  33. public void Fullscreen(){
  34. #if UNITY_ANDROID && !UNITY_EDITOR
  35. if (javaClass != null)
  36. javaClass.CallStatic ("fullscreen");
  37. #endif
  38. }
  39.  
  40. public void Toast(string text){
  41. #if UNITY_ANDROID && !UNITY_EDITOR
  42. if (javaClass != null)
  43. javaClass.CallStatic ("toast",text);
  44. #endif
  45. }
  46.  
  47. public bool Test1(int code,string[] text){
  48. #if UNITY_ANDROID && !UNITY_EDITOR
  49. if (javaClass != null)
  50. return javaClass.CallStatic<bool> ("test1",code,text);
  51. #endif
  52. return false;
  53. }
  54.  
  55. public int Test2(){
  56. #if UNITY_ANDROID && !UNITY_EDITOR
  57. if (javaClass != null)
  58. return javaClass.CallStatic<int> ("test2");
  59. #endif
  60. return 0;
  61. }
  62.  
  63. public void clickBtn1(){
  64. if (Test1 (11, new string[]{ "text" }))
  65. Toast ("true clickBtn1");
  66. else
  67. Toast ("false clickBtn1");
  68. }
  69.  
  70. public void clickBtn2(){
  71. if (Test2 () == 1)
  72. Toast ("Равно 1 clickBtn2");
  73. else
  74. Toast ("Неравно clickBtn2");
  75. }
  76.  
  77. public void clickBtn3(){
  78. Fullscreen ();
  79. Toast ("Fullscreen clickBtn3");
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement