using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class BundleBuilder : EditorWindow
{
/// <summary>
/// 选中的asset以及folder
/// </summary>
public class AssetEntry
{
public string path; // 路径
public bool selected = true; // 是否选中
}
/// <summary>需要生成asset bundle包</summary>
protected static List<AssetBundleBuild> builds = new List<AssetBundleBuild>();
protected static bool ms_isDebugBuild = false;
protected static BuildTarget target = BuildTarget.Android;
protected static string outputPath = ".";
protected static string version = "0.0.0.1";
protected static void SelectAll(List<AssetEntry> all)
{
foreach (AssetEntry entry in all)
{
entry.selected = true;
}
}
protected static void UnselectAll(List<AssetEntry> all)
{
foreach (AssetEntry entry in all)
{
entry.selected = false;
}
}
protected static void GetDependencies(string path, string extension, ref Dictionary<string, bool> Dependencies)
{
string[] dep = AssetDatabase.GetDependencies(path);
string depsPath = "";
for (int i = 0; i < dep.Length; ++i)
{
depsPath = Path.GetExtension(dep[i]).ToLower();
if (depsPath.Contains(extension))
{
if (!Dependencies.ContainsKey(dep[i]))
{
Dependencies.Add(dep[i], true);
}
}
}
}
protected static void GetDependencies(string[] path, string extension, ref Dictionary<string, bool> Dependencies)
{
string[] dep = AssetDatabase.GetDependencies(path);
string depsPath = "";
for (int i = 0; i < dep.Length; ++i)
{
depsPath = Path.GetExtension(dep[i]).ToLower();
if (depsPath.Contains(extension))
{
if (!Dependencies.ContainsKey(dep[i]))
{
Dependencies.Add(dep[i], true);
}
}
}
}
public static void BuildTargetSetting()
{
// 编译平台
//target = (BuildTarget)EditorGUILayout.EnumPopup("Build target", target);
// 输出路径
GUILayout.Label("Output path", EditorStyles.boldLabel);
//GUI.contentColor = Color.green;
outputPath = FileSystem.PackagePath();
if (GUILayout.Button(outputPath == string.Empty ? "Output path" : outputPath, EditorStyles.miniButtonMid))
{
outputPath = EditorUtility.SaveFolderPanel("Save folder",FileSystem.PackagePath(), "");
}
// 版本号
//version = EditorGUILayout.TextField("Version", version);
version = Application.version;
EditorGUILayout.LabelField("Version", version);
}
protected static BuildTarget mBuildTarget
{
get
{
#if UNITY_IPHONE
return BuildTarget.iOS;
#elif UNITY_ANDROID
return BuildTarget.Android;
#else
return BuildTarget.StandaloneWindows;
#endif
}
}
}