예제 #1
0
    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);
        }
    }
예제 #2
0
    public void CleanRef(GameObject go)
    {
        ABRef abRef = go.GetComponent <ABRef>();

        if (abRef != null)
        {
            Destroy(abRef);
        }
    }
예제 #3
0
    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);
        }
    }