少年修仙传客户端代码仓库
hch
2023-10-17 7cea40bba92ee9c1640017757ca29cbb93ceab19
System/WindowBase/ModelCenter.cs
@@ -329,8 +329,13 @@
            return model;
        }
        // 此处加try的原因是 遇不报错的情况
        void OnBeforePlayerDataInitialize()
        {
#if UNITY_EDITOR
            try
            {
#endif
            foreach (var model in models.Values)
            {
                var beforePlayerDataInitialize = model as IBeforePlayerDataInitialize;
@@ -339,10 +344,21 @@
                    beforePlayerDataInitialize.OnBeforePlayerDataInitialize();
                }
            }
#if UNITY_EDITOR
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
        }
        void OnAfterPlayerDataInitialize()
        {
#if UNITY_EDITOR
            try
            {
#endif
            foreach (var model in models.Values)
            {
                var afterPlayerDataInitialize = model as IAfterPlayerDataInitialize;
@@ -351,22 +367,45 @@
                    afterPlayerDataInitialize.OnAfterPlayerDataInitialize();
                }
            }
        }
        void OnPlayerLoginOk()
#if UNITY_EDITOR
        }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
}
void OnPlayerLoginOk()
        {
#if UNITY_EDITOR
            try
            {
#endif
            foreach (var model in models.Values)
            {
                var playerLoginOk = model as IPlayerLoginOk;
                if (playerLoginOk != null)
                {
                    playerLoginOk.OnPlayerLoginOk();
                }
                    if (playerLoginOk != null)
                    {
                        playerLoginOk.OnPlayerLoginOk();
                    }
            }
#if UNITY_EDITOR
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
        }
        void OnMapInitOk()
        {
#if UNITY_EDITOR
            try
            {
#endif
            foreach (var model in models.Values)
            {
                var mapInitOk = model as IMapInitOk;
@@ -375,10 +414,21 @@
                    mapInitOk.OnMapInitOk();
                }
            }
#if UNITY_EDITOR
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
        }
        void OnAccountSwitch()
        {
#if UNITY_EDITOR
            try
            {
#endif
            foreach (var model in models.Values)
            {
                var switchAccount = model as ISwitchAccount;
@@ -387,6 +437,13 @@
                    switchAccount.OnSwitchAccount();
                }
            }
#if UNITY_EDITOR
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
        }
    }