wangguan
2020-11-05 ac7a95d834b4ef2f5904f54bd4173002b6ff52b7
Assets/Scripts/GameAnalytics_SDK/UI/LoginUI.cs
@@ -18,16 +18,20 @@
    // Start is called before the first frame update
    void Start()
    {
        GA_SDK_Manager.Ins.SDKInit(ChannelID.Gm.ToString());
        GA_SDK_Manager.Ins.Statistics(1);//成功加载登陆界面的人数
        TDAA_SDKManager.Ins.SDKInit(ChannelID.Gm.ToString());
        TDAA_SDKManager.Ins.Statistics(1);//成功加载登陆界面的人数
        isLogining = false;
        transform.Find("Panel/Button").GetComponent<Button>().onClick.AddListener(OnClickLoginBtn);
        transform.Find("Panel/Button (1)").GetComponent<Button>().onClick.AddListener(OnClickResetBtn);
        progressSlider = transform.Find("Progress").GetComponent<Slider>();
        progressSlider.value = 0;
        if (Application.platform == RuntimePlatform.Android)
        {
            //GetetDeviceIMEI();//获取安卓手机IMEI
            imei0 = GA_SDK_Manager.Ins.GetDeviceId();//使用设备ID
            imei0 = TDAA_SDKManager.Ins.GetDeviceId();//使用设备ID
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
@@ -69,11 +73,31 @@
    #endregion
    private void OnClickResetBtn()
    {
        Debug.LogError("清空了所有数据");
        PlayerPrefs.DeleteAll();
        TDAA_SDKManager.Ins.Reset();
    }
    private void OnClickLoginBtn()
    {
        LoginRequest();
        GA_SDK_Manager.Ins.Statistics(2);//埋点
        if (!isLogining)
        {
            AudioSourceManager.Ins.Play(AudioEnum.UI);
            TDAA_SDKManager.Ins.Statistics(2);//埋点
            StartCoroutine(loginMy());
            //StartCoroutine(LoadScene());
        }
        else
        {
        }
        //TDAA_SDKManager.Ins.Statistics(2);//埋点
        //LoginRequest();
    }
    /// <summary>
@@ -89,8 +113,8 @@
            {
                Debug.Log("编辑器直接登录");
                GA_SDK_Manager.Ins.Login(imei0);
                GA_SDK_Manager.Ins.Statistics(3);//埋点
                //TDAA_SDKManager.Ins.Login();
                //TDAA_SDKManager.Ins.Statistics(3);//埋点
                //StartCoroutine(loginMy());
                StartCoroutine(LoadScene());
@@ -180,8 +204,8 @@
            Debug.Log("--------------------- 登录成功 ---------------------");
            //UserDataMsg userData = login.Userdata;
            GA_SDK_Manager.Ins.Login(imei0);
            GA_SDK_Manager.Ins.Statistics(3);//埋点
            //TDAA_SDKManager.Ins.Login();
            //TDAA_SDKManager.Ins.Statistics(3);//埋点
            //StartCoroutine(loginMy());
            StartCoroutine(LoadScene());
@@ -198,24 +222,26 @@
    IEnumerator LoadScene()
    {
        async = SceneManager.LoadSceneAsync(GameConfig.NextSceneName);
        async.allowSceneActivation = true;
        /*while (!async.isDone)
        //async.allowSceneActivation = true;
        while (!async.isDone)
        {
            if (async.progress < 0.9f)
                progressValue = async.progress;
            {
                Debug.Log(async.progress);
            }
            //progressValue = async.progress;
            else
                progressValue = 1.0f;
            slider.value = progressValue;
            progress.text = (int)(slider.value * 100) + " %";
                Debug.Log("超过0.9,");
            //progressValue = 1.0f;
            //slider.value = progressValue;
            //progress.text = (int)(slider.value * 100) + " %";
            if (async.progress >= 0.89)
            {
                Debug.Log("进展时间分别是:" + async.progress + "," + totalTime);
                if( totalTime >= 3.0f )
                    async.allowSceneActivation = true;
                progress.text = "按任意键继续";
                Debug.Log("进展时间分别是:" + async.progress + ",");
                //progress.text = "按任意键继续";
                if (Input.anyKeyDown)
                {
                    async.allowSceneActivation = true;
@@ -224,11 +250,11 @@
            }
            //yield return null;
        }*/
        }
        yield return null;
    }
    private Slider progressSlider;
    IEnumerator loginMy()
    {
        int displayProgress = 0;
@@ -237,10 +263,11 @@
        op.allowSceneActivation = false;
        while (op.progress < 0.9f) //此处如果是 <= 0.9f 则会出现死循环所以必须小0.9
        {
            toProgress = (int)op.progress * 100;
            toProgress = (int)(op.progress * 100);
            while (displayProgress < toProgress)
            {
                ++displayProgress;
                progressSlider.value = displayProgress * 0.01f;
                SetLoadingPercentage(displayProgress);
                yield return new WaitForEndOfFrame();//ui渲染完成之后
            }
@@ -249,6 +276,8 @@
        while (displayProgress < toProgress)
        {
            ++displayProgress;
            progressSlider.value = displayProgress * 0.01f;
            SetLoadingPercentage(displayProgress);
            yield return new WaitForEndOfFrame();
        }