private void OnDestroy() { if (asset != null) { asset.Release(); asset = null; go = null; } }
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); }
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); }
/// <summary> /// 卸载指定资源 /// </summary> /// <param name="asset"></param> public static void UndLoad(MyAsset asset) { asset.Release(); }