当前位置: 首页>>代码示例>>C#>>正文


C# AssetBundle.LoadAsync方法代码示例

本文整理汇总了C#中UnityEngine.AssetBundle.LoadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# AssetBundle.LoadAsync方法的具体用法?C# AssetBundle.LoadAsync怎么用?C# AssetBundle.LoadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.AssetBundle的用法示例。


在下文中一共展示了AssetBundle.LoadAsync方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnAssetBundleLoaded

    void OnAssetBundleLoaded(string url, AssetBundle assetBundle, params object[] args)
    {
        Object asset = null;
        System.DateTime beginTime = System.DateTime.Now;
        if (AssetInBundleName == null)
        {
            // 经过AddWatch调试,.mainAsset这个getter第一次执行时特别久,要做序列化
            try
            {
                asset = assetBundle.mainAsset;
            }
            catch
            {
                CBase.LogError("[OnAssetBundleLoaded:mainAsset]{0}", url);
            }
        }
        else
        {
            AssetBundleRequest request = assetBundle.LoadAsync(AssetInBundleName, typeof(Object));
            asset = request.asset;
        }

        CResourceManager.LogLoadTime("AssetFileBridge", url, beginTime);

        if (asset == null)
        {
            CBase.LogError("Asset is NULL: {0}", url);
        }

        AssetFileLoadedCallback(asset, CallbackArgs);
    }
开发者ID:mr-kelly,项目名称:ProjectWeak,代码行数:31,代码来源:CAssetFileBridge.cs

示例2: BundleLoadedHandler

    private void BundleLoadedHandler(WWW request)
    {
        Debug.Log("Bundle loaded: " + request.url);
        _bundle = request.assetBundle;

        AssetBundleRequest assetBundleRequest = _bundle.LoadAsync(AssetName, typeof(GameObject));
        _assetBundleQueue.Send(assetBundleRequest, AssetLoadedHandler);
    }
开发者ID:bwheatley,项目名称:edriven,代码行数:8,代码来源:Main2CSa.cs

示例3: GoLoader

    /// <summary>
    /// Begin load
    /// </summary>
    /// <param name="asset"></param>
    /// <param name="resName"></param>
    /// <returns></returns>
    public IEnumerator GoLoader(AssetBundle asset, string resName)
    {
        this.m_cRequest = asset.LoadAsync(resName, typeof(UnityEngine.Object));

        for (; !this.m_cRequest.isDone; )
            yield return this.m_cRequest;

        GameObject.Destroy(this.gameObject);
    }
开发者ID:huangxuping,项目名称:Unity3DGameResource,代码行数:15,代码来源:AsyncLoader.cs

示例4: OnGUI

    // ReSharper restore InconsistentNaming
    // ReSharper restore UnusedMember.Local
    // ReSharper disable UnusedMember.Local
    // ReSharper disable InconsistentNaming
    void OnGUI()
    {
        // classic OnGUI
        GUI.depth = 0;
        if (GUI.Button(new Rect(10, 10, 100, 50), _progress == 0 ? "Load" : "Loading: " + _progress + "%"))
        {
            // reset queues
            _bundleQueue.Reset();
            _assetBundleQueue.Reset();

            // destroy old object
            if (null != _object)
                Destroy(_object);

            // unload old bundle
            if (null != _bundle)
                _bundle.Unload(true);

            // load bundle
            _bundleQueue.Send(new WWW(BundleUrl),
                delegate(WWW request)
                {
                    Debug.Log("Bundle loaded: " + request.url);
                    _bundle = request.assetBundle;

                    AssetBundleRequest assetBundleRequest = _bundle.LoadAsync(AssetName, typeof(GameObject));
                    _assetBundleQueue.Send(assetBundleRequest,
                        delegate(AssetBundleRequest request2)
                        {
                            Debug.Log("Asset loaded: " + request2.asset.name);
                            _object = (GameObject)Instantiate(request2.asset);

                            // add mouse orbit
                            GameObject cameraGo = GameObject.Find("Main Camera");
                            if (null != cameraGo)
                            {
                                MouseOrbitCs mouseOrbit = cameraGo.AddComponent<MouseOrbitCs>();
                                mouseOrbit.Target = _object.transform;
                            }
                        }
                    );
                }
            );
        }
    }
开发者ID:bwheatley,项目名称:edriven,代码行数:49,代码来源:Main2CSb.cs

示例5: GoLoader

        //Begin to load
        private IEnumerator GoLoader(AssetBundle asset, string resName , FINISH_CALLBACK finish_callback)
        {
            this.m_delFinishCallback = finish_callback;
            this.m_fProgress = 0;
            this.m_cRequest = asset.LoadAsync(resName, typeof(UnityEngine.Object));

            for (; !this.m_cRequest.isDone; )
            {
                this.m_fProgress = this.m_cRequest.progress;
                yield return new WaitForEndOfFrame();
            }
            this.m_fProgress = 1;

            if(this.m_delFinishCallback != null)
            {
                this.m_delFinishCallback(resName , this.m_cRequest.asset);
            }

            GameObject.Destroy(this.gameObject);
        }
开发者ID:lingllting,项目名称:Unity3DGameResource,代码行数:21,代码来源:AsyncLoader.cs

示例6: AsyncLoadAsset

        static IEnumerator AsyncLoadAsset(AssetBundle bundle, Action<UnityObject> onFinish, String path)
        {
            if (EnablePauseFlag)
            {
                if (path.EndsWith(".png.u3dext") || path.EndsWith(".tga.u3dext") || path.EndsWith(".bytes.u3dext") || path.EndsWith(".mp3.u3dext"))
                {
                    while (GetPauseFlag())
                        yield return null;

                    Debug.LogWarning(path);
                    EntryPoint.DebugString = path;
                }
            }

            ////checkres(path, typeof(Texture), 0);
			CheckDependBundlesInCache(path);
            AssetBundleRequest request = bundle.LoadAsync("1", typeof(UnityObject));
            if (request == null)
            {
				Debug.LogWarning("Failed to LoadAsync with name '1' from: " + path);

                if (onFinish != null)
                    onFinish(null);
                yield break;
            }

            while (!request.isDone)
                yield return null;

			UnityObject asset = request.asset;
			if (asset == null)
				Debug.LogWarning("LoadAsync with name '1' return null:" + path);

			if (m_bEnableLog)
				Log("AsyncLoadAsset finish: " + path + "@ " + Time.realtimeSinceStartup);

            if (onFinish != null)
                onFinish(asset);
        }
开发者ID:fengqk,项目名称:Art,代码行数:39,代码来源:ResourceManager.cs

示例7: NewLoadBGElement

		private IEnumerator NewLoadBGElement ()
		{
				string path = Application.dataPath + "/Bundle/BGElement";
				AssetBundle ab = new AssetBundle ();
				AssetBundleRequest abr = ab.LoadAsync (path, typeof(GameObject));
				yield return abr;
				GameObject newCube = Instantiate (abr.asset) as GameObject;
		}
开发者ID:jjhesk,项目名称:unity-interview,代码行数:8,代码来源:LoadGameData.cs

示例8: LoadAssetsFromBundleAsync

    public IEnumerator LoadAssetsFromBundleAsync(AssetBundle bundle, string[] names)
    {
        objects = new List<Object>();

        foreach (var name in names)
        {
            AssetBundleRequest request = bundle.LoadAsync(name, typeof(UnityEngine.Object));

            yield return request;
            UnityEngine.Object obj = request.asset;
            TryAddAsset(name, obj, objects);

        }
    }
开发者ID:NotYours180,项目名称:AssetBundleBenchmark,代码行数:14,代码来源:AssetBundleManager.cs

示例9: LoadAssetsFromBundleSimultaneouslyAsync

    public IEnumerator LoadAssetsFromBundleSimultaneouslyAsync(AssetBundle bundle, string[] names, int nAssets)
    {
        objects = new List<Object>();
        List<AssetBundleRequest> requests = new List<AssetBundleRequest>();

        for (int i = 0; i < names.Length; i++)
        {
            string name = names[i];
            requests.Add(bundle.LoadAsync(name, typeof(Object)));

            if (requests.Count == nAssets || i == names.Length - 1)
            {
                while (!AreAssetsLoaded(requests))
                {
                    yield return null;
                }
                foreach (var request in requests)
                {
                    Object obj = request.asset;
                    TryAddAsset(obj.name, obj, objects);
                }
                Debug.Log("Loaded " + requests.Count + " assets from the bundle");
                requests = new List<AssetBundleRequest>();
            }
        }
    }
开发者ID:NotYours180,项目名称:AssetBundleBenchmark,代码行数:26,代码来源:AssetBundleManager.cs

示例10: AyncLoadAsset

        static IEnumerator AyncLoadAsset(AssetBundle bundle, Action<UnityObject> onFinish, String path)
        {
			CheckDependBundlesInCache(path);
            AssetBundleRequest request = bundle.LoadAsync("1", typeof(UnityObject));
            if (request == null)
            {
                if (onFinish != null)
                    onFinish(null);
                yield break;
            }

            while (!request.isDone)
                yield return null;

            if (onFinish != null)
                onFinish(request.asset);
        }
开发者ID:fengqk,项目名称:Art,代码行数:17,代码来源:ResourceManager.cs

示例11: ProcessAssetBundle

    /// <summary>
    /// In this function we can do whatever we want with the freshly downloaded bundle.
    /// In this example we will cache it for later use, and we will load a texture from it.
    /// </summary>
    IEnumerator ProcessAssetBundle(AssetBundle bundle)
    {
        if (bundle == null)
            yield break;

        // Save the bundle for future use
        cachedBundle = bundle;

        // Start loading the asset from the bundle
        var asyncAsset = 
#if UNITY_5
            cachedBundle.LoadAssetAsync("9443182_orig", typeof(Texture2D));
#else
        
            cachedBundle.LoadAsync("9443182_orig", typeof(Texture2D));
#endif

        // wait til load
        yield return asyncAsset;

        // get the texture
        texture = asyncAsset.asset as Texture2D;
    }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:27,代码来源:AssetBundleSample.cs


注:本文中的UnityEngine.AssetBundle.LoadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。