博客
关于我
unity3d打包和包的使用
阅读量:650 次
发布时间:2019-03-15

本文共 1372 字,大约阅读时间需要 4 分钟。

AssetBundle打包指南

步骤一:在Assets文件夹中创建两个新文件夹,分别命名为Editor和streamingAssets。             步骤二:选择需要打包的文件并进行打包操作。             以下是完整的代码示例:
using UnityEngine;using UnityEditor;using System.Collections;

public class AssetBundle : MonoBehaviour{[MenuItem("Custom Editor/Create AssetBundles Main")]static void CreateAssetBundlesMain(){Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);foreach (Object obj in SelectedAsset){string sourcePath = AssetDatabase.GetAssetPath(obj);string targetPath = Application.dataPath + "/StreamingAssets" + obj.name + ".assetbundle";

if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies))        {            Debug.Log(obj.name + " success");        }        else         {            Debug.Log(obj.name + " failure");        }    }}

}

如何从AssetBundle加载预设

使用以下代码可以实现从AssetBundle中加载预设的功能: using UnityEngine;using System.Collections;public class LoadAB : MonoBehaviour {    public void Start()    {        StartCoroutine(LoadBundle("file://"+Application.streamingAssetsPath+"/"+"StreamingAssetsNew Prefab.assetbundle"));    }    private IEnumerator LoadBundle(string path)    {        WWW load = new WWW(path);        yield return load;        GameObject obj = GameObject.Instantiate(load.assetBundle.mainAsset) as GameObject;        load.assetBundle.Unload(false);    }}

转载地址:http://oxelz.baihongyu.com/

你可能感兴趣的文章
opencv25-直方图反向投影
查看>>
opencv26-模板匹配
查看>>
opencv27-轮廓发现
查看>>
opencv28-凸包
查看>>
opencv29-轮廓周围绘制矩形框和圆形框
查看>>
OpenCV3 install tutorial for Mac
查看>>
opencv3-Mat对象
查看>>
opencv30-图像矩
查看>>
opencv32-基于距离变换和分水岭的图像分割
查看>>
opencv4-图像操作
查看>>
opencv5-图像混合
查看>>
opencv6-调整图像亮度和对比度
查看>>
opencv7-绘制形状和文字
查看>>
opencv8-图像模糊
查看>>
opencv9-膨胀和腐蚀
查看>>
OpenCV_ cv2.imshow()
查看>>
opencv_core.dir/objects.a(vs_version.rc.obj)‘ is incompatible with i386:x86-64 output
查看>>
opencv——图像缩放1(resize)
查看>>
opencv——最简单的视频读取
查看>>
Opencv——模块介绍
查看>>