Exemplo n.º 1
0
    IEnumerator Test2()
    {
        yield return(new WaitForSeconds(2));

        Debug.Log("Load prefab " + Time.frameCount);
        AssetLoaderEnumerator loader = m_AssetManager.YieldLoadAsset("ArtResources/Prefabs/MyPrefab.prefab");

        yield return(loader);

        AssetReference ar = loader.assetReference;

        Debug.Log(ar + "," + Time.frameCount);
        if (ar != null)
        {
            Debug.Log(ar.asset);
            m_Obj = GameObject.Instantiate(ar.asset);
            //ar.Retain(m_Obj);
            ar.Monitor(m_Obj as GameObject);
        }
        loader.Dispose();

        Debug.Log("Load mat " + Time.frameCount);
        AssetLoaderEnumerator loader2 = m_AssetManager.YieldLoadAsset("ArtResources/Materials/MyMaterial.mat");

        ar = loader2.assetReference;
        Debug.Log(ar + "," + Time.frameCount);
        if (ar != null)
        {
            Debug.Log(ar.asset);
        }
        loader2.Dispose();
        Debug.Log("Load complete " + Time.frameCount);
        yield return(new WaitForSeconds(2));

        Debug.Log("start dstroy " + Time.frameCount);
        if (m_Obj != null)
        {
            Destroy(m_Obj);
        }

        yield return(null);

        m_AssetManager.UnloadUnuseds();

        //yield return m_AssetManager.LoadAsset("ArtResources/Prefabs/MyPrefab.prefab", (ar) =>
        //{

        //    Debug.Log(ar + "," + Time.frameCount);
        //    if (ar != null)
        //    {
        //        Debug.Log(ar.asset);
        //        GameObject go = GameObject.Instantiate(ar.asset) as GameObject;
        //        go.transform.Translate(10, 0, 0);
        //    }
        //});
    }
Exemplo n.º 2
0
        public IEnumerator TestYeildLoadAsset()
        {
            AssetLoaderEnumerator assetLoaderEnumerator = m_AssetManager.YieldLoadAsset("ArtResources/Prefabs/MyPrefab.prefab");

            yield return(assetLoaderEnumerator);

            AssetReference result = assetLoaderEnumerator.assetReference;

            Assert.AreNotEqual(result, null);
            assetLoaderEnumerator.Dispose();
        }
Exemplo n.º 3
0
    IEnumerator Testloop()
    {
        AssetLoaderEnumerator loader = m_AssetManager.YieldLoadAsset("ArtResources/Prefabs/CircelRefs/APreab.prefab");

        yield return(loader);

        AssetReference ar = loader.assetReference;

        Debug.Log(ar + "," + Time.frameCount);
        if (ar != null)
        {
            GameObject.Instantiate(ar.asset);
        }
        loader.Dispose();
    }
Exemplo n.º 4
0
    IEnumerator Test3()
    {
        AssetLoaderEnumerator loader = m_AssetManager.YieldLoadAsset("ArtResources/Prefabs/MyPrefab.prefab");

        yield return(loader);

        AssetReference assetRef = loader.assetReference;

        Debug.Log(Time.frameCount);
        //资源已经在LoadAsset时已经被加载出来,后面删除AssetBundle也没有关系。
        yield return(new WaitForSeconds(1));

        Debug.Log("Remove bundle," + Time.frameCount);
        assetRef.assetBundleReference = null;

        yield return(new WaitForSeconds(1));

        Debug.Log("Instance," + Time.frameCount);
        GameObject.Instantiate(assetRef.asset);
        loader.Dispose();
    }
Exemplo n.º 5
0
    IEnumerator Test4()
    {
        AssetLoaderEnumerator loader = m_AssetManager.YieldLoadAsset("ArtResources/Materials/MyMaterial.mat");

        yield return(loader);

        AssetReference ar = loader.assetReference;

        Debug.Log(ar + "," + Time.frameCount);
        if (ar != null)
        {
            Debug.Log(ar.asset);
            ar.assetBundleReference = null;
        }
        loader = m_AssetManager.YieldLoadAsset("ArtResources/Prefabs/MyPrefab.prefab");
        yield return(loader);

        Debug.Log(ar + "," + Time.frameCount);
        if (ar != null)
        {
            GameObject.Instantiate(ar.asset);
        }
        loader.Dispose();
    }