Пример #1
0
    public void Reset(bool askConfirmation)
    {
        Debug.Log("Reset ");

        if (Application.platform == RuntimePlatform.Android)
        {
            Debug.Log("Android");

            if (askConfirmation)
            {
                Debug.Log("Confirmation required");

                if (Time.realtimeSinceStartup - lastClicked > 1.5f)
                {
                    Debug.Log("ShowToaster");

                    lastClicked = Time.realtimeSinceStartup;

                    ShowToast toast = new ShowToast();

                    toast.showToastOnUiThread("Press again to restart game");

                    return;
                }
            }
        }

        NextQuestion();
        SetAmounts(m_save.defaultFillAmounts);

        GetComponent <WinLoose>().RestartGame();
    }
Пример #2
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                Debug.Log("Android");

                Debug.Log("Confirmation required");

                if (Time.realtimeSinceStartup - lastClicked > 1.5f)
                {
                    Debug.Log("ShowToaster");

                    lastClicked = Time.realtimeSinceStartup;

                    ShowToast toast = new ShowToast();

                    toast.showToastOnUiThread("Press again to exit.");

                    return;
                }
            }

#if UNITY_ANDROID
            // Get the unity player activity
            AndroidJavaObject activity =
                new AndroidJavaClass("com.unity3d.player.UnityPlayer")
                .GetStatic <AndroidJavaObject>("currentActivity");

            // call activity's boolean moveTaskToBack(boolean nonRoot) function
            // documentation: http://developer.android.com/reference/android/app/Activity.html#moveTaskToBack(boolean)
            activity.Call <bool>("moveTaskToBack", true);
#else
            Application.Quit();
#endif
        }
    }