Esempio n. 1
0
    int isInstalledGooglePlay     = -1;                       //checked flag

    public void CheckTTS(string ttsPackageName, string ttsName, Button ttsButton)
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        if (isInstalledGooglePlay == -1)    //at first time only
        {
            isInstalledGooglePlay = AndroidPlugin.IsExistApplication(GooglePlay) ? 1 : 0;
        }

        if (isInstalledGooglePlay == 1)
        {
            if (AndroidPlugin.IsExistApplication(ttsPackageName))
            {
                string appName = AndroidPlugin.GetApplicationName(ttsPackageName);
                string verName = AndroidPlugin.GetVersionName(ttsPackageName);
                DisplayText("\n" + appName + " ver." + verName + " is installed.", true);
                if (ttsButton != null)
                {
                    ttsButton.interactable = false;
                }
            }
            else
            {
                DisplayText("\n" + ttsName + " is not installed.", true);
                if (ttsButton != null)
                {
                    ttsButton.interactable = true;
                }
            }
        }
        else
        {
            DisplayText("\nGoogle Play is not installed.", true);
        }
#endif
    }
        // Update is called once per frame
        //private void Update()
        //{

        //}



        //Check if the package exists on the Android system.
        public void CheckInstall()
        {
            if (string.IsNullOrEmpty(packageName))
            {
                return;
            }

#if UNITY_EDITOR
            Debug.Log("AppInstallCheckController.CheckInstall called.");
#elif UNITY_ANDROID
            if (AndroidPlugin.IsExistApplication(packageName))
            {
                string appName = AndroidPlugin.GetApplicationName(packageName);
                int    verCode = AndroidPlugin.GetVersionCode(packageName);
                string verName = AndroidPlugin.GetVersionName(packageName);
                if (OnInstalled != null)
                {
                    OnInstalled.Invoke(appName, verCode, verName);
                }
            }
            else
            {
                if (OnNotInstalled != null)
                {
                    OnNotInstalled.Invoke();
                }
            }
#endif
        }