Example #1
0
    private static void OpenAssetBundleWindow()
    {
        AssetBundleEditor ABEditor = GetWindow <AssetBundleEditor>("AssetBundles");

        ABEditor.Init();
        ABEditor.Show();
    }
Example #2
0
    private static void CreateWindow()
    {
        AssetBundleEditor wnd = EditorWindow.GetWindow <AssetBundleEditor>(true);

        wnd.minSize = new Vector2(500, 780);
        wnd.Show();
    }
Example #3
0
    void OnGUI()
    {
        index = EditorGUILayout.Popup("Choose the platform:", index, options, GUIStyle.none, null);

        isMultiple = EditorGUILayout.Toggle("isMultiple:", isMultiple);


        version = EditorGUILayout.FloatField("version:", version);

        if (GUILayout.Button("加密创建"))
        {
            switch (index)
            {
            case 0:
                AssetBundleEditor.AssetBundleAndEncryption(BuildTarget.Android, isMultiple, version);
                break;

            case 1:
                AssetBundleEditor.AssetBundleAndEncryption(BuildTarget.StandaloneWindows, isMultiple, version);
                break;

            case 2:
                AssetBundleEditor.AssetBundleAndEncryption(BuildTarget.iPhone, isMultiple, version);
                break;
            }
        }


        if (GUILayout.Button("测试"))
        {
            AssetBundleEditor.Test();
        }
    }
Example #4
0
    void OnEnable()
    {
        try
        {
            save = true;
            if (!Directory.Exists(ABPackHelper.BUILD_PATH))
            {
                Directory.CreateDirectory(ABPackHelper.BUILD_PATH);
            }
            if (!Directory.Exists(ABPackHelper.BUILD_PATH + LuaConst.osDir))
            {
                Directory.CreateDirectory(ABPackHelper.BUILD_PATH + LuaConst.osDir);
            }
            Instance   = this;
            abTypeMaps = new Dictionary <string, string>();
            ABData.datas.Clear();
//#if !UNITY_IOS
//            SVNHelper.UpdateVersion();
//#endif
//            // 拷贝资源版本号
//#if UNITY_IOS
//            var destVersionPath = ABPackHelper.VERSION_PATH + "version_ios.txt";
//#else
//            var destVersionPath = ABPackHelper.VERSION_PATH + "version.txt";
//#endif
//            if (!File.Exists(destVersionPath)) destVersionPath = ABPackHelper.ASSET_PATH + LuaConst.osDir + "/version.txt";
//            var versionPath = ABPackHelper.BUILD_PATH + LuaConst.osDir + "/version.txt";
//            File.Copy(destVersionPath, versionPath, true);
//            if (File.Exists(versionPath))
//                gameVersion = GameVersion.CreateVersion(File.ReadAllText(versionPath));
//            else
//                gameVersion = GameVersion.CreateVersion(Application.version);
//            // 读取游戏版本号
//            destVersionPath = ABPackHelper.VERSION_PATH + "apk_version.txt";
//            if (File.Exists(destVersionPath))
//            {
//                var ver = File.ReadAllText(destVersionPath);
//                apkVersion = Convert.ToInt32(ver);
//            }
//            else
//                apkVersion = 0;

            if (!File.Exists(DEFAULT_CONFIG_NAME))
            {
                return;
            }
            LoadConfig(DEFAULT_CONFIG_NAME);
            LoadSDKConfig();
            Refresh();
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            save = false;
            AssetBundleEditor.CloseEditor();
        }
    }
Example #5
0
    static void Open()
    {
        AssetBundleEditor window = GetWindow <AssetBundleEditor>("AssetBundleEditor");

        window.minSize = new Vector2(1055, 730);
        window.maxSize = new Vector2(1055, 730);
        //window.position = new Rect(Screen.width / 2 - 100, Screen.height / 2, 0, 0);
        window.Init();
        window.Show();
    }
    public static void BuildApp()
    {
        AssetBundleEditor.Build();
        ConfigDataEditor.AllXmlToBinary();

        CopyABToStreamAssetsPath();
        CleanBuildTargetSubDirectory();

        string buildPath = GetBuildPath();

        BuildPipeline.BuildPlayer(GetEditorScenesPathArray(), buildPath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);

        Debug.Log("打包完成");
    }
 private static void OpenAssetBundleWindows()
 {
     if (bundleEditorWindows == null)
     {
         bundleEditorWindows = GetWindow <AssetBundleEditor>();
         bundleEditorWindows.titleContent.text = "AssetBundle Editor";
         bundleEditorWindows.minSize           = new Vector2(750, 700);
         bundleEditorWindows.Show();
     }
     else
     {
         bundleEditorWindows.Close();
     }
 }
Example #8
0
        static void Build(BuildTarget buildTarget)
        {
            AssetBundleEditor.BuildAssetBundles(OutputPlaneAssetBundleDirPath, buildTarget);

            EncryptionKey        encryptionKey = new EncryptionKey();
            AssetBundleEncryptor encryptor     = new AssetBundleEncryptor(
                AssetBundleEditor.GetAssetBundleDir(OutputPlaneAssetBundleDirPath, buildTarget),
                AssetBundleEditor.GetAssetBundleDir(OutputCryptedAssetBundleDirPath, buildTarget),
                encryptionKey);

            AssetBundleTableCondition tableCondition = CreateResourceTableCondition();

            AssetBundleEditor.CreateAndBuildAssetBundleTable(
                encryptor,
                AssetBundleTableDirPath,
                buildTarget,
                tableCondition);
        }
Example #9
0
 void OnDisable()
 {
     try
     {
         if (save)
         {
             SaveConfig();
         }
         Instance = null;
         ABData.datas.Clear();
         abTypeMaps.Clear();
         abTypeMaps    = null;
         gameVersion   = null;
         Apk_Save_Path = null;
     }
     catch (Exception e)
     {
     }
 }
Example #10
0
    public static void BuildIOSProject()
    {
        string path     = string.Empty;
        bool   nobundle = false;
        string key      = string.Empty;

        foreach (string arg in System.Environment.GetCommandLineArgs())
        {
            if (arg.Contains("path:", StringComparison.OrdinalIgnoreCase))
            {
                var splitTmps = arg.Split(';');
                path     = splitTmps[0].Split(':')[1];
                nobundle = splitTmps[1].Split(':')[1].Equals("1");
                key      = splitTmps[2].Split(':')[1];
                break;
            }
        }
        XCodePostProcess.config_path = Application.dataPath + "/Res/Template/IOSConfig/" + path;
        AssetBundleEditor.OpenEditor();
        AssetBundleEditor.Instance.ReleaseIOS(path, nobundle, key);
        AssetBundleEditor.CloseEditor();
    }
Example #11
0
    private void OnGUI()
    {
        selectTab = GUILayout.Toolbar(selectTab, new string[] { "Pack", "Hotfix(需配置7z环境变量)" });
        EditorGUILayout.Space();
        //Pack
        if (selectTab == 0)
        {
            EditorGUILayout.BeginHorizontal();
            isCompress = EditorGUILayout.ToggleLeft("压缩AssetBundle(需下载7z并配置环境变量)", isCompress);
            EditorGUILayout.EndHorizontal();
            if (isCompress)
            {
                EditorGUILayout.BeginHorizontal();
                isCompressAll = EditorGUILayout.ToggleLeft("全部重新压缩", isCompressAll);
                if (GUILayout.Button("单独执行"))
                {
                    AssetBundleEditor.CompressAll();
                }
                isCompressAll = EditorGUILayout.ToggleLeft("差异压缩", !isCompressAll);
                if (GUILayout.Button("单独执行"))
                {
                    AssetBundleEditor.CompressDiff();
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        //Hotfix
        else if (selectTab == 1)
        {
            EditorGUILayout.BeginHorizontal();
            isUpdateHash = EditorGUILayout.ToggleLeft("更新线上hash文件", isUpdateHash);
            if (GUILayout.Button("单独执行"))
            {
                AssetBundleEditor.DownLoadHash();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            isCompressHotfix = EditorGUILayout.ToggleLeft("比较hash差异并压缩(未勾选更新hash将用本地hash)", isCompressHotfix);
            if (GUILayout.Button("单独执行"))
            {
                AssetBundleEditor.CompressForHotfix(isUpdateHash);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            isUpLoadHotfixZip = EditorGUILayout.ToggleLeft("上传更新压缩包", isUpLoadHotfixZip);
            if (GUILayout.Button("单独执行"))
            {
                AssetBundleEditor.UpLoadHotfixZip();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            isChangeVersion = EditorGUILayout.ToggleLeft("更新版本号(最后一位+1)", isChangeVersion);
            if (GUILayout.Button("单独执行"))
            {
                AssetBundleEditor.ChangeVersion();
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        isUpLoadHash = EditorGUILayout.ToggleLeft("上传hash文件", isUpLoadHash);
        if (GUILayout.Button("单独执行"))
        {
            AssetBundleEditor.UpLoadNewHash();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        if (GUILayout.Button("开始执行"))
        {
            AssetBundleEditor.BuildAssetBundle();
            if (selectTab == 0)
            {
                if (isCompress)
                {
                    if (isCompressAll)
                    {
                        AssetBundleEditor.CompressAll();
                    }
                    else
                    {
                        AssetBundleEditor.CompressDiff();
                    }
                }
            }
            else if (selectTab == 1)
            {
                if (isUpdateHash)
                {
                    AssetBundleEditor.DownLoadHash();
                }
                if (isCompressHotfix)
                {
                    AssetBundleEditor.CompressForHotfix(isUpdateHash);
                }
                if (isUpLoadHotfixZip)
                {
                    AssetBundleEditor.UpLoadHotfixZip();
                }
                if (isChangeVersion)
                {
                    AssetBundleEditor.ChangeVersion();
                }
            }
            if (isUpLoadHash)
            {
                AssetBundleEditor.UpLoadNewHash();
            }
        }
    }
Example #12
0
 static void BuildAssetBundle()
 {
     Debug.Log("正在打包...");
     AssetBundleEditor.CreateAssetBunldesAll();
     Debug.Log("打包完成...");
 }
Example #13
0
 static void GenerateVersionFile()
 {
     Debug.Log("正在生成更新文件...");
     AssetBundleEditor.GenerateVersionContent();
     Debug.Log("生成更新文件完成...");
 }
Example #14
0
        static void SetNamesSelecting()
        {
            var namer = AssetBundleEditor.GetAssetBundleNamerWithPacking();

            namer.SetAssetNameToSelectingObjects(RootAssetDirPath);
        }
Example #15
0
        static void SetNamesAll()
        {
            var namer = AssetBundleEditor.GetAssetBundleNamerWithPacking();

            namer.SetAllAssetsName(RootAssetDirPath);
        }
Example #16
0
    /// <summary>
    /// OnInspectorGUI
    /// </summary>
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        EditorGUI.BeginChangeCheck();
        {
            serializedObject.Update();
            bool bSave = false;
            // 模式
            string value    = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
            var    index    = value.Contains("AB_MODE") ? 1 : 0;
            var    selected = GUILayout.Toolbar(index, new string[] { "编辑器模式", "高级AB模式" });
            if (index != selected)
            {
                bSave = true;
                ModeToggle(selected);
            }
            // 产品名字
            value = EditorGUILayout.TextField("Product Name", m_select[Const.PRODUCT_NAME].ToString());
            if (value != m_select[Const.PRODUCT_NAME].ToString())
            {
                bSave = true;
                m_select[Const.PRODUCT_NAME] = value;
                ChangeSettings(ChangeType.ProductName);
            }
            // 包名
            value = EditorGUILayout.TextField("Bundle Identifier", m_select[Const.BUNDLE_IDENTIFIER].ToString());
            if (value != m_select[Const.BUNDLE_IDENTIFIER].ToString())
            {
                bSave = true;
                m_select[Const.BUNDLE_IDENTIFIER] = value;
                ChangeSettings(ChangeType.BundleIdentifier);
            }
            // 版本
            value = EditorGUILayout.TextField("Version*", m_select[Const.VERSION].ToString());
            if (value != m_select[Const.VERSION].ToString())
            {
                bSave = true;
                m_select[Const.VERSION] = value;
                ChangeSettings(ChangeType.Version);
            }
            // 版本Code
#if UNITY_ANDROID
            int bundleVersionCode = EditorGUILayout.IntField("BundleVersionCode", (int)m_select[Const.BUNDLE_VERSION_CODE]);
            if (PlayerSettings.Android.bundleVersionCode != bundleVersionCode)
            {
                bSave = true;
                m_select[Const.BUNDLE_VERSION_CODE] = bundleVersionCode;
                ChangeSettings(ChangeType.BundleVersionCode);
            }
#elif UNITY_IOS
            int buildNumber = EditorGUILayout.IntField("BuildNumber", (int)m_select[Const.BUNDLE_VERSION_CODE]);
            if (PlayerSettings.iOS.buildNumber != buildNumber.ToString())
            {
                bSave = true;
                m_select[Const.BUNDLE_VERSION_CODE] = buildNumber;
                ChangeSettings(ChangeType.BundleVersionCode);
            }
#else
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.IntField("BundleVersionCode", (int)m_select[Const.BUNDLE_VERSION_CODE]);
            EditorGUILayout.LabelField("*仅Android或IOS有效");
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
#endif

            // 平台、宏定义
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField("Platform", EditorUserBuildSettings.activeBuildTarget.ToString());
            EditorGUILayout.TextField("Scripting Define Symbol", m_select[Const.SCRIPTING_DEFINE_SYMBOLS].ToString());
            EditorGUI.EndDisabledGroup();

            // 设置配置选项组
            selected = EditorGUILayout.Popup("服务器配置", m_nameList.IndexOf(m_select[Const.NAME].ToString()), m_nameList.ToArray());
            if (selected != m_nameList.IndexOf(m_select[Const.NAME].ToString()))
            {
                bSave    = true;
                m_select = m_data[selected];

                ChangeSettings(ChangeType.ProductName);
                ChangeSettings(ChangeType.BundleIdentifier);
                ChangeSettings(ChangeType.Version);
                ChangeSettings(ChangeType.BundleVersionCode);
                ChangeSettings(ChangeType.ScriptingDefineSymbols);
            }

            // 脚本
            EditorGUI.BeginDisabledGroup(true);
            SerializedProperty property = serializedObject.GetIterator();
            if (property.NextVisible(true))
            {
                EditorGUILayout.PropertyField(property, new GUIContent("Script"), true, new GUILayoutOption[0]);
            }
            EditorGUI.EndDisabledGroup();

            // 其它字段属性
            EditorGUI.BeginDisabledGroup(selected != 0);
            {
                // 登陆地址
                value = EditorGUILayout.TextField("登录地址", m_select[Const.LOGIN_URL].ToString());
                if (value != m_select[Const.LOGIN_URL].ToString())
                {
                    bSave = true;
                    m_select[Const.LOGIN_URL] = value;
                }

                // CDN
                value = EditorGUILayout.TextField("CDN资源地址", m_select[Const.CDN].ToString());
                if (value != m_select[Const.CDN].ToString())
                {
                    bSave = true;
                    m_select[Const.CDN] = value;
                }

                // 是否开启引导
                bool bValue = EditorGUILayout.Toggle("开启新手引导?", (bool)m_select[Const.OPEN_GUIDE]);
                if (bValue != (bool)m_select[Const.OPEN_GUIDE])
                {
                    bSave = true;
                    m_select[Const.OPEN_GUIDE] = bValue;
                }

                // 是否开启更新模式
                bValue = EditorGUILayout.Toggle("开启资源更新?", (bool)m_select[Const.OPEN_UPDATE]);
                if (bValue != (bool)m_select[Const.OPEN_UPDATE])
                {
                    bSave = true;
                    m_select[Const.OPEN_UPDATE] = bValue;
                }

                // 是否完全解锁所有功能
                bValue = EditorGUILayout.Toggle("开启所有功能?", (bool)m_select[Const.UNLOCK_ALL_FUNCTION]);
                if (bValue != (bool)m_select[Const.UNLOCK_ALL_FUNCTION])
                {
                    bSave = true;
                    m_select[Const.UNLOCK_ALL_FUNCTION] = bValue;
                }

                // 是否开启日志
                bValue = EditorGUILayout.Toggle("开启日志&GM工具?", (bool)m_select[Const.LOG]);
                if (bValue != (bool)m_select[Const.LOG])
                {
                    bSave = true;
                    m_select[Const.LOG] = bValue;
                }

                // 是否开启Web日志
                bValue = EditorGUILayout.Toggle("开启远程日志?", (bool)m_select[Const.WEB_LOG]);
                if (bValue != (bool)m_select[Const.WEB_LOG])
                {
                    bSave = true;
                    m_select[Const.WEB_LOG] = bValue;
                }

                // 远程日志白名单
                value = EditorGUILayout.TextField("远程日志白名单", m_select[Const.WEB_LOG_IP].ToString());
                if (value != m_select[Const.WEB_LOG_IP].ToString())
                {
                    bSave = true;
                    string   ip    = string.Empty;
                    string[] array = value.Split(',', ';', '|');
                    for (int i = 0; i < array.Length; ++i)
                    {
                        if (!string.IsNullOrEmpty(array[i]))
                        {
                            ip += ";" + array[i];
                        }
                    }
                    if (ip.StartsWith(";"))
                    {
                        ip = ip.Substring(1, ip.Length - 1);
                    }
                    m_select[Const.WEB_LOG_IP] = ip;
                }

                // [安卓]CDN资源标签
                value = EditorGUILayout.TextField("[安卓]CDN资源标签", m_select[Const.ANDROID_PLATFORM_NAME].ToString());
                if (value != m_select[Const.ANDROID_PLATFORM_NAME].ToString())
                {
                    bSave = true;
                    m_select[Const.ANDROID_PLATFORM_NAME] = value;
                }

                // [苹果]CDN资源标签
                value = EditorGUILayout.TextField("[苹果]CDN资源标签", m_select[Const.IOS_PLATFORM_NAME].ToString());
                if (value != m_select[Const.IOS_PLATFORM_NAME].ToString())
                {
                    bSave = true;
                    m_select[Const.IOS_PLATFORM_NAME] = value;
                }

                // [桌面]CDN资源标签
                value = EditorGUILayout.TextField("[桌面]CDN资源标签", m_select[Const.DEFAULT_PLATFORM_NAME].ToString());
                if (value != m_select[Const.DEFAULT_PLATFORM_NAME].ToString())
                {
                    bSave = true;
                    m_select[Const.DEFAULT_PLATFORM_NAME] = value;
                }
            }
            EditorGUI.EndDisabledGroup();

            if (selected != 0)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("复制到自定义..."))
                {
                    bSave = true;
                    foreach (var kvp in m_select)
                    {
                        if (kvp.Key.Equals(Const.NAME))
                        {
                            continue;
                        }
                        if (m_data[0].ContainsKey(kvp.Key))
                        {
                            m_data[0][kvp.Key] = kvp.Value;
                        }
                        else
                        {
                            m_data[0].Add(kvp.Key, kvp.Value);
                        }
                    }
                    m_select = m_data[0];

                    ChangeSettings(ChangeType.ProductName);
                    ChangeSettings(ChangeType.BundleIdentifier);
                    ChangeSettings(ChangeType.Version);
                    ChangeSettings(ChangeType.BundleVersionCode);
                    ChangeSettings(ChangeType.ScriptingDefineSymbols);
                }
                if (GUILayout.Button("编辑配置..."))
                {
                    if (File.Exists(versionJson))
                    {
                        System.Diagnostics.Process.Start(versionJson);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            // 打开本地沙盒资源目录
            if (GUILayout.Button("打开本地沙盒资源目录"))
            {
                string persistentDataPath = Application.persistentDataPath.Replace("/", "\\");
                System.Diagnostics.Process.Start("explorer.exe", persistentDataPath);
            }
            // 清除本地沙盒资源
            if (GUILayout.Button("清除本地沙盒资源"))
            {
                Util.SetString(Const.SANDBOX_VERSION, null);
                if (Directory.Exists(Application.persistentDataPath))
                {
                    var start = System.DateTime.Now;
                    Directory.Delete(Application.persistentDataPath, true);
                    Debug.Log("clear persistent data finished! use " + (System.DateTime.Now - start).TotalMilliseconds + " ms");
                }
            }

            value = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
            index = value.Contains("AB_MODE") ? 1 : 0;
            EditorGUI.BeginDisabledGroup(index < 0);
            {
                // 打完整资源包应用
                if (GUILayout.Button("打包完整资源"))
                {
                    m_buildAsset = true;
                }
                // 打更新资源包
                if (GUILayout.Button("打包更新资源"))
                {
                    m_buildUpdateAsset = true;
                }
            }
            EditorGUI.EndDisabledGroup();

            serializedObject.ApplyModifiedProperties();
            if (bSave)
            {
                bSave = false;
                if (m_data[0].ContainsKey("selected"))
                {
                    m_data[0]["selected"] = selected;
                }
                else
                {
                    m_data[0].Add("selected", selected);
                }
                File.WriteAllText(path, JsonWriter.Serialize(m_data[0]));
                SaveVersion();
                AssetDatabase.Refresh();
            }
        }
        EditorGUI.EndChangeCheck();
        EditorGUI.EndDisabledGroup();

        // 打完整资源包
        if (m_buildAsset)
        {
            var start = System.DateTime.Now;
            m_buildAsset = false;
            AssetBundleEditor.BuildAssetBundlesAndCopy(AssetBundleEditor.outputPath, true);
            Debug.Log("build asset finished! use " + (System.DateTime.Now - start).TotalMilliseconds + " ms");
            GUIUtility.ExitGUI();
        }
        // 打更新资源包
        if (m_buildUpdateAsset)
        {
            var start = System.DateTime.Now;
            m_buildUpdateAsset = false;
            App.Init();
            AssetBundleEditor.BuildUpdateAssetBundlesAndZip(AssetBundleEditor.outputPath, AssetBundleEditor.outputVersionPath, App.version, App.platform, false, App.cdn);
            Debug.Log("build update asset finished! use " + (System.DateTime.Now - start).TotalMilliseconds + " ms");
            GUIUtility.ExitGUI();
        }
    }