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

编辑器场景打包资源

时间:2015-04-03 13:26:30      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

打包场景的代码,比较简单.
主要是调用 BuildStreamedSceneAssetBundle 方法,执行命令后会弹出默认当前场景名字的菜单,选择路径,即可生成.unity3d资源包.

备案可查.


1
using UnityEngine; 2 using UnityEditor; 3 4 public class ExportAssetBundles 5 { 6 [MenuItem("Assets/Build iOS Streamed")] 7 static void ExportAsset() 8 { 9 //Clean Cache 10 Caching.CleanCache (); 11 12 string[] levels = new string[] {EditorApplication.currentScene}; // Assets/CurrentSceneName.unity 13 14 int length = EditorApplication.currentScene.Split (/).Length; 15 16 string editorPath = EditorApplication.currentScene.Split (/) [length - 1]; 17 18 //Get current scene name 19 string Name = editorPath.Substring (0, editorPath.Length - 6); 20 21 string Path = EditorUtility.SaveFilePanel ("Save Resource", "", Name, "unity3d"); 22 23 if (!Path.Equals(string.Empty) && !Name.Equals(string.Empty) ) { 24 BuildPipeline.BuildStreamedSceneAssetBundle (levels, Path, BuildTarget.iPhone); 25 Debug.Log(Name + " 打包成功! 存放路径是 " + Path); 26 AssetDatabase.Refresh (); 27 } 28 } 29 }


技术分享

 

编辑器场景打包资源

标签:

原文地址:http://www.cnblogs.com/leesymbol/p/4389658.html

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