static bool BuildMachineAssets(PlatformType platformType)
    {
        bool        result = false;
        BuildTarget target = BuildAssetBundleHelper.GetBuildTarget(platformType);

        if (target != BuildTarget.NoTarget)
        {
            //Note: Important fix. If don't switch platform, everytime before building AssetBundle,
            //it will take much time to switch to the particular platform.
            PerformBuild.SwitchBuildPlatform(target);

            string path = BuildAssetBundleHelper.GetAssetBundlePath(platformType);
            BuildAssetBundleHelper.DeleteAllFilesInDir(path);

            foreach (SingleMachineAssetConfig config in _machineConfig._machineConfigs)
            {
                if (config._selected)
                {
                    string   bundleName  = config._name.ToLower();
                    string[] assetNames  = AssetDatabase.GetAssetPathsFromAssetBundle(bundleName);
                    bool     buildResult = BuildAssetBundles.BuildBundlesFromMap(path, "", platformType, target,
                                                                                 false, bundleName, assetNames);
                    Debug.Log("Build MachineAsset result:" + buildResult.ToString());
                    Debug.Assert(buildResult);

                    WriteMachineVersionToFile(path, bundleName, config._version);
                }
            }

            result = true;
        }
        return(result);
    }
예제 #2
0
    static void Init()
    {
        BuildAssetBundles window = (BuildAssetBundles)EditorWindow.GetWindow(typeof(BuildAssetBundles));

        window.minSize        = new Vector2(500, 400);
        window.wantsMouseMove = true;
        window.Show();
    }
예제 #3
0
    private static void BuildBundleIos()
    {
        CommonAssetSetting();
        if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS)
        {
            throw new Exception(" unity not ios platform now");
        }

        Debug.LogError("begin build bundle" + DateTime.Now.ToLongTimeString());
        ClearBundle();
        BuildAssetBundles.BuildAllAssetBundle();
    }
예제 #4
0
    private void Init()
    {
        string stylePrePath = string.Format("{0}/CreatAssetBundle/", Application.dataPath);

        BuildAssetBundles.Pack(stylePrePath + "PlatformLobby/DataTable", "DataTable");

        //以Assets目录创建根对象
        _asset = new AssetInfo(Application.dataPath + "/CreatAssetBundle", "CreatAssetBundle", true);
        //从根对象开始,读取所有文件创建子对象
        EditorTool.ReadAssetsInChildren(_asset);

        Resources.UnloadUnusedAssets();
    }
예제 #5
0
    static bool BuildSingleExcel(PlatformType platform, BuildTarget target, string excelName, string outputPath, ExcelDirType dirType)
    {
        List <string> allResPaths = BuildAssetBundleHelper.GetSingleExcelResourcePaths(dirType, excelName);
        string        bundleName  = ExcelConfig.GetBundleName(dirType, excelName);
        bool          result      = BuildAssetBundles.BuildBundlesFromMap(outputPath, "", platform, target, false, bundleName, allResPaths);

        if (!result)
        {
            Debug.Log("Warn: Fail to build excel: " + excelName);
        }

        return(result);
    }
예제 #6
0
    private static void BuildBundleApk()
    {
        PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.ForceInternal;
        PlayerSettings.Android.forceInternetPermission  = true;
        CommonAssetSetting();
        if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
        {
            throw new Exception(" unity not apk platform now");
        }

        Debug.LogError("begin build bundle" + DateTime.Now.ToLongTimeString());
        ClearBundle();
        BuildAssetBundles.BuildAllAssetBundle();
    }
예제 #7
0
    void LoadAssetCallback(string assetBundleName, string assetPath)
    {
        if (!(collectionInclude || collectionExclude))
        {
            EditorAssetBundles.LoadAssetCallback -= LoadAssetCallback;
            return;
        }
        //Debug.Log("Load Asset: " + assetPath);
        string guid = AssetDatabase.AssetPathToGUID(assetPath);

        if (!string.IsNullOrEmpty(guid))
        {
            bool changed = false;

            if (collectionInclude)
            {
                var item = BuildAssetBundles.FindGroupItem(collectionInclude, assetPath);
                if (item != null)
                {
                    if (!item.includeGuids.Contains(guid))
                    {
                        item.includeGuids.Add(guid);
                        Debug.Log(AssetBundles.LogPrefix + $"<{collectionInclude.name}> Group Include : {assetPath}");
                        changed = true;
                        EditorUtility.SetDirty(collectionInclude);
                    }
                }
            }
            else if (collectionExclude)
            {
                var item = BuildAssetBundles.FindGroupItem(collectionExclude, assetPath);
                if (item != null)
                {
                    if (!item.excludeGuids.Contains(guid))
                    {
                        item.excludeGuids.Add(guid);
                        Debug.Log(AssetBundles.LogPrefix + $"<{collectionExclude.name}> Group Exclude : {assetPath}");
                        changed = true;
                        EditorUtility.SetDirty(collectionExclude);
                    }
                }
            }
            if (changed)
            {
                Repaint();
            }
        }
    }
예제 #8
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            var assetPath = AssetDatabase.GetAssetPath(target);
            var importer  = AssetImporter.GetAtPath(assetPath);

            if (!importer)
            {
                return;
            }
            float margin = 2;

            r.xMin += margin;
            r.xMax -= margin;
            r.yMin += margin;

            r.height = EditorGUIUtility.singleLineHeight;
            float labelWidth = 80;
            float labelSpace = 0;
            Rect  rect;

            rect = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Path: "));
            string value;

            value = assetPath;
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            value = BuildAssetBundles.GetAddressableName(assetPath);
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Name: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            value = target.GetType().Name;
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Asset Type: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));

            string bundleName = AssetDatabase.GetImplicitAssetBundleName(assetPath);

            value = AssetBundles.IsPreloadedBundle(bundleName).ToString();
            r.y  += EditorGUIUtility.singleLineHeight;
            rect  = GUIDrawLabel(new Rect(r.x, r.y, labelWidth, r.height), new GUIContent("Preloaded: "));
            GUIDrawValue(new Rect(rect.xMax + labelSpace, r.y, r.width - rect.width - labelSpace, r.height), new GUIContent(value, value));
        }
예제 #9
0
    static bool BuildLiveUpdateAssets()
    {
        bool        result = false;
        BuildTarget target = BuildAssetBundleHelper.GetBuildTarget(_liveUpdateConfig._platformType);

        if (target != BuildTarget.NoTarget)
        {
            //Note: Important fix. If don't switch platform, everytime before building AssetBundle,
            //it will take much time to switch to the particular platform.
            PerformBuild.SwitchBuildPlatform(target);

            string path = BuildAssetBundleHelper.GetAssetBundlePath(_liveUpdateConfig._platformType);
            BuildAssetBundleHelper.DeleteAllFilesInDir(path);

            ExcelDirType  dirType     = BuildAssetBundleHelper.GetExcelDirType(target);
            List <string> allResPaths = BuildAssetBundleHelper.GetAllExcelResourcePaths(dirType, _liveUpdateConfig._excelFileNames);
            allResPaths.AddRange(_liveUpdateConfig._resourcePaths);

            result = BuildAssetBundles.BuildBundlesFromMap(path, _liveUpdateConfig._version, _liveUpdateConfig._platformType, target,
                                                           true, _liveUpdateConfig._bundleName, allResPaths);
        }
        return(result);
    }
예제 #10
0
    /*
     * void Reload()
     * {
     *  foreach (var item in asset.items)
     *      item.guids.Clear();
     *
     *  foreach (var bundleName in AssetDatabase.GetAllAssetBundleNames())
     *  {
     *      foreach (var assetPath in AssetDatabase.GetAssetPathsFromAssetBundle(bundleName))
     *      {
     *          var item = BuildAssetBundles.FindGroupItem(asset, assetPath);
     *
     *          if (item != null)
     *          {
     *              string guid = AssetDatabase.AssetPathToGUID(assetPath);
     *              if (!item.guids.Contains(guid))
     *              {
     *                  item.guids.Add(guid);
     *              }
     *          }
     *      }
     *  }
     *  EditorUtility.SetDirty(asset);
     * }*/


    void ValidateAssets()
    {
        var    asset = Asset;
        string assetPath;
        bool   changed = false;

        for (int i = 0; i < asset.items.Count; i++)
        {
            var item = asset.items[i];
            for (int j = 0; j < item.excludeGuids.Count; j++)
            {
                string guid = item.excludeGuids[j];
                assetPath = AssetDatabase.GUIDToAssetPath(guid);

                if (string.IsNullOrEmpty(assetPath))
                {
                    item.excludeGuids.RemoveAt(j);
                    changed = true;
                    j--;
                    Debug.Log(AssetBundles.LogPrefix + $"Remove <{guid}>. missing");
                    continue;
                }
                if (!BuildAssetBundles.IsMatch(item, assetPath))
                {
                    item.excludeGuids.RemoveAt(j);
                    changed = true;
                    j--;
                    Debug.Log(AssetBundles.LogPrefix + $"Remove <{ assetPath}>. no matching include & exclude");
                    continue;
                }
            }
        }
        if (changed)
        {
            EditorUtility.SetDirty(asset);
        }
    }
예제 #11
0
    static bool BuildABTestAssets()
    {
        bool        result = false;
        BuildTarget target = BuildAssetBundleHelper.GetBuildTarget(_abTestConfig._platformType);

        if (target != BuildTarget.NoTarget)
        {
            //Note: Important fix. If don't switch platform, everytime before building AssetBundle,
            //it will take much time to switch to the particular platform.
            PerformBuild.SwitchBuildPlatform(target);

            ExcelDirType dirType = BuildAssetBundleHelper.GetExcelDirType(target);
            result = true;
            foreach (string abVersion in _abTestConfig._abVersions)
            {
                string path = BuildAssetBundleHelper.GetAssetBundlePath(_abTestConfig._platformType);
                BuildAssetBundleHelper.DeleteAllFilesInDir(path);

                BuildABTestHelper.CopyABToProject(abVersion, dirType);

                string version = _abTestConfig._version + "." + abVersion;

                List <string> allResPaths = BuildAssetBundleHelper.GetAllExcelResourcePaths(dirType, _abTestConfig._excelFileNames);
                allResPaths.AddRange(_abTestConfig._resourcePaths);

                bool r = BuildAssetBundles.BuildBundlesFromMap(path, version, _abTestConfig._platformType, target,
                                                               true, _abTestConfig._bundleName, allResPaths);

                if (!r)
                {
                    result = false;
                }
            }
        }
        return(result);
    }
예제 #12
0
    //各要素の描画
    void DrawProperties()
    {
        //AssetBundleTool debugViewer = target as AssetBundleTool;

        /*
         * EditorGUILayout.LabelField ("名前", "test");
         * EditorGUILayout.LabelField ("コメント", "test");
         *
         * EditorGUILayout.Separator ();
         */


        EditorGUILayout.Separator();

        /*
         * if (GUILayout.Button ("定義ファイル読み取り", GUILayout.Width (250f))) {
         *      CSMaker.ReadClass();
         * }
         */

        EditorGUILayout.HelpBox("アセットバンドル照合用のEXCELファイルを生成します.", MessageType.Info, true);

        if (GUILayout.Button("データチェッカーファイルを生成", GUILayout.Width(250f)))
        {
            AssetBudleDataChecker.DataSeetMake();
        }

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("↓オブジェクト初期生成", MessageType.Info, true);

        if (GUILayout.Button("C#ファイル生成", GUILayout.Width(250f)))
        {
            CSMaker.CSParser();

            //スクリプタブルオブジェクト生成コードを生成
            CSMaker.CSParserObjectMaker();

            //Atach生成コードを設置
            CSMaker.MakeAtachHolderFormat();

            //CSV出入力系を生成
            CSMaker.MakeCSVLoader();

            //EXCEL出入力系を生成
            CSMaker.MakeExcelLoader();

            Debug.LogWarning("MakeEnd :");
        }


        EditorGUILayout.Separator();

        if (GUILayout.Button("スクリプタブルオブジェクト生成", GUILayout.Width(250f)))
        {
            //スクリプタブルオブジェクト生成
            CSMaker.GenerateScriptableObject();

            //スクリプタブルオブジェクトをアタッチ
            CSMaker.AtachObject();
            Debug.LogWarning("Holder生成とスクリプタブルオブジェクト設置");
        }


        EditorGUILayout.Separator();
                #if UNITY_IOS
        if (GUILayout.Button("データのアセットバンドル生成(iOS)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.StartMakeAssetBundle(BuildTarget.iOS);
        }
        EditorGUILayout.Separator();
        if (GUILayout.Button("利用不可:データのアセットバンドル生成(Android)", GUILayout.Width(250f)))
        {
            Debug.LogError("Please SwitchPlatform for Android");
        }
                #elif UNITY_ANDROID
        if (GUILayout.Button("利用不可:データのアセットバンドル生成(iOS)", GUILayout.Width(250f)))
        {
            Debug.LogError("Please SwitchPlatform for iOS");
        }
        EditorGUILayout.Separator();
        if (GUILayout.Button("データのアセットバンドル生成(Android)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.StartMakeAssetBundle(BuildTarget.Android);
        }
                #else
                #endif

//		EditorGUILayout.Separator();
//
//		if (GUILayout.Button ("データのアセットバンドル生成2", GUILayout.Width (250f))) {
//			BuildPipeline.BuildAssetBundles ("AssetBundles");
//		}

        EditorGUILayout.Separator();

        if (GUILayout.Button("Excelひな形生成(上書き注意)", GUILayout.Width(250f)))
        {
            ExcelParser.MakeDataSeet();
        }


        if (GUILayout.Button("CSVひな形生成(上書き注意)", GUILayout.Width(250f)))
        {
            CSVPerser.MakeCSV();
        }

        EditorGUILayout.HelpBox("↓オブジェクト初期生成", MessageType.Info, true);

        EditorGUILayout.Separator();

        if (GUILayout.Button("EXCEL→CSV変換(上書き注意)", GUILayout.Width(250f)))
        {
            ExcelLoader.LoadExcelAndMakeCSV();
            Debug.LogWarning("変換終了 :");
        }

        if (GUILayout.Button("CSV→EXCEL変換(上書き注意)", GUILayout.Width(250f)))
        {
            CSVLoader.LoadCSVAndMakeExcel();
            Debug.LogWarning("変換終了 :");
        }

        if (GUILayout.Button("CSV→ScriptableObject変換", GUILayout.Width(250f)))
        {
            CSMaker.SetSTODataFromCSV();
        }

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("データローダシステム側を更新します", MessageType.Info, true);

        if (GUILayout.Button("データロードコンテナを更新", GUILayout.Width(250f)))
        {
            CSMaker.MakeDataContainer();
        }

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("フォントのアセットバンドルを生成します", MessageType.Info, true);

                #if UNITY_IOS
        if (GUILayout.Button("BitmapFont(iOS)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.MakeAssetBundle("AssetBundle/BitmapFont/", "BitmapFontPrefab", "BitmapFont/", BuildTarget.iOS);
        }
        if (GUILayout.Button("利用不可:BitmapFont(Android)", GUILayout.Width(250f)))
        {
            Debug.LogError("Please SwitchPlatform for Android");
        }
                #elif UNITY_ANDROID
        if (GUILayout.Button("利用不可:BitmapFont(iOS)", GUILayout.Width(250f)))
        {
            Debug.LogError("Please SwitchPlatform for iOS");
        }
        if (GUILayout.Button("BitmapFont(Android)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.MakeAssetBundle("AssetBundle/BitmapFont/", "BitmapFontPrefab", "BitmapFont/", BuildTarget.Android);
        }
                #endif

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("アトラスのアセットバンドルを生成します", MessageType.Info, true);

                #if UNITY_IOS
        foreach (string buildURL in buildAtlasPathArray)
        {
            if (GUILayout.Button(buildURL + "(iOS)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAtlas(buildURL, BuildTarget.iOS);
            }
        }

        EditorGUILayout.Separator();

        foreach (string filename in buildAtlasNameArray)
        {
            if (GUILayout.Button("filename:" + filename + "(iOS)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAtlasSingle("Assetbundle/Atlas/" + filename + "/", filename, "AssetBundles/Atlas/", BuildTarget.iOS);
            }
        }
                #elif UNITY_ANDROID
        foreach (string buildURL in buildAtlasPathArray)
        {
            if (GUILayout.Button(buildURL + "(Android)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAtlas(buildURL, BuildTarget.Android);
            }
        }

        EditorGUILayout.Separator();

        foreach (string filename in buildAtlasNameArray)
        {
            if (GUILayout.Button("filename:" + filename + "(Android)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAtlasSingle("Assetbundle/Atlas/" + filename, filename, "AssetBundles/Atlas/", BuildTarget.Android);
            }
        }
                #endif

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("Audioのアセットバンドルを生成します", MessageType.Info, true);

                #if UNITY_IOS
        foreach (string buildURL in buildAudioDataArray)
        {
            if (GUILayout.Button(buildURL + "(iOS)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAudio(buildURL, BuildTarget.iOS);
            }
        }
                #elif UNITY_ANDROID
        foreach (string buildURL in buildAudioDataArray)
        {
            if (GUILayout.Button(buildURL + "(Android)", GUILayout.Width(250f)))
            {
                BuildAssetBundles.BuildStartAudio(buildURL, BuildTarget.Android);
            }
        }
                #endif

        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("管理ファイルの生成を行います", MessageType.Info, true);

        if (GUILayout.Button("管理ファイルを更新", GUILayout.Width(250f)))
        {
            CSVPerser.MakeAssetBundleList();
        }

                #if UNITY_IOS
        if (GUILayout.Button("管理ファイルのアセットバンドル生成(iOS)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.StartMakeAssetBundleList(BuildTarget.iOS);
        }
                #elif UNITY_ANDROID
        if (GUILayout.Button("管理ファイルのアセットバンドル生成(Android)", GUILayout.Width(250f)))
        {
            BuildAssetBundles.StartMakeAssetBundleList(BuildTarget.Android);
        }
                #endif

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        EditorGUILayout.HelpBox("更新クラス。チェックをはずすとデータ生成の影響外になります。アセットバンドル生成だけ対象外", MessageType.Info, true);

        CSMaker.ReadMyToggle(); // 更新
        IList <string> list = new List <string>(CSMaker.dataSeetMyToggleDictionary.Keys);
        foreach (string str in list)
        {
            if (CSMaker.dataSeetMyToggleDictionary[str].Validate)
            {
                bool _flag = CSMaker.dataSeetMyToggleDictionary[str].Enable;
                CSMaker.dataSeetMyToggleDictionary[str].Enable = EditorGUILayout.Toggle(str, _flag);
            }
        }

        /*
         * foreach (string str in list)
         * {
         *  CSMaker.MyToggle toggle = CSMaker.dataSeetMyToggleDictionary[str];
         *
         *  // 有効であれば表示
         *  if (toggle.b_validate)
         *  {
         *      toggle.b_enable = EditorGUILayout.Toggle(str, toggle.b_enable);
         *      CSMaker.dataSeetMyToggleDictionary[str].b_enable = toggle.b_enable;
         *  }
         * }
         */

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUILayout.HelpBox("自動生成したデータやC#ファイルを全部削除します。取り扱いに注意!!!", MessageType.Info, true);

        /*
         * if (GUILayout.Button ("全データリセット。取り扱い注意!!", GUILayout.Width (250f))) {
         *      //BuildAssetBundles.StartMakeAssetBundleList();
         * }
         */
    }
예제 #13
0
    private void OnGUI()
    {
        #region TITLE CREATE PLIST
        EditorGUILayout.BeginVertical("box");
        {
            EditorGUILayout.LabelField("----->>STEP[1] TITLE CREATE PLIST");
            EditorGUILayout.LabelField("保存文件路径:", SavePath);
            ClientVersion          = EditorGUILayout.TextField("客户端版本号:", ClientVersion);
            GameVersion            = EditorGUILayout.TextField("游戏版本号:", GameVersion);
            ClientUpdatePackageURL = EditorGUILayout.TextField("客户端更新包URL:", ClientUpdatePackageURL);
            AssetPackageURL        = EditorGUILayout.TextField("资源配置文件URL:", AssetPackageURL);
            ApkSize = EditorGUILayout.TextField("客户端大小(MB):", ApkSize);

            EditorGUILayout.Space();
            isDifferencePackage = EditorGUILayout.Toggle("生成服务器资源文件:", isDifferencePackage);
            EditorGUILayout.LabelField("----->>STEP[2] BUILDING ASSETBUNDLE");
            EditorGUILayout.LabelField("保存文件路径:", StreamingAssets);
            if (GUILayout.Button("发布打包 Asset Bundles"))
            {
                CreatePlist(ClientVersion);
                SaveViewValue(null, ClientVersion, GameVersion,
                              ClientUpdatePackageURL, AssetPackageURL, ApkSize);

                BuildAssetBundles.BuildAssetBundle();

                if (isDifferencePackage)
                {
                    CreateSeviserFilesData();
                }

                if (EditorUtility.DisplayDialog("发布打包完成", "完成所有任务", "ok"))
                {
                }
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();
        #endregion

        #region TITLE RELEASE COMPRESSION

        //EditorGUILayout.BeginVertical("box");
        //{
        //    EditorGUILayout.LabelField("----->>STEP[3] TITLE RELEASE COMPRESSION");
        //    //显示 上一次操作时的版本号
        //    EditorGUILayout.LabelField("压缩文件的路径 =" + StreamingAssets);
        //    EditorGUILayout.LabelField("输入发布版数据路径 =" + SaveReleasePath);
        //    ZipFileName = EditorGUILayout.TextField("ZIP包的名称(xxx.zip):", ZipFileName);
        //    CompressionFlieType = EditorGUILayout.TextField("压缩类型(例:*.u3d|*.txt)", CompressionFlieType);

        //    if (GUILayout.Button("发布版 一键生成ZIP"))
        //    {
        //        EditorPrefs.SetString(EZIPFileName, ZipFileName);
        //        EditorPrefs.SetString(EComFileTypePath, CompressionFlieType);

        //        CompressZip(StreamingAssets, SaveReleasePath, ZipFileName, CompressionFlieType);
        //    }
        //}
        //EditorGUILayout.EndVertical();
        //EditorGUILayout.Space();
        #endregion

        #region TITLE DIFFERENCE ZIP
        //EditorGUILayout.BeginVertical("box");
        //{
        //    EditorGUILayout.LabelField("----->>TITLE RELEASE DIFFERECT PACKAGE");
        //    //比对版本号
        //    if (GUILayout.Button("对比版本号 生成差异包"))
        //    {

        //    }
        //}
        //EditorGUILayout.EndVertical();
        //EditorGUILayout.Space();
        #endregion

        #region TITLE DELECT STREAMING ASSETS
        //EditorGUILayout.BeginVertical("box");
        //{
        //    EditorGUILayout.LabelField("----->>TITLE DELECT STREAMING ASSETS");
        //    //删除Application.StreamingAssets
        //    if (GUILayout.Button("删除Application.StreamingAssets下所有文件"))
        //    {
        //        Directory.Delete(StreamingAssets, true);
        //        Directory.CreateDirectory(StreamingAssets);
        //        EditorUtility.FocusProjectWindow();
        //    }
        //}
        //EditorGUILayout.EndVertical();
        //EditorGUILayout.Space();
        #endregion
    }
        public static void OnPostprocessAllAssets(string[] importedAsset, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (!EditorAssetBundleSettings.Enabled)
            {
                return;
            }

            if (deletedAssets.Length > 0)
            {
                foreach (var assetPath in deletedAssets)
                {
                    string guid = AssetDatabase.AssetPathToGUID(assetPath);
                    if (BuildAssetBundles.AddressableAsset.Remove(guid))
                    {
                        EditorUtility.SetDirty(BuildAssetBundles.AddressableAsset);
                        BuildAssetBundles.DelaySaveAssets();
                    }
                }
            }

            EditorApplication.delayCall += () =>
            {
                bool   changed  = false;
                Action onChange = () =>
                {
                    if (!changed)
                    {
                        changed = true;
                        AssetDatabase.StartAssetEditing();
                    }
                };


                foreach (string assetPath in importedAsset.Concat(movedAssets))
                {
                    string assetPathLower = assetPath.ToLower();
                    if (ignoreFileExtension.Contains(Path.GetExtension(assetPathLower)))
                    {
                        continue;
                    }

                    if (ignoreDirection.Where(o => assetPathLower.StartsWith(o)).FirstOrDefault() != null)
                    {
                        continue;
                    }

                    if (Directory.Exists(assetPath))
                    {
                        continue;
                    }
                    //if (EditorAssetBundles.Logger.logEnabled)
                    //    EditorAssetBundles.Logger.Log(EditorAssetBundles.LogTag, "AssetBundlePostprocessor: " + assetPath);
                    if (BuildAssetBundles.UpdateAssetBundleName(assetPath))
                    {
                        onChange();
                    }
                }


                if (changed)
                {
                    AssetDatabase.StopAssetEditing();
                }
            };
        }
예제 #15
0
        private void OnGUI()
        {
            //BuildAssetBundleSettings config = Config;

            using (EditorAssetBundles.EditorLocalizationValues.BeginScope())
            {
                using (new GUILayout.HorizontalScope())
                {
                    //GUILayout.Label("Mode".Localization(), GUILayout.ExpandWidth(false));
                    EditorAssetBundles.Mode = (AssetBundleMode)EditorGUILayout.EnumPopup(EditorAssetBundles.Mode, GUILayout.ExpandWidth(false));
                    if (GUILayout.Button("Release".Localization()))
                    {
                        BuildAssetBundles.Release();
                    }
                    if (GUILayout.Button("Build".Localization()))
                    {
                        BuildAssetBundles.Build();
                    }
                }

                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Refresh".Localization()))
                    {
                        BuildAssetBundles.UpdateAllAssetBundleNames();
                    }
                    if (GUILayout.Button("Remove Unused Bundle Names".Localization()))
                    {
                        EditorAssetBundles.RemoveUnusedAssetBundleNames();
                    }
                    if (GUILayout.Button("gen AssetBundleNames.dll".Localization()))
                    {
                        BuildAssetBundles.GenerateAssetBundleNamesClass();
                    }
                    if (GUILayout.Button("Delete All Crypto".Localization()))
                    {
                        BuildAssetBundles.DeleteAllCryptoOrSignatureBuildAssetBundle();
                    }
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label("Open Directory".Localization());
                    if (GUILayout.Button("Local".Localization()))
                    {
                        EditorAssetBundles.OpenLocalDirectory_Menu();
                    }
                    if (GUILayout.Button("StreamingAssets"))
                    {
                        EditorAssetBundles.OpenStreamingAssetsDirectory_Menu();
                    }
                    if (GUILayout.Button("Output".Localization()))
                    {
                        EditorAssetBundles.OpenBuildDirectory_Menu();
                    }
                }
                GUIVersionList();


                using (var sv = new GUILayout.ScrollViewScope(scrollPos))
                    using (var checker = new EditorGUI.ChangeCheckScope())
                        using (var enabledScope = new EditorGUILayout.ToggleGroupScope(new GUIContent("Enabled".Localization()), EditorAssetBundleSettings.Enabled))
                        {
                            scrollPos = sv.scrollPosition;
                            EditorAssetBundleSettings.Enabled = enabledScope.enabled;
                            ShowAdvancedOptions = EditorGUILayout.Toggle("Show Advanced Options".Localization(), ShowAdvancedOptions);

                            EditorAssetBundleSettings.Options = (BuildAssetBundleOptions)EditorGUILayout.EnumFlagsField(new GUIContent("Options".Localization()), EditorAssetBundleSettings.Options);

                            AssetBundleSettings.BundleVersion = EditorGUILayout.DelayedTextField(new GUIContent("Bundle Version".Localization()), AssetBundleSettings.BundleVersion ?? string.Empty);
                            AssetBundleSettings.Channel       = EditorGUILayout.DelayedTextField(new GUIContent("Channel".Localization()), AssetBundleSettings.Channel ?? string.Empty);

                            if (ShowAdvancedOptions)
                            {
                                AssetBundleSettings.BuildManifestPath                 = new GUIContent("Build Path".Localization()).FolderField(AssetBundleSettings.BuildManifestPath ?? string.Empty, "AssetBundle Build Path", relativePath: ".");
                                AssetBundleSettings.StreamingAssetsManifestPath       = new GUIContent("StreamingAssets Path".Localization()).FolderField(AssetBundleSettings.StreamingAssetsManifestPath ?? string.Empty, "StreamingAssets Path", relativePath: ".");
                                EditorAssetBundleSettings.StreamingAssetsExcludeGroup = EditorGUILayout.DelayedTextField(new GUIContent("StreamingAssets Exclude Group".Localization()), EditorAssetBundleSettings.StreamingAssetsExcludeGroup ?? string.Empty);

                                AssetBundleSettings.LocalManifestPath = EditorGUILayout.DelayedTextField(new GUIContent("Local Path".Localization()), AssetBundleSettings.LocalManifestPath ?? string.Empty);
                            }


                            EditorAssetBundleSettings.AssetBundleName = EditorGUILayout.DelayedTextField(new GUIContent("AssetBundle Name".Localization()), EditorAssetBundleSettings.AssetBundleName ?? string.Empty);

                            using (new GUILayout.HorizontalScope())
                            {
                                EditorAssetBundleSettings.AssetName = EditorGUILayout.DelayedTextField(new GUIContent("Asset Name".Localization()), EditorAssetBundleSettings.AssetName ?? string.Empty);
                                GUILayout.Label("Lower".Localization(), GUILayout.ExpandWidth(false));
                                EditorAssetBundleSettings.AssetNameToLower = GUILayout.Toggle(EditorAssetBundleSettings.AssetNameToLower, GUIContent.none, GUILayout.ExpandWidth(false));
                            }

                            if (ShowAdvancedOptions)
                            {
                                using (new GUILayout.HorizontalScope())
                                {
                                    EditorGUILayout.PrefixLabel(new GUIContent("App Version Format".Localization()));
                                    AssetBundleSettings.AppVersionFormat = EditorGUILayoutx.DelayedPlaceholderField(AssetBundleSettings.AppVersionFormat ?? string.Empty, new GUIContent("{0}.{1}.{2}"));
                                }
                                AssetBundleSettings.VersionFile = EditorGUILayout.DelayedTextField(new GUIContent("Version File".Localization()), AssetBundleSettings.VersionFile ?? string.Empty);

                                EditorAssetBundleSettings.BundleCodeResetOfAppVersion = EditorGUILayout.Toggle(new GUIContent("BundleCode Reset Of AppVersion".Localization(), "BundleCode Reset Of AppVersion".Localization()), EditorAssetBundleSettings.BundleCodeResetOfAppVersion);



                                if (EditorAssetBundleSettings.AssetBundleNamesClass == null)
                                {
                                    EditorAssetBundleSettings.AssetBundleNamesClass = new EditorAssetBundleSettings.AssetBundleNamesClassSettings();
                                }


                                using (var tg = new EditorGUILayout.ToggleGroupScope("AssetBundleNames Class".Localization(), EditorAssetBundleSettings.AssetBundleNamesClassSettings.Enabled))
                                {
                                    EditorGUI.indentLevel++;
                                    using (new GUILayout.VerticalScope())
                                    {
                                        EditorAssetBundleSettings.AssetBundleNamesClassSettings.Enabled        = tg.enabled;
                                        EditorAssetBundleSettings.AssetBundleNamesClassSettings.FilePath       = EditorGUILayout.DelayedTextField("File Path".Localization(), EditorAssetBundleSettings.AssetBundleNamesClassSettings.FilePath);
                                        EditorAssetBundleSettings.AssetBundleNamesClassSettings.AssetNameClass = EditorGUILayout.DelayedTextField("Asset Name Class".Localization(), EditorAssetBundleSettings.AssetBundleNamesClassSettings.AssetNameClass);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }



                            using (new GUILayout.HorizontalScope())
                            {
                                var obj = (AssetBundleGroup)EditorGUILayout.ObjectField("Local Group".Localization(), EditorAssetBundleSettings.LocalGroup.Asset, typeof(AssetBundleGroup), false);
                                if (EditorAssetBundleSettings.LocalGroup.Asset != obj)
                                {
                                    var v = EditorAssetBundleSettings.LocalGroup;
                                    v.Asset = obj;
                                    EditorAssetBundleSettings.LocalGroup = v;
                                }

                                if (!EditorAssetBundleSettings.LocalGroup)
                                {
                                    if (GUILayout.Button("Create".Localization(), GUILayout.ExpandWidth(false)))
                                    {
                                        string path = EditorUtility.SaveFilePanel("AssetBundle Group", "Assets", BuildAssetBundles.LocalGroupName, "asset");
                                        if (!string.IsNullOrEmpty(path))
                                        {
                                            var asset = ScriptableObject.CreateInstance <AssetBundleGroup>();
                                            asset.items.Add(new AssetBundleGroup.BundleItem());
                                            path = path.Substring(Path.GetFullPath(".").Length + 1);
                                            AssetDatabase.CreateAsset(asset, path);

                                            EditorAssetBundleSettings.LocalGroup = new AssetObjectReferenced(asset);
                                        }
                                    }
                                }
                            }

                            if (!EditorAssetBundleSettings.LocalGroup)
                            {
                                EditorGUILayout.HelpBox("Require local group".Localization(), MessageType.Error);
                            }

                            EditorAssetBundleSettings.Groups = new GUIContent("Groups".Localization()).ArrayField(EditorAssetBundleSettings.Groups, (item, index) =>
                            {
                                var val = (AssetBundleGroup)EditorGUILayout.ObjectField(item.Asset, typeof(AssetBundleGroup), false);
                                if (val != item.Asset)
                                {
                                    item.Asset  = val;
                                    GUI.changed = true;
                                }
                                return(item);
                            }, initExpand: true) as AssetObjectReferenced[];



                            using (var g = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent("Download".Localization())))
                            {
                                if (g.Visiable)
                                {
                                    using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                    {
                                        AssetBundleSettings.DownloadUrl          = EditorGUILayoutx.DelayedPlaceholderField(new GUIContent("Download Url".Localization()), AssetBundleSettings.DownloadUrl, new GUIContent("http://"));
                                        AssetBundleSettings.RequireDownload      = EditorGUILayout.Toggle("Require Download".Localization(), AssetBundleSettings.RequireDownload);
                                        AssetBundleSettings.DownloadManifestPath = EditorGUILayout.DelayedTextField(new GUIContent("Download Manifest Path".Localization()), AssetBundleSettings.DownloadManifestPath ?? string.Empty);
                                        AssetBundleSettings.DownloadVersionFile  = EditorGUILayout.DelayedTextField(new GUIContent("Download Version File".Localization()), AssetBundleSettings.DownloadVersionFile ?? string.Empty);
                                        AssetBundleSettings.ReleasePath          = EditorGUILayout.DelayedTextField(new GUIContent("Release Path".Localization()), AssetBundleSettings.ReleasePath ?? string.Empty);
                                    }
                                }
                            }

                            if (EditorAssetBundleSettings.PreBuildPlayer == null)
                            {
                                EditorAssetBundleSettings.PreBuildPlayer = new EditorAssetBundleSettings.PreBuildPlayerSettings();
                            }

                            using (var g = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent("Pre Build Player".Localization())))
                            {
                                if (g.Visiable)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new GUILayout.VerticalScope())
                                    {
                                        EditorAssetBundleSettings.PreBuildPlayerSettings.AutoBuildAssetBundle = EditorGUILayout.Toggle("Auto Build AssetBundle".Localization(), EditorAssetBundleSettings.PreBuildPlayerSettings.AutoBuildAssetBundle);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            if (EditorAssetBundleSettings.PostBuildPlayer == null)
                            {
                                EditorAssetBundleSettings.PostBuildPlayer = new EditorAssetBundleSettings.PostBuildPlayerSettings();
                            }

                            using (var g = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent("Post Build Player".Localization())))
                            {
                                if (g.Visiable)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new GUILayout.VerticalScope())
                                    {
                                        EditorAssetBundleSettings.PostBuildPlayerSettings.ClearStreamingAssets = EditorGUILayout.Toggle("Clear StreamingAssets".Localization(), EditorAssetBundleSettings.PostBuildPlayerSettings.ClearStreamingAssets);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            if (EditorAssetBundleSettings.PostBuild == null)
                            {
                                EditorAssetBundleSettings.PostBuild = new EditorAssetBundleSettings.PostBuildSettings();
                            }

                            using (var g = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent("Post Build".Localization())))
                            {
                                if (g.Visiable)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new GUILayout.VerticalScope())
                                    {
                                        EditorAssetBundleSettings.PostBuildSettings.ShowFolder = EditorGUILayout.Toggle("Show Folder".Localization(), EditorAssetBundleSettings.PostBuildSettings.ShowFolder);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            if (EditorAssetBundleSettings.IgnorePaths == null)
                            {
                                EditorAssetBundleSettings.IgnorePaths = new string[0];
                            }
                            EditorAssetBundleSettings.IgnorePaths = new GUIContent("Exclude Directory".Localization()).ArrayField(EditorAssetBundleSettings.IgnorePaths, (item, index) =>
                            {
                                using (new GUILayout.HorizontalScope())
                                {
                                    item = EditorGUILayout.DelayedTextField(item);
                                }
                                return(item);
                            }, createInstance: () => "") as string[];


                            EditorAssetBundleSettings.ReleasePath = EditorGUILayout.DelayedTextField(new GUIContent("Release Path".Localization()), EditorAssetBundleSettings.ReleasePath);

                            if (EditorAssetBundleSettings.ExcludeExtensions == null)
                            {
                                EditorAssetBundleSettings.ExcludeExtensions = new string[0];
                            }
                            EditorAssetBundleSettings.ExcludeExtensions = new GUIContent("Exclude Extension".Localization()).ArrayField(EditorAssetBundleSettings.ExcludeExtensions, (item, index) =>
                            {
                                item = EditorGUILayout.DelayedTextField(item);
                                return(item);
                            }, createInstance: () => "") as string[];


                            if (EditorAssetBundleSettings.ExcludeTypeNames == null)
                            {
                                EditorAssetBundleSettings.ExcludeTypeNames = new string[0];
                            }
                            EditorAssetBundleSettings.ExcludeTypeNames = new GUIContent("Exclude Type Name".Localization()).ArrayField(EditorAssetBundleSettings.ExcludeTypeNames, (item, index) =>
                            {
                                item = EditorGUILayout.DelayedTextField(item);
                                return(item);
                            }, createInstance: () => "") as string[];

                            if (EditorAssetBundleSettings.ExcludeDependencyExtensions == null)
                            {
                                EditorAssetBundleSettings.ExcludeDependencyExtensions = new string[0];
                            }
                            EditorAssetBundleSettings.ExcludeDependencyExtensions = new GUIContent("Exclude Dependency Extension".Localization()).ArrayField(EditorAssetBundleSettings.ExcludeDependencyExtensions, (item, index) =>
                            {
                                return(EditorGUILayout.DelayedTextField(item));
                            }, createInstance: () => "") as string[];

                            if (showAdvancedOptions.Value)
                            {
                                using (var g = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent("Auto Dependency".Localization())))
                                {
                                    if (g.Visiable)
                                    {
                                        using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                        {
                                            EditorAssetBundleSettings.AutoDependencyBundleName = EditorGUILayout.DelayedTextField("Bundle Name".Localization(), EditorAssetBundleSettings.AutoDependencyBundleName);
                                            EditorAssetBundleSettings.AutoDependencySplit      = EditorGUILayout.DelayedIntField("Bundle Split".Localization(), EditorAssetBundleSettings.AutoDependencySplit);
                                        }
                                    }
                                }
                            }

                            using (var tg = new EditorGUILayout.ToggleGroupScope("Preload".Localization(), AssetBundleSettings.PreloadEnabled))
                            {
                                AssetBundleSettings.PreloadEnabled = tg.enabled;
                                if (tg.enabled)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope("box"))
                                    {
                                        AssetBundleSettings.PreloadInclude = EditorGUILayout.DelayedTextField(new GUIContent("Include".Localization(), "AssetBundle Name"), AssetBundleSettings.PreloadInclude ?? string.Empty);
                                        AssetBundleSettings.PreloadExclude = EditorGUILayout.DelayedTextField("Exclude".Localization(), AssetBundleSettings.PreloadExclude ?? string.Empty);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            using (var tg = new EditorGUILayout.ToggleGroupScope("Crypto".Localization(), AssetBundleSettings.CryptoEnabled))
                            {
                                AssetBundleSettings.CryptoEnabled = tg.enabled;
                                if (tg.enabled)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope("box"))
                                    {
                                        EditorAssetBundleSettings.CryptoKey = EditorGUILayoutx.Base64TextField(new GUIContent("Crypto Key".Localization()), EditorAssetBundleSettings.CryptoKey ?? string.Empty, 8);
                                        EditorAssetBundleSettings.CryptoIV  = EditorGUILayoutx.Base64TextField(new GUIContent("Crypto IV".Localization()), EditorAssetBundleSettings.CryptoIV ?? string.Empty, 8);
                                        AssetBundleSettings.CryptoInclude   = EditorGUILayout.DelayedTextField(new GUIContent("Include".Localization(), "AssetBundle Name"), AssetBundleSettings.CryptoInclude ?? string.Empty);
                                        AssetBundleSettings.CryptoExclude   = EditorGUILayout.DelayedTextField("Exclude".Localization(), AssetBundleSettings.CryptoExclude ?? string.Empty);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            using (var tg = new EditorGUILayout.ToggleGroupScope("Signature".Localization(), AssetBundleSettings.SignatureEnabled))
                            {
                                AssetBundleSettings.SignatureEnabled = tg.enabled;
                                if (tg.enabled)
                                {
                                    EditorGUI.indentLevel++;
                                    using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope("box"))
                                    {
                                        string pubKey;
                                        EditorAssetBundleSettings.SignatureKeyPath = EditorGUILayoutx.CryptoKeyField(new GUIContent("SignatureKeyPath".Localization()), EditorAssetBundleSettings.SignatureKeyPath ?? string.Empty, out pubKey);
                                        if (!string.IsNullOrEmpty(pubKey))
                                        {
                                            AssetBundleSettings.SignaturePublicKey = pubKey;
                                        }
                                        using (new EditorGUI.DisabledGroupScope(!string.IsNullOrEmpty(EditorAssetBundleSettings.SignatureKeyPath)))
                                        {
                                            AssetBundleSettings.SignaturePublicKey = EditorGUILayout.DelayedTextField(new GUIContent("SignaturePubKey".Localization()), AssetBundleSettings.SignaturePublicKey ?? string.Empty);
                                        }
                                        AssetBundleSettings.SignatureInclude = EditorGUILayout.DelayedTextField(new GUIContent("Include".Localization(), "AssetBundle Name"), AssetBundleSettings.SignatureInclude ?? string.Empty);
                                        AssetBundleSettings.SignatureExclude = EditorGUILayout.DelayedTextField("Exclude".Localization(), AssetBundleSettings.SignatureExclude ?? string.Empty);
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }

                            GUILayout.Space(10);

                            if (checker.changed)
                            {
                                //Debug.Log("Changed [" + config.IgnorePaths.Last()+"]");
                                //Save();

                                EditorAssetBundleSettings.Provider.Save();
                            }
                        }
            }
        }
예제 #16
0
        void GUIVersionList()
        {
            using (var header = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(true, new GUIContent("Version".Localization())))
            {
                if (header.Visiable)
                {
                    if (versionList == null)
                    {
                        List <AssetBundleVersion> list = new List <AssetBundleVersion>();
                        string dir = BuildAssetBundles.GetOutputPath();
                        if (File.Exists(dir))
                        {
                            foreach (var file in Directory.GetFiles(dir, AssetBundleSettings.VersionFile, SearchOption.AllDirectories))
                            {
                                try
                                {
                                    var item = JsonUtility.FromJson <AssetBundleVersion>(File.ReadAllText(file, Encoding.UTF8));
                                    if (item != null)
                                    {
                                        list.Add(item);
                                    }
                                }
                                catch { }
                            }
                        }
                        versionList = list.ToArray();
                    }
                    if (versionList.Length > 0)
                    {
                        using (var sv = new GUILayout.ScrollViewScope(versionListScrollPos, GUILayout.MinHeight(0), GUILayout.MaxHeight(200)))
                        {
                            versionListScrollPos = sv.scrollPosition;
                            using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                            {
                                foreach (var g in versionList.OrderByDescending(o => o.bundleCode)
                                         .OrderByDescending(o => Version.Parse(o.appVersion))
                                         .GroupBy(o => o.bundleCode)
                                         .ToArray())
                                {
                                    GUILayout.Label(new GUIContent(g.Key.ToString(), "Bundle Code".Localization()));

                                    foreach (var item in g)
                                    {
                                        using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                            using (var checker = new EditorGUI.ChangeCheckScope())
                                            {
                                                //using (new GUILayout.HorizontalScope())
                                                //{
                                                //    GUILayout.Label(item.platform);
                                                //    GUILayout.FlexibleSpace();
                                                //    GUILayout.Label(item.Timestamp.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.ExpandWidth(false));
                                                //    if (GUILayout.Button("Delete".Localization(), GUILayout.ExpandWidth(false)))
                                                //    {
                                                //        if (EditorUtility.DisplayDialog("Delete".Localization(), "Delete".Localization() + $" {item.platform} <{item.bundleCode}>", "ok".Localization(), "cancel".Localization()))
                                                //        {
                                                //            remove = item;
                                                //        }
                                                //    }
                                                //}

                                                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                                {
                                                    using (new GUILayout.HorizontalScope())
                                                    {
                                                        EditorGUILayout.PrefixLabel("App Version".Localization());
                                                        GUILayout.Label(item.appVersion.ToString());
                                                    }

                                                    EditorGUILayout.LabelField("Hash".Localization(), item.hash);
                                                    EditorGUILayout.LabelField("Commit Id".Localization(), item.commitId);

                                                    //using (new GUILayout.HorizontalScope())
                                                    //{
                                                    //    EditorGUILayout.PrefixLabel("Build Time".Localization());
                                                    //    GUILayout.Label(item.Timestamp.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"));
                                                    //}
                                                }
                                            }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("no version, generate menu  <Build/Build AssetBundle>");
                    }
                }
            }

            //if (remove != null)
            //{
            //    //BuildAssetBundles.RemoveRootVersion(remove);
            //    string outputPath = BuildAssetBundles.GetOutputPath(remove);
            //    if (Directory.Exists(outputPath))
            //    {
            //        Directory.Delete(outputPath, true);
            //        BuildAssetBundles.DeleteOutputEmptyDirectory(outputPath);
            //    }

            //    versionList = null;
            //}
        }
예제 #17
0
 public static void Build(AssetInfo _asset = null, string _buildPath = null)
 {
     BuildAssetBundles.BuildAllAssetBundles(1, _asset, _buildPath);
 }
예제 #18
0
    public void OnGUI()
    {
        using (EditorAssetBundles.EditorLocalizationValues.BeginScope())
        {
            using (new GUILayout.HorizontalScope())
            {
                int selectedIndex = -1;
                if (groupAssetPath != null)
                {
                    selectedIndex = Array.IndexOf(allGroupAssetPaths, groupAssetPath);
                }
                using (var checker = new EditorGUI.ChangeCheckScope())
                {
                    selectedIndex = EditorGUILayout.Popup(selectedIndex, allGroupAssetPaths.Select(o => Path.GetFileNameWithoutExtension(o)).ToArray());
                    if (checker.changed)
                    {
                        Asset = AssetDatabase.LoadAssetAtPath <AssetBundleGroup>(allGroupAssetPaths[selectedIndex]);
                    }
                }
                if (GUILayout.Button("New", GUILayout.ExpandWidth(false)))
                {
                    CreateAsset();
                }
            }
            if (!Asset)
            {
                return;
            }


            string assetPath;


            asset.IsLocal = EditorGUILayout.Toggle("Local".Localization(), asset.IsLocal);
            asset.IsDebug = EditorGUILayout.Toggle("Debug".Localization(), asset.IsDebug);

            //using (new GUILayout.HorizontalScope())
            //{
            //    GUILayout.Label("Items");

            //    if (GUILayout.Button("+", "label", GUILayout.ExpandWidth(false)))
            //    {
            //        asset.items.Add(new AssetBundleGroup.Item());
            //    }
            //}

            using (var sv = new GUILayout.ScrollViewScope(scrollPos))
                using (var checker = new EditorGUI.ChangeCheckScope())
                {
                    scrollPos = sv.scrollPosition;

                    asset.items = (List <AssetBundleGroup.BundleItem>) new GUIContent("Items".Localization()).ArrayField(asset.items, (item, index) =>
                                                                                                                         //for (int i = 0; i < asset.items.Count; i++)
                    {
                        //using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope("box"))
                        {
                            //AssetBundleGroup.Item item = asset.items[i];
                            //if (item.includes == null)
                            //    item.includes = new string[0];
                            //item.includes = (string[])EditorGUILayoutx.ArrayField(new GUIContent("Include"), item.includes, (o, index) =>
                            //  {
                            //      return EditorGUILayout.DelayedTextField(o);
                            //  }, initExpand: true, createInstance: () => string.Empty);

                            //if (item.excludes == null)
                            //    item.excludes = new string[0];
                            //item.excludes = (string[])EditorGUILayoutx.ArrayField(new GUIContent("Exclude"), item.excludes, (o, index) =>
                            //{
                            //    return EditorGUILayout.DelayedTextField(o);
                            //}, initExpand: true, createInstance: () => string.Empty);

                            item.include = EditorGUILayout.DelayedTextField(new GUIContent("Include".Localization()), item.include);
                            if (string.IsNullOrEmpty(item.include))
                            {
                                EditorGUILayout.HelpBox("Empty".Localization(), MessageType.Error);
                            }

                            item.exclude = EditorGUILayout.DelayedTextField(new GUIContent("Exclude".Localization()), item.exclude);

                            item.bundleName = EditorGUILayoutx.DelayedPlaceholderField(new GUIContent("AssetBundle Name".Localization()), item.bundleName ?? string.Empty, new GUIContent(EditorAssetBundleSettings.AssetBundleName));

                            using (new GUILayout.HorizontalScope())
                            {
                                item.assetName = EditorGUILayoutx.DelayedPlaceholderField(new GUIContent("Asset Name".Localization()), item.assetName ?? string.Empty, new GUIContent(EditorAssetBundleSettings.AssetName));
                                using (new EditorGUI.DisabledGroupScope(string.IsNullOrEmpty(item.assetName)))
                                {
                                    GUILayout.Label("Lower".Localization(), GUILayout.ExpandWidth(false));
                                    if (string.IsNullOrEmpty(item.assetName))
                                    {
                                        GUILayout.Toggle(EditorAssetBundleSettings.AssetNameToLower, GUIContent.none, GUILayout.ExpandWidth(false));
                                    }
                                    else
                                    {
                                        item.assetNameToLower = GUILayout.Toggle(item.assetNameToLower, GUIContent.none, GUILayout.ExpandWidth(false));
                                    }
                                }
                            }

                            item.variants = new GUIContent("Variant".Localization() + $" ({item.variants.Count})").ArrayField(item.variants, (variantItem, variantIndex) =>
                            {
                                variantItem.include = EditorGUILayout.DelayedTextField(new GUIContent("Include".Localization(), "Pattern"), variantItem.include ?? string.Empty);
                                variantItem.exclude = EditorGUILayout.DelayedTextField(new GUIContent("Exclude".Localization(), "Pattern"), variantItem.exclude ?? string.Empty);
                                variantItem.variant = EditorGUILayout.DelayedTextField("Variant".Localization(), variantItem.variant ?? string.Empty);
                                return(variantItem);
                            }, initExpand: false, itemStyle: "box") as List <AssetBundleGroup.BundleVariant>;



                            using (var foldout = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(collectionInclude, new GUIContent("Include".Localization() + $" ({item.includeGuids.Count})")))
                                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                {
                                    if (foldout.Visiable)
                                    {
                                        using (new GUILayout.HorizontalScope())
                                        {
                                            GUI.backgroundColor = collectionInclude ? Color.yellow : Color.white;

                                            if (GUILayout.Button(collectionInclude ? "Stop Collection".Localization() : "Start Collection".Localization()))
                                            {
                                                if (collectionInclude)
                                                {
                                                    StopCollection();
                                                }
                                                else
                                                {
                                                    EditorAssetBundles.LoadAssetCallback += LoadAssetCallback;
                                                    collectionInclude = asset;
                                                    collectionExclude = null;
                                                    //EditorApplication.isPlaying = true;
                                                }
                                            }
                                            GUI.backgroundColor = Color.white;

                                            if (GUILayout.Button("Clear".Localization()))
                                            {
                                                foreach (var item2 in asset.items)
                                                {
                                                    item2.includeGuids.Clear();
                                                }
                                                EditorUtility.SetDirty(asset);
                                            }
                                        }

                                        var array = item.includeGuids.Select(o => new string[] { o, AssetDatabase.GUIDToAssetPath(o) }).OrderBy(o => o[1]).ToArray();
                                        for (int j = 0; j < array.Length; j++)
                                        {
                                            string guid = array[j][0];
                                            assetPath   = array[j][1];
                                            using (new GUILayout.HorizontalScope())
                                            {
                                                if (string.IsNullOrEmpty(assetPath))
                                                {
                                                    GUI.color = Color.red;
                                                    GUILayout.Label(guid + " (missing)");
                                                    GUI.color = Color.white;
                                                }
                                                else
                                                {
                                                    string assetName = BuildAssetBundles.GetAssetName(item, assetPath);
                                                    if (GUILayout.Button(new GUIContent(assetName, assetPath), "label"))
                                                    {
                                                        EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)));
                                                    }
                                                }
                                                if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                                                {
                                                    item.includeGuids.Remove(guid);
                                                }
                                            }
                                        }
                                    }
                                }

                            using (var foldout = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(collectionExclude, new GUIContent("Exclude".Localization() + $" ({item.excludeGuids.Count})")))
                                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                {
                                    if (foldout.Visiable)
                                    {
                                        using (new GUILayout.HorizontalScope())
                                        {
                                            GUI.backgroundColor = collectionExclude ? Color.yellow : Color.white;
                                            if (GUILayout.Button(collectionExclude ? "Stop Collection".Localization() : "Start Collection".Localization()))
                                            {
                                                if (collectionExclude)
                                                {
                                                    StopCollection();
                                                }
                                                else
                                                {
                                                    EditorAssetBundles.LoadAssetCallback += LoadAssetCallback;
                                                    collectionExclude = asset;
                                                    collectionInclude = null;
                                                    //EditorApplication.isPlaying = true;
                                                }
                                            }
                                            GUI.backgroundColor = Color.white;

                                            if (GUILayout.Button("Clear".Localization()))
                                            {
                                                foreach (var item2 in asset.items)
                                                {
                                                    item2.excludeGuids.Clear();
                                                }
                                                EditorUtility.SetDirty(asset);
                                            }
                                        }

                                        var array = item.excludeGuids.Select(o => new string[] { o, AssetDatabase.GUIDToAssetPath(o) }).OrderBy(o => o[1]).ToArray();
                                        for (int j = 0; j < array.Length; j++)
                                        {
                                            string guid = array[j][0];
                                            assetPath   = array[j][1];
                                            using (new GUILayout.HorizontalScope())
                                            {
                                                if (string.IsNullOrEmpty(assetPath))
                                                {
                                                    GUI.color = Color.red;
                                                    GUILayout.Label(guid + " (missing)");
                                                    GUI.color = Color.white;
                                                }
                                                else
                                                {
                                                    string assetName = BuildAssetBundles.GetAssetName(item, assetPath);
                                                    if (GUILayout.Button(new GUIContent(assetName, assetPath), "label"))
                                                    {
                                                        EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)));
                                                    }
                                                }
                                                if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                                                {
                                                    item.excludeGuids.Remove(guid);
                                                }
                                            }
                                        }
                                    }
                                }


                            using (var foldout = new EditorGUILayoutx.Scopes.FoldoutHeaderGroupScope(false, new GUIContent($"Preview".Localization()), onShow: () =>
                            {
                                Load(item);
                            }))
                                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                                {
                                    if (foldout.Visiable)
                                    {
                                        List <string[]> list;
                                        if (cachedAssets.TryGetValue(item, out list))
                                        {
                                            int max   = displayMax;
                                            var array = list;
                                            for (int j = 0; j < list.Count && j < max; j++)
                                            {
                                                string guid = array[j][0];
                                                assetPath   = array[j][1];
                                                using (new GUILayout.HorizontalScope())
                                                {
                                                    if (string.IsNullOrEmpty(assetPath))
                                                    {
                                                        GUI.color = Color.red;
                                                        GUILayout.Label(guid + " (missing)");
                                                        GUI.color = Color.white;
                                                    }
                                                    else
                                                    {
                                                        string assetName = BuildAssetBundles.GetAssetName(item, assetPath);
                                                        string bundleName, variant;
                                                        bundleName = Asset.GetBundleName(assetPath, out variant);
                                                        if (GUILayout.Button(new GUIContent(assetName + " [" + bundleName + (string.IsNullOrEmpty(variant) ? "" : " ." + variant) + "]", assetPath), "label"))
                                                        {
                                                            EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)));
                                                        }
                                                    }
                                                }
                                            }
                                            if (list.Count > max)
                                            {
                                                GUILayout.Label("...");
                                            }
                                        }
                                    }
                                }
                        }
                        return(item);
                    }, initExpand: true, itemStyle: "box");
                    if (checker.changed)
                    {
                        EditorUtility.SetDirty(asset);
                    }
                }

            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Clear Missing".Localization()))
                {
                    ValidateAssets();
                }
                //if (GUILayout.Button("Reset"))
                //{
                //    if (Asset.items.Sum(o => o.guids.Count) == 0 || EditorUtility.DisplayDialog("Confirm", "Delete all ?", "Yes", "No"))
                //    {
                //        Reload();
                //    }
                //}
            }
        }
    }