Exemplo n.º 1
0
        public async ETTask AddPackageAsync(string type)
        {
            if (Define.IsEditorMode)
            {
                await ETTask.CompletedTask;
                if (AddPackageRef(type))
                {
                    UIPackage.AddPackage($"{FGUI_PACKAGE_DIR}/{type}");
                }
                //UIPackage uiPackage = UIPackage.AddPackage($"{FGUI_PACKAGE_DIR}/{type}");

                //packages.Add(type, uiPackage);
            }
            else
            {
                if (AddPackageRef(type))
                {
                    string             uiBundleDesName    = AssetBundleHelper.StringToAB($"{type}_fui");
                    string             uiBundleResName    = AssetBundleHelper.StringToAB(type);
                    ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
                    await resourcesComponent.LoadBundleAsync(uiBundleDesName);

                    await resourcesComponent.LoadBundleAsync(uiBundleResName);

                    AssetBundle desAssetBundle = resourcesComponent.GetAssetBundle(uiBundleDesName);
                    AssetBundle resAssetBundle = resourcesComponent.GetAssetBundle(uiBundleResName);
                    UIPackage.AddPackage(desAssetBundle, resAssetBundle);
                }
                //UIPackage uiPackage = UIPackage.AddPackage(desAssetBundle, resAssetBundle);

                //packages.Add(type, uiPackage);
            }
        }
Exemplo n.º 2
0
        public void RemovePackage(string type)
        {
            if (RemovePackageRef(type))
            {
                var p = UIPackage.GetByName(type);

                if (p != null)
                {
                    UIPackage.RemovePackage(type);
                }
            }

            /*UIPackage package;
             *
             * if(packages.TryGetValue(type, out package))
             * {
             *  var p = UIPackage.GetByName(package.name);
             *
             *  if (p != null)
             *  {
             *      UIPackage.RemovePackage(package.name);
             *  }
             *
             *  packages.Remove(package.name);
             * }*/

            if (!Define.IsEditorMode)
            {
                string uiBundleDesName = AssetBundleHelper.StringToAB($"{type}_fui");
                string uiBundleResName = AssetBundleHelper.StringToAB(type);
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle(uiBundleDesName);
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle(uiBundleResName);
            }
        }