码迷,mamicode.com
首页 > 其他好文 > 详细

AssetBundle Manager

时间:2017-10-01 10:17:48      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:setname   img   deploy   span   src   cti   open   ati   style   

AssetBundle Manager

  AssetBundleManager是一个款Unity公司制作的Unity库。

1、Simulation Mode

  The main advantage of using Simulation Mode is that Assets can be modified, updated, added, and deleted without the need to re-build and deploy the AssetBundles every time.

  It is worth noting that AssetBundle Variants do not work with Simulation Mode. If you need to use variants, Local AssetBundle Server is the option you need.

2、Local AssetBundle Server

  AssetBundleManager在Asset目录中提供了Build选项。

3、AssetBundleManager.Initialize()

  The AssetBundle Manager uses this manifest you load during the Initialize() to help with a number of features behind the scenes, including dependency management.

技术分享
IEnumerator Start()

{
    yield return StartCoroutine(Initialize());
}
IEnumerator Initialize()
{
    var request = AssetBundleManager.Initialize();
if (request != null)
    yield return StartCoroutine(request);
}
View Code

4、Loading Assets

技术分享
IEnumerator InstantiateGameObjectAsync (string assetBundleName, string assetName)

{
    // Load asset from assetBundle.
    AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject) );
    if (request == null)
        yield break;
    yield return StartCoroutine(request);
    // Get the asset.
    GameObject prefab = request.GetAsset<GameObject> ();
    if (prefab != null)
        GameObject.Instantiate(prefab);
}
View Code

5、Loading Scenes

技术分享
IEnumerator InitializeLevelAsync (string levelName, bool isAdditive)

{
    // Load level from assetBundle.
    AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(sceneAssetBundle, levelName, isAdditive);
    if (request == null)
        yield break;
    yield return StartCoroutine(request);
}
View Code

6、ActiveVariants

技术分享
IEnumerator InitializeLevelAsync (string levelName, bool isAdditive, string[] variants)

{
    //Set the activeVariants.
    AssetBundleManager.ActiveVariants = variants;
    // Load level from assetBundle.
    AssetBundleLoadOperation request = AssetBundleManager.LoadLevelAsync(variantSceneAssetBundle, levelName, isAdditive);
    if (request == null)
        yield break;
    yield return StartCoroutine(request);
}
View Code

 

AssetBundle Manager

标签:setname   img   deploy   span   src   cti   open   ati   style   

原文地址:http://www.cnblogs.com/tekkaman/p/7616665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!