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

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

打包:

①Assets下新建文件夹Editor和steamingAssets

②对选定文件打包:

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");            }        }    }}

从Asset Bundle加载预设:

1 using UnityEngine; 2 using System.Collections; 3  4 public class loadAB : MonoBehaviour { 5  6     // Use this for initialization 7     void Start () { 8         StartCoroutine (loadBundle("file://"+Application.streamingAssetsPath+"/"+"StreamingAssetsNew Prefab.assetbundle")); 9     }10     11     // Update is called once per frame12     void Update () {13     14     }15     private IEnumerator loadBundle(string path) {16         WWW load = new WWW (path);17         yield return load;18         GameObject obj = GameObject.Instantiate (load.assetBundle.mainAsset) as GameObject;19         load.assetBundle.Unload (false);20     }21 }

 

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

你可能感兴趣的文章
Mtab书签导航程序 LinkStore/getIcon SQL注入漏洞复现
查看>>
myeclipse配置springmvc教程
查看>>
MyEclipse配置SVN
查看>>
MTCNN 人脸检测
查看>>
MyEcplise中SpringBoot怎样定制启动banner?
查看>>
MyPython
查看>>
MTD技术介绍
查看>>
MySQL
查看>>
MySQL
查看>>
mysql
查看>>
MTK Android 如何获取系统权限
查看>>
MySQL - 4种基本索引、聚簇索引和非聚索引、索引失效情况、SQL 优化
查看>>
MySQL - ERROR 1406
查看>>
mysql - 视图
查看>>
MySQL - 解读MySQL事务与锁机制
查看>>
MTTR、MTBF、MTTF的大白话理解
查看>>
mt_rand
查看>>
mysql -存储过程
查看>>
mysql /*! 50100 ... */ 条件编译
查看>>
mysql 1045解决方法
查看>>