public override Object Load(Type type) { if (!Prefab) { Holder = null; if (ManiItem != null && DepBundles.Count > 0) { var bi = DepBundles[DepBundles.Count - 1]; if (bi != null && bi.Bundle != null) { var path = ConcatAssetPath(); Prefab = bi.Bundle.LoadAsset <GameObject>(path); } } } if (Prefab) { if (!Holder) { Holder = Prefab.AddComponent <CapsPrefabHolder>(); Holder.AssetInfo = this; } } return(Prefab); }
public override IEnumerator LoadAsync(CoroutineTasks.CoroutineWork req, Type type) { var holdhandle = Hold(); try { if (!Prefab) { if (ManiItem != null && DepBundles.Count > 0) { var bi = DepBundles[DepBundles.Count - 1]; if (bi != null && bi.Bundle != null) { var path = ConcatAssetPath(); while (AsyncWorkTimer.Check()) { yield return(null); } AssetBundleRequest raw = null; try { raw = bi.Bundle.LoadAssetAsync <GameObject>(path); } catch (Exception e) { PlatDependant.LogError(e); } if (raw != null) { yield return(raw); var asset = raw.asset as GameObject; if (!Prefab) { Holder = null; Prefab = asset; } } } } } if (Prefab) { if (!Holder) { Holder = Prefab.AddComponent <CapsPrefabHolder>(); Holder.AssetInfo = this; } } req.Result = Prefab; } finally { GC.KeepAlive(holdhandle); } }
public override void Unload() { if (Holder) { #if UNITY_EDITOR Object.DestroyImmediate(Holder); #else Object.Destroy(Holder); #endif Holder = null; } base.Unload(); }