BundleBuilder (打包基类)

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值