Ejemplo n.º 1
0
        public override void EnterState()
        {
            // Save The Time When Enter This Page
            tempTime = Time.timeSinceLevelLoad;

            Transform tsf = UICtr.Instance.Open(UIType.Setting);

            if (HorizontalSettingGroup == null)
            {
                HorizontalSettingGroup = tsf.Find(SettingGroup);
            }

            if (HorizontalBtnGroup == null)
            {
                HorizontalBtnGroup = tsf.Find(ButtonGroup);
            }
            if (Ctr == null)
            {
                Ctr = HorizontalSettingGroup.Find("Ctr");
            }
            if (CtrText == null)
            {
                CtrText = Ctr.Find("Text").GetComponent <UnityEngine.UI.Text>();
            }

            if (Usb == null)
            {
                Usb = HorizontalSettingGroup.Find("Usb");
#if UNITY_IOS
                Usb.gameObject.SetActive(false);
                HorizontalSettingGroup.GetComponent <UnityEngine.UI.HorizontalLayoutGroup>().spacing = -461f;
#endif
            }
            if (UsbText == null)
            {
                UsbText = Usb.Find("Text").GetComponent <UnityEngine.UI.Text>();
            }

            if (Beacon == null)
            {
                Beacon = HorizontalSettingGroup.Find("Beacon");
            }
            if (BeginButton == null)
            {
                BeginButton = HorizontalBtnGroup.Find(BeginButtonName);
            }
            if (DownBtn == null)
            {
                DownBtn = HorizontalBtnGroup.Find("DownStore");

                bool Launcher = false;
#if !UNITY_EDITOR && UNITY_ANDROID
                ///判断是否存在包名
                AndroidJavaObject   packageManager = AndroidUtil.GetActivity().Call <AndroidJavaObject>("getPackageManager");
                AndroidJavaObject   packageInfos   = packageManager.Call <AndroidJavaObject>("getInstalledPackages", 0);
                AndroidJavaObject[] packages       = packageInfos.Call <AndroidJavaObject[]>("toArray");
                for (int i = 0; i < packages.Length; i++)
                {
                    AndroidJavaObject applicationInfo = packages[i].Get <AndroidJavaObject>("applicationInfo");
                    if ((applicationInfo.Get <int>("flags") & applicationInfo.GetStatic <int>("FLAG_SYSTEM")) == 0)
                    {
                        string packageName = applicationInfo.Get <string>("packageName");
                        if (packageName == MirageAR_SDK.mLauncherPackageName)
                        {
                            Launcher = true;
                        }
                    }
                }
#elif !UNITY_EDITOR && UNITY_IOS
                //TODO:iOS Check The Launcher Whether Installed
#endif
                if (Launcher)
                {
                    ///如果存在则下载按钮隐藏
                    DownBtn.gameObject.SetActive(false);
                }
                else
                {
                    MirageAR_UIEventListener.Get(DownBtn.gameObject).onClick = () => { Application.OpenURL(DownAppUrl); };
                }
            }

            ChangeTitleLanguage(LanguageManager.Instance);

            if (BackButton == null)
            {
                BackButton = tsf.Find("Back");
            }

            InitSet();

#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
            BeginButton.GetComponent <UnityEngine.UI.Button>().interactable = false;
            MirageAR_UIEventListener.Get(BackButton.gameObject).onClick     = () => { DeviceUtils.ShowDialog(Title, null, YesBtn, () => { Application.Quit(); }, NoBtn, () => { }); };
#else
            MirageAR_UIEventListener.Get(BackButton.gameObject).onClick = () => { UnityEditor.EditorApplication.isPlaying = false; };
#endif
            MirageAR_UIEventListener.Get(BeginButton.gameObject).onClick += DoEnterGameEvent;
            MirageAR_UIEventListener.Get(Ctr.gameObject).onClick          = () => { parent.SetState(MainControl.Transtion.Ctr); };
            MirageAR_UIEventListener.Get(Usb.gameObject).onClick          = () => { parent.SetState(MainControl.Transtion.Usb); };
            MirageAR_UIEventListener.Get(Beacon.gameObject).onClick       = () => { parent.SetState(MainControl.Transtion.Beacon); };

            bool CanEnterGame;
#if !UNITY_IOS
            CanEnterGame = CtrFlag && UsbState.Usbflag;
#else
            CanEnterGame = CtrFlag;
#endif

            if (CanEnterGame)
            {
                BeginButton.GetComponent <UnityEngine.UI.Button>().interactable = true;
            }
            else
            {
#if !UNITY_EDITOR
                MirageAR_UIEventListener.Get(BeginButton.gameObject).onClick -= DoEnterGameEvent;
#endif
            }

            // Init
            UpdateCtrBattery();
            UpdateUsbBattery();
        }