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

assetBundle

时间:2015-07-13 20:31:58      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:

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

 

assetBundle

标签:

原文地址:http://www.cnblogs.com/jiangjieqim/p/4643747.html

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