Пример #1
0
        /// <summary>
        /// 清除可能会冲突的实例(尽管禁用UIDate后再载入存档一般可以顺利进行,但游戏特殊情况仍会卡读档,在游戏开发稳定之前双保险)
        /// </summary>
        /// <returns></returns>
        private static bool Prefix(DateFile.LegendBook loadDate)
        {
            if (LoadFile.OnLoad)
            {
                LoadFile.OnLoad = false;
#if DEBUG
                var m_Container = ReflectionMethod.GetValue <SingletonObject, GameObject>(null, "m_Container");
                Main.Logger.Log($"DateFile_Loadloadlegend: Is m_Container null? {m_Container == null}");
                foreach (string key in m_SingletonMap.Keys)
                {
                    Main.Logger.Log($"DateFile_Loadloadlegend m_SingletonMap keys {key}");
                }
#endif
                // 清除需要清除的实例(仿自 SingletonObject.ClearInstances)
                foreach (var inst in instancesToRemove)
                {
                    if (SingletonMap.TryGetValue(inst, out object item) && !DontClearList.Contains(item))
                    {
                        (item as IDisposable)?.Dispose();
                        if (item is Component cmp)
                        {
                            UnityEngine.Object.Destroy(cmp);
                        }
                        SingletonMap.Remove(inst);
                    }
                }
                // 清除Subsystem中可能存在冲突的实例
                SubSystems.OnUnloadGameData();
            }
            return(true);
        }
Пример #2
0
        /// <summary>
        /// 执行存档读取操作
        /// </summary>
        public static void DoLoad(int dataId)
        {
            Main.onLoad = true;
            UIDate.instance.gameObject.SetActive(false);
            // 释放资源
            SubSystems.OnUnloadGameData();

            MainMenu.instance.SetLoadIndex(dataId);
        }
Пример #3
0
        /// <summary>
        /// 执行存档读取操作
        /// </summary>
        public static void DoLoad(int dataId)
        {
            OnLoad = true;
            // 防止UI活动生成新的SingletonObject实例
            UIDate.instance.gameObject.SetActive(false);
            // 来自DateFile.BackToStartMenu()方法,载入存档前清空,防止载入存档时载入奇书数据时卡档
            SingletonObject.ClearInstances();
            // 释放资源
            SubSystems.OnUnloadGameData();

            MainMenu.instance.SetLoadIndex(dataId);
        }