• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AssetBundle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _LoadAssets

    IEnumerator _LoadAssets(Action loadComplete, Action loadError)
    {
        if (Debug.isDebugBuild)
            _loader = new WWW(Main.HOST + _versionBundle.url);
        else
            _loader = WWW.LoadFromCacheOrDownload(Main.HOST + _versionBundle.url, _versionBundle.versionValue);
        yield return _loader;

        if (string.IsNullOrEmpty(_loader.error))
        {
            if (_versionBundle.isEncrypted)
            {
                TextAsset encryped = _loader.assetBundle.Load(BundleLoader.ENCRYPTED_DATA, typeof(TextAsset)) as TextAsset;
                byte[] encryptedData = encryped.bytes;
                byte[] decryptedData = _Decrypt(encryptedData);
                _bundle = AssetBundle.CreateFromMemory(decryptedData).assetBundle;
            }
            else
            {
                _bundle = _loader.assetBundle;
            }

            _isLoadComplete = true;

            if (loadComplete != null) loadComplete();
        }
        else
        {
            Debug.LogError("Error: Load asset error with url: " + Main.HOST + _versionBundle.url + " - " + _loader.error);
            if (loadError != null) loadError();
        }
    }
开发者ID:fuutou89,项目名称:AngeVierge,代码行数:32,代码来源:BundleLoader.cs


示例2: LoadBundle

 /// <summary>
 /// 创建
 /// </summary>
 /// <param name="decryptedData"></param>
 /// <returns></returns>
 IEnumerator LoadBundle(byte[] decryptedData)
 {
     AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(decryptedData);
     yield return acr;
     assetBundel = acr.assetBundle;
     Instantiate(assetBundel.Load("Cube"));
 }
开发者ID:ylyking,项目名称:ABXTool,代码行数:12,代码来源:NewBehaviourScript.cs


示例3: AddLoadedBundleToManager

    static void AddLoadedBundleToManager(AssetBundle bundle, string name)
    {
        if (!isBundleLoaded(bundle, name))
            return;

        AssetBundleManager.AddBundle(name, 0, bundle);
    }
开发者ID:hrajagop,项目名称:2DShooter,代码行数:7,代码来源:Loader.cs


示例4: Start

    void Start()
    {
        m_cube = AssetBundle.LoadFromFile("C:\\Users\\yunsubaek_df\\Documents\\AssetBundleTest1\\AssetBundles\\Windows\\cube-bundle");

        cube_obj = (GameObject)m_cube.LoadAsset<GameObject>("Cube");
        GameObject.Instantiate(cube_obj,new Vector3(1,1,1),Quaternion.identity);
    }
开发者ID:yunsubaek,项目名称:Unity3D,代码行数:7,代码来源:AssutBundle_example.cs


示例5: StartLoad

    private AssetBundleRequest m_cRequest; //The load request

    #endregion Fields

    #region Methods

    /// <summary>
    /// Start async load the assetbundle
    /// </summary>
    /// <param name="asset"></param>
    /// <param name="resName"></param>
    /// <param name="callback"></param>
    public static AsyncLoader StartLoad(AssetBundle asset, string resName)
    {
        GameObject obj = new GameObject("AsyncLoader");
        AsyncLoader loader = obj.AddComponent<AsyncLoader>();
        loader.StartCoroutine(loader.GoLoader(asset, resName));
        return loader;
    }
开发者ID:huangxuping,项目名称:Unity3DGameResource,代码行数:19,代码来源:AsyncLoader.cs


示例6: 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


示例7: 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


示例8: DownloadAB

 IEnumerator DownloadAB()
 {
     Debug.Log("downloading...");
         yield return StartCoroutine(AssetBundleManager.downloadAssetBundle (url, version));
         bundle = AssetBundleManager.getAssetBundle (url, version);
         Debug.Log("complete");
         Debug.Log(bundle);
 }
开发者ID:Dotby,项目名称:SpaceViever,代码行数:8,代码来源:Test.cs


示例9: OnGUI

 void OnGUI()
 {
     if (GUILayout.Button ("Download bundle")){
         bundle = AssetBundleManager.getAssetBundle (url, version);
         if(!bundle)
             StartCoroutine (DownloadAB());
     }
 }
开发者ID:Dotby,项目名称:SpaceViever,代码行数:8,代码来源:Test.cs


示例10: LoadBundleFromFileUncompressed

 public IEnumerator LoadBundleFromFileUncompressed(string path)
 {
     CheckFileExists(path);
     bundle = AssetBundle.CreateFromFile(path);
     CheckBundle(bundle);
     Debug.Log("loaded bundle: " + path);
     yield return null;
 }
开发者ID:NotYours180,项目名称:AssetBundleBenchmark,代码行数:8,代码来源:AssetBundleManager.cs


示例11: 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


示例12: Load

 public AssetBundleRequest Load(string name, Type type)
 {
     Debug.Log("Loading " + name);
     if (null == bundle)
     {
         bundle = www.assetBundle;
         www.Dispose();
     }
     return bundle.LoadAsync(name, type);
 }
开发者ID:urgamedev,项目名称:burst_bubbles,代码行数:10,代码来源:ResourceLoader.cs


示例13: initialize

    /// <summary>
    /// 初始化
    /// </summary>
    void initialize() {
        string uri = string.Empty;
        //------------------------------------Shared--------------------------------------
        uri = Util.DataPath + "shared.assetbundle";
        Debug.LogWarning("LoadFile::>> " + uri);

        shared = AssetBundle.CreateFromFile(uri);
        shared.Load("Dialog", typeof(GameObject));
        ioo.gameManager.OnResourceInited();    //回调游戏管理器,执行后续操作 
    }
开发者ID:wangwuyi,项目名称:SimpleFramework_WP,代码行数:13,代码来源:ResourceManager.cs


示例14: LoadBundleFromMemory

 public IEnumerator LoadBundleFromMemory(byte[] buffer)
 {
     AssetBundleCreateRequest bundleRequest = AssetBundle.CreateFromMemory(buffer);
     yield return bundleRequest;
     if (bundleRequest.isDone)
     {
         bundle = bundleRequest.assetBundle;
         CheckBundle(bundle);
     }
 }
开发者ID:NotYours180,项目名称:AssetBundleBenchmark,代码行数:10,代码来源:AssetBundleManager.cs


示例15: MapHandler

    public MapHandler(IMapLoader mapLoader, AssetBundle mapAsset, MapSettings mapSettings, int mapLayer)
    {
        this.mapLoader = mapLoader;
        this.bundle = mapAsset;
        this.mapSettings = mapSettings;
        this.mapLayer = mapLayer;

        this.mapOffset = new Vector3(mapSettings.length / 2, HUDConstants.MAP_HEIGHT, mapSettings.width / 2);
        this.mapBounds = new Rect();
    }
开发者ID:kartsofchaos,项目名称:game,代码行数:10,代码来源:MapHandler.cs


示例16: loadSprite

 private GameObject loadSprite(string spriteName)
 {
     #if USE_ASSETBUNDLE
     if(assetbundle == null)
         assetbundle = AssetBundle.CreateFromFile(Application.streamingAssetsPath +"/Main.assetbundle");
             return assetbundle.Load(spriteName) as Sprite;
     #else
     return Instantiate(Resources.Load<GameObject>("Prefab/Atlas/Public/" + spriteName)) as GameObject;
     #endif
 }
开发者ID:tonyshow,项目名称:cardGame,代码行数:10,代码来源:UIMain.cs


示例17: LoadAssetsFromBundle

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

        foreach (var name in names)
        {
            Object obj = bundle.Load(name);
            TryAddAsset(name, obj, objects);
        }
        yield return null;
    }
开发者ID:NotYours180,项目名称:AssetBundleBenchmark,代码行数:11,代码来源:AssetBundleManager.cs


示例18: isBundleLoaded

    static bool isBundleLoaded(AssetBundle bundle, string name)
    {
        if (bundle == null)
        {
            Debug.LogWarning(string.Format("Bundle {0} is not loaded", name));
            return false;
        }

        Debug.Log(string.Format("Bundle {0} is loaded", name));
        return true;
    }
开发者ID:hrajagop,项目名称:2DShooter,代码行数:11,代码来源:Loader.cs


示例19: addAssetBundle

	public static void addAssetBundle(string url, int version, AssetBundle assetbundle )
	{
		Debug.Log("addAssetBundle url = "+ url);
		if( getAssetBundle(url, version ) == null )
		{
			Debug.Log("addAssetBundle Success");
			string keyName = url + version.ToString();
			AssetBundleRef abRef = new AssetBundleRef (url, version);
			abRef.assetBundle = assetbundle;
			dictAssetBundleRefs.Add (keyName, abRef);
		}
	}
开发者ID:RatzelAdmin,项目名称:Run,代码行数:12,代码来源:AssetBundleManager.cs


示例20: Insert

 public bool Insert(AssetBundle assetBundle)
 {
     try
     {
         _ctx.AssetBundles.Add(assetBundle);
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:cometa93,项目名称:SerwerDevilmind,代码行数:12,代码来源:ServerRepository_AssetBundles.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AssetItem类代码示例发布时间:2022-05-24
下一篇:
C# AssetBase类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap