private IEnumerator _CreateFromAB(string abPath, string resName, ObjCallback callback) { if (string.IsNullOrEmpty(resName)) { resName = GetResName(abPath); } yield return(StartCoroutine(_LoadAB(abPath, null, true))); ABInfo abInfo; if (!mAssetBundles.TryGetValue(abPath.ToLower(), out abInfo)) { yield break; } GameObject go = abInfo.ab.LoadAsset(resName, typeof(GameObject)) as GameObject; if (go == null) { yield break; } go = Instantiate(go) as GameObject; ABRef abRef = go.AddComponent <ABRef>(); abRef.SetABPath(abPath); if (callback != null) { callback(go); } }
public void CleanRef(GameObject go) { ABRef abRef = go.GetComponent <ABRef>(); if (abRef != null) { Destroy(abRef); } }
private IEnumerator _LoadAssetFromAB(string abPath, string resName, GameObject go, System.Type type, ObjCallback callback) { if (string.IsNullOrEmpty(resName)) { resName = GetResName(abPath); } //yield return Utils.StartConroutine(_LoadAB(abPath, null, true)); yield return(StartCoroutine(_LoadAB(abPath, null, true))); ABInfo abInfo; if (!mAssetBundles.TryGetValue(abPath, out abInfo)) { yield break; } UnityEngine.Object asset = abInfo.ab.LoadAsset(resName, type); if (asset == null) { yield break; } if (go == null) { yield break; } ABRef abRef = go.GetComponent <ABRef>(); if (abRef == null) { abRef = go.AddComponent <ABRef>(); } abRef.SetABPath(abPath); if (callback != null) { callback(asset); } }