private async void OnApplicationQuit()
 {
     AtlasManager.Dispose();
     XLuaManager.Dispose();
     AOIManager.Dispose();
     TcpManager.Dispose();
     TimeManager.Dispose();
     MapManager.Dispose();
     HUDManager.Dispose();
     //why
     await Task.Delay(1);
 }
        //public static byte[] LoadLuaFileSync(string path)
        //    => SyncAddressables.LoadAsset<TextAsset>(m_RootPath + path)?.bytes;

        //public static async Task<TextAsset> LoadLuaFileAsync(string path, Action<TextAsset> action = null)
        //{
        //    /// Log
        //    Debug.Log("LoadLuaFileAsync : " + m_RootPath + path);

        //    TextAsset @object = await Addressables.LoadAssetAsync<TextAsset>(m_RootPath + path).Task;
        //    action?.Invoke(@object);
        //    return @object;
        //}

        //public static void LoadLuaFilesAsync(string label, Action<IList<TextAsset>> action = null)
        //{
        //    /// Log
        //    Debug.Log("LoadLuaFiles label : " + label);

        //    Addressables.LoadAssetsAsync<TextAsset>(label, null).Completed += (aoh) =>
        //    {
        //        action?.Invoke(aoh.Task.Result);
        //    };
        //}

        /// <summary>
        /// 加载图片
        /// </summary>
        /// <param name="atlasName"></param>
        /// <param name="spriteName">不带后缀</param>
        /// <param name="action"></param>
        public static void LoadSprite(string atlasName, string spriteName, Action <Sprite> action = null)
        {
            if (string.IsNullOrEmpty(atlasName) || string.IsNullOrEmpty(spriteName))
            {
                Debug.LogError("图集或者图片名称为空");
                action(null);
            }
            else
            {
                AtlasManager.OnAtlasRequestedAsync(atlasName, (atlas) =>
                {
                    Sprite gObj = atlas.GetSprite(spriteName);
                    if (gObj == null)
                    {
                        Debug.LogError("图集中无此图" + spriteName);
                        return;
                    }
                    action?.Invoke(gObj);
                });
            }
        }
Esempio n. 3
0
        void OnDestroy()
        {
            NetworkMgr.Dispose();
            ServerMgr.Dispose();
            UpdateMgr.Dispose();
            PoolMgr.Dispose();
            SceneMgr.Dispose();
            ResMgr.Dispose();
            LuaMgr.Dispose();
            GameMgr.Dispose();
            AtlasMgr.Dispose();

            SceneMgr   = null;
            NetworkMgr = null;
            ServerMgr  = null;
            UpdateMgr  = null;
            ResMgr     = null;
            GameMgr    = null;
            AtlasMgr   = null;
            PoolMgr    = null;
            LuaMgr     = null;

            Ins = null;
        }
 private void OnEnable()
 {
     AtlasManager.Init();
 }