assetBundle

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

 

posted @ 2015-07-13 19:45  泥潭里的金鱼  阅读(158)  评论(0)    收藏  举报