示例#1
0
 private void OnDestroy()
 {
     if (asset != null)
     {
         asset.Release();
         asset = null;
         go    = null;
     }
 }
示例#2
0
        public static ReleaseAssetOnDestroy Register(GameObject go, MyAsset asset)
        {
            ReleaseAssetOnDestroy component = go.GetComponent <ReleaseAssetOnDestroy>();

            if (component == null)
            {
                component = go.AddComponent <ReleaseAssetOnDestroy>();
            }

            component.asset = asset;
            component.go    = go;
            return(component);
        }
示例#3
0
        private static MyAsset LoadInternam(string name, System.Type type, bool asyncMode, Action <MyAsset> callback = null)
        {
            MyAsset asset = assets.Find(obj => { return(obj.assetName == name); });

            if (asset == null)
            {
#if UNITY_EDITOR
                if (!FrameworkDefaultSetting.useEditorPrefab)
                {
                    asset = CreatAssetRuntime(name, type, asyncMode);
                }
                else
                {
                    asset = new MyAsset(name, type);
                }
#else
                asset = CreatAssetRuntime(name, type, asyncMode);
#endif
                assets.Add(asset);
                if (!manifest.IsInit)
                {
                    asset.OnLoadManifest();
                }
                else
                {
                    asset.Load();
                }
            }
            asset.Retain(); //资源依赖数量

            if (callback != null)
            {
                asset.AddCompletedLisenter(callback);
            }
            return(asset);
        }
示例#4
0
 /// <summary>
 /// 卸载指定资源
 /// </summary>
 /// <param name="asset"></param>
 public static void UndLoad(MyAsset asset)
 {
     asset.Release();
 }