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


C# AssetBundle.Load方法代码示例

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


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

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

示例2: LoadFromBundle

 private UnityEngine.Object LoadFromBundle(AssetBundle bundle, string name)
 {
     #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
     return bundle.Load(name);
     #else
     return bundle.LoadAsset(name);
     #endif
 }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:8,代码来源:AssetBundleManager.cs

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

示例4: LoadBundle

    public IEnumerator LoadBundle()
    {
        ImBusy = true;
            string url = "file:///"+Path.GetFullPath(ResPath);
            MessageServiceClass.MessageProcessing("Loadin bundle from "+url);
            WWW www = WWW.LoadFromCacheOrDownload(url, version);
            yield return www;
            MessageServiceClass.MessageProcessing("Bundle resources are loaded from "+ url);

            assetBundle = www.assetBundle;
            CircleGameObjPref = assetBundle.Load("circle") as GameObject;
            for (int i = 0;i <4; i++){
                BundleResourceTextures2d[i] = assetBundle.Load (BundleTexturesNames[i]) as Texture2D;

            }// int i = 0;i <4; i++

           	assetBundle.Unload(false);
            ImBusy = false;
    }
开发者ID:R---K,项目名称:SQ,代码行数:19,代码来源:ResManagerScript.cs

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

示例6: initialize

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

            stream = File.ReadAllBytes(uri);
            shared = AssetBundle.CreateFromMemoryImmediate(stream);
#if UNITY_5
        shared.LoadAsset("Dialog", typeof(GameObject));
#else
            shared.Load("Dialog", typeof(GameObject));
#endif
            if (func != null) func();    //资源初始化完成,回调游戏管理器,执行后续操作 
        }
开发者ID:xq48799220,项目名称:SimpleFramework_NGUI,代码行数:19,代码来源:ResourceManager.cs

示例7: loadAssetBundle

    /**
        (3):AssetBundle

        关于AssetBundle的介绍已经有很多了。简而言之就是把prefab或者二进制文件封装成AssetBundle文件(也是一种二进制)。
        但是也有硬伤,就是在移动端无法更新脚本。下面简单的总结下:
        1:是Unity3D定义的一种二进制类型。
        2:最好将prefab封装成AseetBundle,不过上面不是才说了在移动端无法更新脚本吗?
            那从Assetbundle中拿到的Prefab上挂的脚本是不是就无法运行了?也不一定,只要这个prefab上挂的是本地脚本,就可以。
        3:使用WWW类来下载。

     * */
    IEnumerator loadAssetBundle()
    {
        AssetBundle AssetBundleCsv = new AssetBundle();

        //读取放入StreamingAssets文件夹中的bundle文件
        string str = Application.streamingAssetsPath + "/" + "Test.bundle";
        WWW www = new WWW(str);
        www = WWW.LoadFromCacheOrDownload(str, 0);

        AssetBundleCsv = www.assetBundle;
        string path = "Test";
        TextAsset test = AssetBundleCsv.Load(path, typeof(TextAsset)) as TextAsset;
        string result = test.ToString();

        yield return null;
    }
开发者ID:jackdevelop,项目名称:ThreeCard,代码行数:27,代码来源:test.cs

示例8: initialize

        /// <summary>
        /// 初始化
        /// </summary>
        public void initialize(Action func) {
            if (AppConst.ExampleMode) {
                byte[] stream;
                string uri = string.Empty;
                //------------------------------------Shared--------------------------------------
                uri = Util.DataPath + "shared" + AppConst.ExtName;
                Debug.LogWarning("LoadFile::>> " + uri);

                stream = File.ReadAllBytes(uri);
                shared = AssetBundle.LoadFromMemory(stream);
#if UNITY_5
        shared.LoadAsset("Dialog", typeof(GameObject));
#else
                shared.Load("Dialog", typeof(GameObject));
#endif
            }
            if (func != null) func();    //资源初始化完成,回调游戏管理器,执行后续操作 
        }
开发者ID:guyun008,项目名称:LuaFramework_ngui_mod,代码行数:21,代码来源:ResourceManager.cs

示例9: StartCreatePanel

    /// <summary>
    /// 创建面板
    /// </summary>
    IEnumerator StartCreatePanel(string name, AssetBundle bundle, string text = null) {
        name += "Panel";
        GameObject prefab = bundle.Load(name) as GameObject;
        yield return new WaitForEndOfFrame();
        if (Parent.FindChild(name) != null || prefab == null) {
            yield break;
        }
        GameObject go = Instantiate(prefab) as GameObject;
        go.name = name;
        go.layer = LayerMask.NameToLayer("Default");
        go.transform.parent = Parent;
        go.transform.localScale = Vector3.one;
        go.transform.localPosition = Vector3.zero;

        yield return new WaitForEndOfFrame();
        go.AddComponent<BaseLua>().OnInit(bundle);

        Debug.Log("StartCreatePanel------>>>>" + name);
    }
开发者ID:wangwuyi,项目名称:SimpleFramework_WP,代码行数:22,代码来源:PanelManager.cs

示例10: AddPackage

 /// <summary>
 /// Add a UI package from two assetbundles with a optional main asset name.
 /// </summary>
 /// <param name="desc">A assetbunble contains description file.</param>
 /// <param name="res">A assetbundle contains resources.</param>
 /// <param name="mainAssetName">Main asset name.</param>
 /// <returns>UIPackage</returns>
 public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string mainAssetName)
 {
     string source = null;
     #if UNITY_5
     if (mainAssetName != null)
     {
         TextAsset ta = desc.LoadAsset<TextAsset>(mainAssetName);
         if (ta != null)
             source = ta.text;
     }
     else
     {
         string[] names = desc.GetAllAssetNames();
         foreach (string n in names)
         {
             if (n.IndexOf("@") == -1)
             {
                 TextAsset ta = desc.LoadAsset<TextAsset>(n);
                 if (ta != null)
                 {
                     source = ta.text;
                     if (mainAssetName == null)
                         mainAssetName = Path.GetFileNameWithoutExtension(n);
                     break;
                 }
             }
         }
     }
     #else
     if (mainAssetName != null)
     {
         TextAsset ta = (TextAsset)desc.Load(mainAssetName, typeof(TextAsset));
         if (ta != null)
             source = ta.text;
     }
     else
     {
         source = ((TextAsset)desc.mainAsset).text;
         mainAssetName = desc.mainAsset.name;
     }
     #endif
     if (source == null)
         throw new Exception("FairyGUI: invalid package.");
     if (desc != res)
         desc.Unload(true);
     return AddPackage(source, res, mainAssetName);
 }
开发者ID:yinlei,项目名称:Fishing,代码行数:54,代码来源:UIPackage.cs

示例11: DownloadAssetBundle

    private IEnumerator DownloadAssetBundle(string asset, string bundleName, int version)
    {
        loadedAsset = null;

        // Wait for the Caching system to be ready
        while (!Caching.ready)
        {
            yield return null;
        }

        string url = baseURL + bundleName;

        // Start the download
        using (WWW www = WWW.LoadFromCacheOrDownload(url, version))
        {
            yield return www;
            if (www.error != null)
            {
                throw new System.Exception("AssetBundle - WWW download:" + www.error);
            }
            thisAssetBundle = www.assetBundle;

            //load the specified asset into memory
            loadedAsset = thisAssetBundle.Load(asset, typeof(GameObject));

            www.Dispose();

            isDone = true;
        }
    }
开发者ID:RandomColourzzz,项目名称:AssetBundleCreator,代码行数:30,代码来源:LoadAssetFromBundle.cs

示例12: LoadAsset

    public static GameObject LoadAsset(AssetBundle bundle, string name)
    {
#if UNITY_5
        return bundle.LoadAsset(name, typeof(GameObject)) as GameObject;
#else
        return bundle.Load(name, typeof(GameObject)) as GameObject;
#endif
    }
开发者ID:shiqinghui,项目名称:LuaSpaceShoot,代码行数:8,代码来源:Util.cs

示例13: Load

    IEnumerator Load()
    {
        string filePath = string.Empty;
        if(GooglePlayDownloader.RunningOnAndroid()){

            if(mainPath == null){
                needServerDownload = true;

                message = "MainFile still not found!";
                Debug.Log(message);

            }

            if(needServerDownload){
                filePath = ServerURL + "/" + AssetBundleName + ".unity3d";
            } else {
                filePath = "jar:file://" + mainPath;
                filePath += "!/"+AssetBundleName+".unity3d";
            }

        } else {
            filePath = "file://" + Application.dataPath;
            filePath += "/"+AssetBundleName+".unity3d";

        }

        message = "FilePath: " + filePath;
        Debug.Log(message);

        www = WWW.LoadFromCacheOrDownload(filePath,AssetVersionNumber);
        yield return www;
        bundle = www.assetBundle;
        loadedAssets.Clear();
        foreach(var name in PrefabNames){
            GameObject go = bundle.Load(name, typeof(GameObject)) as GameObject;
            loadedAssets.Add(name, go);
        }

        if(loadingScreen != null && loadingScreen.renderer != null)
            loadingScreen.renderer.enabled = false;

        Application.LoadLevel(ChangeToScene);
    }
开发者ID:FriedrichWessel,项目名称:TestOBB,代码行数:43,代码来源:AssetStorage.cs


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