Esempio n. 1
0
        internal static void Init()
        {
            lock (initLock)
            {
                if (instance == null)
                {
                    var instances = FindObjectsOfType <GoodiesSceneHelper>();

                    if (instances.Length > 1)
                    {
                        Debug.LogError(typeof(GoodiesSceneHelper) + " Something went really wrong " +
                                       " - there should never be more than 1 " + typeof(GoodiesSceneHelper) +
                                       " Reopening the scene might fix it.");
                    }
                    else if (instances.Length == 0)
                    {
                        GameObject singleton = new GameObject();
                        instance       = singleton.AddComponent <GoodiesSceneHelper>();
                        singleton.name = "[singleton] " + typeof(GoodiesSceneHelper);

                        DontDestroyOnLoad(singleton);

                        Debug.Log("[Singleton] An instance of " + typeof(GoodiesSceneHelper) +
                                  " is needed in the scene, so '" + singleton +
                                  "' was created with DontDestroyOnLoad.");
                    }
                    else
                    {
                        Debug.Log("[Singleton] Using instance already created: " + instance.gameObject.name);
                    }
                }
            }
        }
Esempio n. 2
0
        public static bool IsNotAndroidCheck()
        {
            bool isAndroid = Application.platform == RuntimePlatform.Android;

            if (isAndroid)
            {
                GoodiesSceneHelper.Init();
            }

            return(!isAndroid);
        }
 public void onClick(AndroidJavaObject dialog, int which)
 {
     if (_onClickVoid != null)
     {
         GoodiesSceneHelper.Queue(_onClickVoid);
     }
     if (_onClickInt != null)
     {
         GoodiesSceneHelper.Queue(() => _onClickInt(which));
     }
     if (_dismissOnClick)
     {
         GoodiesSceneHelper.Queue(() => dialog.Call("dismiss"));
     }
 }
Esempio n. 4
0
            // ReSharper disable once InconsistentNaming
            // ReSharper disable once UnusedMember.Local
            void onRequestPermissionsResults(AndroidJavaObject results)
            {
                int size           = results.CallInt("size");
                var requestResults = new PermissionRequestResult[size];

                for (int i = 0; i < size; i++)
                {
                    var    resultAJO  = results.CallAJO("get", i);
                    string permission = resultAJO.CallStr("getPermission");
                    bool   shouldShowRequestPermissionRationale = resultAJO.CallBool("isShouldShowRequestPermissionRationale");
                    var    status = (PermissionStatus)resultAJO.CallInt("getResult");
                    requestResults[i] = new PermissionRequestResult(permission, shouldShowRequestPermissionRationale, status);
                }

                if (_onResult != null)
                {
                    GoodiesSceneHelper.Queue(() => _onResult(requestResults));
                }
                results.Dispose();
            }
Esempio n. 5
0
            private void onLocationChanged(/*Location*/ AndroidJavaObject locationAJO)
            {
                var location = LocationFromAJO(locationAJO);

                GoodiesSceneHelper.Queue(() => _onLocationChanged(location));
            }
Esempio n. 6
0
 void onClick(AndroidJavaObject dialog, int which, bool isChecked)
 {
     GoodiesSceneHelper.Queue(() => _onClick(which, isChecked));
 }
 void onDismiss(AndroidJavaObject dialog)
 {
     GoodiesSceneHelper.Queue(_onDismiss);
 }
 // ReSharper disable once InconsistentNaming
 // ReSharper disable once UnusedMember.Local
 // ReSharper disable once UnusedParameter.Local
 void onTimeSet(AndroidJavaObject view, int hourOfDay, int minute)
 {
     GoodiesSceneHelper.Queue(() => _onTimePicked(hourOfDay, minute));
 }
 // ReSharper disable once InconsistentNaming
 // ReSharper disable once UnusedMember.Local
 // ReSharper disable once UnusedParameter.Local
 void onDateSet(AndroidJavaObject view, int year, int month, int dayOfMonth)
 {
     //  Month! (0-11 for compatibility with MONTH)
     GoodiesSceneHelper.Queue(() => _onDatePicked(year, month + 1, dayOfMonth));
 }
 void onCancel(AndroidJavaObject dialog)
 {
     GoodiesSceneHelper.Queue(_onCancel);
 }