标签:
using UnityEngine; using UnityEditor; using System.Collections; using System.Collections.Generic; using System.IO; public class LBAssetBundle : EditorWindow { public const string MenuPath = "Assets/LBBuild/Online/"; public const string MenuPathLocal = "Assets/LBBuild/Local/"; public const string ScenePath = "Scene/"; public const string ObjectPath = "Object/"; [MenuItem(MenuPath + ObjectPath + "All")] static void Build_Object_ALL() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.IOS, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.iPhone); } foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.Android, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android); } foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.PC, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ObjectPath + "PC")] static void Build_Object_PC() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.PC, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPathLocal + ObjectPath + "PC")] static void Build_Object_PC_Local() { if(Selection.objects.Length != 0) { DownloadData.isLocal = true; System.DateTime Start = System.DateTime.Now; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.PC, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows); } DownloadData.isLocal = false; Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ObjectPath + "IOS")] static void Build_Object_IOS() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.IOS, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.iPhone); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ObjectPath + "Android")] static void Build_Object_Android() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); foreach(Object ob in selection) { BuildPipeline.BuildAssetBundle(ob, null, DownloadData.GetUpPath(DownloadData.platformType.Android, ob.name), BuildAssetBundleOptions.CollectDependencies, BuildTarget.Android); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ScenePath + "PC")] static void Build_Scene_PC() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; foreach(Object ob in Selection.objects) { string[] level = {AssetDatabase.GetAssetPath(ob)}; BuildPipeline.BuildStreamedSceneAssetBundle(level, DownloadData.GetUpPath(DownloadData.platformType.PC, ob.name), BuildTarget.StandaloneWindows); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPathLocal + ScenePath + "PC")] static void Build_Scene_PC_Local() { if(Selection.objects.Length != 0) { DownloadData.isLocal = true; System.DateTime Start = System.DateTime.Now; foreach(Object ob in Selection.objects) { string[] level = {AssetDatabase.GetAssetPath(ob)}; BuildPipeline.BuildStreamedSceneAssetBundle(level, DownloadData.GetUpPath(DownloadData.platformType.PC, ob.name), BuildTarget.StandaloneWindows); } DownloadData.isLocal = false; Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ScenePath + "IOS")] static void Build_Scene_IOS() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; foreach(Object ob in Selection.objects) { string[] level = {AssetDatabase.GetAssetPath(ob)}; BuildPipeline.BuildStreamedSceneAssetBundle(level, DownloadData.GetUpPath(DownloadData.platformType.IOS, ob.name), BuildTarget.iPhone); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } [MenuItem(MenuPath + ScenePath + "Android")] static void Build_Scene_Android() { if(Selection.objects.Length != 0) { System.DateTime Start = System.DateTime.Now; foreach(Object ob in Selection.objects) { string[] level = {AssetDatabase.GetAssetPath(ob)}; BuildPipeline.BuildStreamedSceneAssetBundle(level, DownloadData.GetUpPath(DownloadData.platformType.Android, ob.name), BuildTarget.Android); } Debug.Log("Time Start: " + Start + "----------- End:" + System.DateTime.Now); } } }
标签:
原文地址:http://www.cnblogs.com/jiangjieqim/p/4643747.html