Exemplo n.º 1
0
        public void Draw(BuildAssistWindow parent)
        {
            var currentParams = P.GetCurrentParams();

            parent.DrawGUI_PackageName();
            parent.DrawGUI_ConfigurationSelect();

            parent.DrawGUI_AssetBundle();
            parent.DrawGUI_BuildSettings();
            parent.DrawGUI_PlayerSettings();

            DrawGUI_WebGL(currentParams);

            parent.DrawGUI_OutputDirectory();



            bool once = false;

            void errorLabel(string s, string icon = "")
            {
                var c = EditorStyles.label.normal.textColor;

                EditorStyles.label.normal.textColor = Color.red;
                EditorStyles.label.fontStyle        = FontStyle.Bold;

                GUILayout.Label(EditorHelper.TempContent(s, Icon.Get(icon)), EditorStyles.label);

                EditorStyles.label.fontStyle        = FontStyle.Normal;
                EditorStyles.label.normal.textColor = c;
            }

            void errorTitle()
            {
                if (once)
                {
                    return;
                }
                errorLabel("PlayerSettings.Standalone settings are incomplete", "console.erroricon.sml");
                once = true;
            }

            if (currentParams.development)
            {
                HEditorGUILayout.BoldLabel(SS._Info, EditorIcon.Info);
                HEditorGUILayout.BoldLabel(S._NotethatWebGLdevelopmentbuildsaremuchlargerthanreleasebuildsandshoundnotbepublicsed);
            }

            GUILayout.FlexibleSpace();
            parent.DrawGUI_Bottom();
        }
Exemplo n.º 2
0
        public void MakeDefaultOutputDirectory()
        {
            var currentParams = P.GetCurrentParams();

            if (!currentParams.outputDirectoryAuto)
            {
                return;
            }

            var s = $"{Environment.CurrentDirectory}/{currentParams.buildTarget.ToString()}";

            if (currentParams.outputUseConfiguration)
            {
                s += $"/{currentParams.name}";
            }
            currentParams.outputDirectory = DirectoryUtils.Prettyfy(s);
        }
Exemplo n.º 3
0
        void ExecuteBuildPackage()
        {
            EditorApplication.delayCall += BuildPackage;

            void BuildPackage()
            {
                P.SetBuildParamIndex();
                try {
                    var flag = 0x01;
                    if (P.GetCurrentParams().buildAssetBundlesTogether)
                    {
                        flag |= 0x02;
                    }
                    BuildCommands.Build(flag);
                }
                catch (Exception e) {
                    UnityDebug.LogException(e);
                }
            };
        }
        public void Draw(BuildAssistWindow parent)
        {
            var currentParams = P.GetCurrentParams();

            if (currentParams == null)
            {
                return;
            }

            parent.DrawGUI_PackageName();
            parent.DrawGUI_ConfigurationSelect();
            parent.DrawGUI_AssetBundle();
            parent.DrawGUI_BuildSettings();
            parent.DrawGUI_PlayerSettings();
            parent.DrawGUI_OutputDirectory();

            // PlayerS
            DrawGUI_Android(currentParams);

            GUILayout.FlexibleSpace();
            parent.DrawGUI_Bottom();
        }
Exemplo n.º 5
0
        /// <summary>
        /// GUI 下部のビルド開始ボタン等の描画を行います
        /// </summary>
        public void DrawGUI_Bottom()
        {
            var currentParams = P.GetCurrentParams();

            using (new GUILayout.HorizontalScope()) {
                GUILayout.FlexibleSpace();
                GUILayout.Label(P.currentOutputPackageFullName);
            }
            using (new GUILayout.HorizontalScope()) {
                GUILayout.FlexibleSpace();

                using (new EditorGUI.DisabledGroupScope(!currentParams.development)) {
                    bool b2 = HEditorGUILayout.SessionToggleLeft(S._ConnectProfiler, S._ProfilingisonlyenabledinaDevelopmentPlayer, E.connectProfiler.Value);
                    E.connectProfiler.Value = b2;
                }
                bool b3 = HEditorGUILayout.SessionToggleLeft(S._AutoRunPlayer, E.autoRunPlayer.Value);
                E.autoRunPlayer.Value = b3;
                //GUILayout.Space( 16 );

                var rc = GUILayoutUtility.GetRect(EditorHelper.TempContent(S._SwitchPlatform, EditorIcon.Warning), GUI.skin.button, GUILayout.Width(150));


                void OnDropAction()
                {
                    var m = new GenericMenu();

                    if (Directory.Exists(P.currentOutputPackageDirectory))
                    {
                        m.AddItem(SS._OpenOutputFolder.content(), false, () => {
                            EditorUtils.ShellOpenDirectory(P.currentOutputPackageDirectory);
                        });
                    }
                    else
                    {
                        m.AddDisabledItem($"{notDirectory}{P.currentOutputPackageDirectory.Replace( "/", "." )}]".content());
                    }
                    m.AddSeparator("");
                    if (PB.i.enableAssetBundleBuild)
                    {
                        m.AddItem(S._BuildAssetBundletogether.content(), currentParams.buildAssetBundlesTogether, () => { currentParams.buildAssetBundlesTogether = !currentParams.buildAssetBundlesTogether; });
                    }
                    if (UnitySymbol.Has("UNITY_EDITOR_WIN"))
                    {
                        m.AddItem(S._CreateabuildBATfile, false, () => {
                            var tname = $"{UnityEditorUserBuildSettings.activeBuildTargetGroup.ToString()}_{currentParams.name}";
                            EditorHelper.WriteFile($"Build_{tname}.bat", b => {
                                b.AppendLine($"@echo off");
                                b.AppendLine($"set PATH=%PATH%;{EditorApplication.applicationPath.GetDirectory()}");
                                b.AppendLine($"set OPT1=-batchmode -nographics");
                                b.AppendLine($"set BUILD=-buildTarget {B.BuildTargetToBatchName( currentParams.buildTarget )}");
                                b.AppendLine($"set PROJ=-projectPath {Environment.CurrentDirectory}");
                                b.AppendLine($"set LOG=-logFile \"Logs/Editor_{tname}.log\"");
                                b.AppendLine($"set METHOD=-executeMethod Hananoki.{Package.name}.{nameof( BuildCommands )}.Batch -buildIndex:{P.i.selectParamsIndex}");
                                b.AppendLine($"Unity.exe %OPT1% %BUILD% %PROJ% %LOG% %METHOD% -quit");
                                b.AppendLine($"pause");
                            }, utf8bom: false);
                            EditorUtility.DisplayDialog(SS._Confirm, $"{S._BuildBATcreated}\n{Environment.CurrentDirectory}/{$"Build_{tname}.bat"}", SS._OK);
                        });
                    }
                    m.DropDown(HEditorGUI.lastRect.PopupRect());
                }

                if (UnityEditorUserBuildSettings.activeBuildTargetGroup != P.i.selectBuildTargetGroup)
                {
                    HEditorGUI.DropDown(rc, EditorHelper.TempContent(S._SwitchPlatform, EditorIcon.Warning), Styles.dropDownButton, 20,
                                        () => PlatformUtils.SwitchActiveBuildTarget(P.i.selectBuildTargetGroup),
                                        OnDropAction
                                        );
                }
                else
                {
                    HEditorGUI.DropDown(rc, E.autoRunPlayer.Value ? S._BuildAndRun : S._Build, Styles.dropDownButton, 20,
                                        () => {
                        if (IsSwitchPlatformAbort())
                        {
                            return;
                        }
                        ExecuteBuildPackage();
                    },
                                        OnDropAction);
                }
                rc = HEditorGUI.lastRect;
                GUI.Label(rc.AddH(-3), GUIContent.none, Styles.dopesheetBackground);
                if (UnitySymbol.Has("UNITY_EDITOR_WIN"))
                {
                    if (P.GetSelectPlatform().buildTargetGroup == BuildTargetGroup.Standalone)
                    {
                        if (File.Exists(P.currentOutputPackageFullName))
                        {
                            if (HEditorGUILayout.ImageButton(EditorIcon.PlayButton, GUILayout.Width(30)))
                            {
                                System.Diagnostics.Process.Start(P.currentOutputPackageFullName);
                            }
                        }
                    }
                    if (P.GetSelectPlatform().buildTargetGroup == BuildTargetGroup.WebGL)
                    {
                        if (File.Exists($"{P.currentOutputPackageFullName}/index.html"))
                        {
                            if (HEditorGUILayout.ImageButton(EditorIcon.PlayButton, GUILayout.Width(30)))
                            {
                                //System.Diagnostics.Process.Start( $"{P.currentOutputPackageFullName}/index.html" );
                                Application.OpenURL("http://localhost/");
                            }
                        }
                    }
                }
            }
            GUILayout.Space(10);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        public void DrawGUI_OutputDirectory()
        {
            var  currentParams = P.GetCurrentParams();
            bool fold;
            bool _outputDirectoryAuto    = currentParams.outputDirectoryAuto;
            bool _outputUseConfiguration = currentParams.outputUseConfiguration;

            using (new GUILayout.VerticalScope(Styles.helpBox)) {
                using (new GUILayout.HorizontalScope()) {
                    EditorGUI.BeginChangeCheck();
                    fold = HEditorGUILayout.Foldout(E.i.fold.Has(E.FoldOutputDirectory), "Output Directory");
                    E.i.fold.Toggle(E.FoldOutputDirectory, fold);
                    if (EditorGUI.EndChangeCheck())
                    {
                        s_changed = true;
                    }

                    GUILayout.FlexibleSpace();
                    var r = GUILayoutUtility.GetRect(20, 18);
                }


                if (fold)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.indentLevel++;

                    EditorGUI.BeginChangeCheck();
                    using (new GUILayout.HorizontalScope()) {
                        _outputDirectoryAuto = HEditorGUILayout.ToggleLeft(S._Autosetting, _outputDirectoryAuto);
                        using (new EditorGUI.DisabledGroupScope(!_outputDirectoryAuto)) {
                            _outputUseConfiguration = HEditorGUILayout.ToggleLeft(S._UseConfigurationName, _outputUseConfiguration);
                        }
                        GUILayout.FlexibleSpace();
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (_outputDirectoryAuto)
                        {
                            currentParams.outputDirectoryAuto    = _outputDirectoryAuto;
                            currentParams.outputUseConfiguration = _outputUseConfiguration;
                            MakeDefaultOutputDirectory();
                        }
                        s_changed = true;
                    }

                    string _outputDirectory = currentParams.outputDirectory;
                    var    rect             = GUILayoutUtility.GetRect(_outputDirectory.content(), EditorStyles.label, GUILayout.Height(16));

                    var r1 = rect;
                    r1.width -= 16;
                    EditorGUI.LabelField(r1, SS._Directory, _outputDirectory);
                    if (!_outputDirectoryAuto)
                    {
                        var r2 = rect;
                        r2.x     = r1.xMax;
                        r2.width = 16;
                        if (HEditorGUI.IconButton(r2, Icon.Get("Folder Icon")))
                        {
                            var _path = EditorUtility.OpenFolderPanel(S._SelectOutputDirectory, _outputDirectory, "");
                            if (!string.IsNullOrEmpty(_path))
                            {
                                _outputDirectory = _path;
                                s_changed        = true;
                            }
                        }
                    }

                    EditorGUI.indentLevel--;
                    if (EditorGUI.EndChangeCheck() || s_changed)
                    {
                        currentParams.outputDirectoryAuto    = _outputDirectoryAuto;
                        currentParams.outputUseConfiguration = _outputUseConfiguration;
                        currentParams.outputDirectory        = _outputDirectory;
                        s_changed = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// GUI Player Settingsの描画を行います
        /// </summary>
        public void DrawGUI_PlayerSettings()
        {
            var currentParams = P.GetCurrentParams();

            int  opt = currentParams.platformOption;
            bool fold;


            using (new GUILayout.VerticalScope(Styles.helpBox)) {
                using (new GUILayout.HorizontalScope()) {
                    EditorGUI.BeginChangeCheck();

                    fold = HEditorGUILayout.Foldout(E.i.fold.Has(E.FoldPlatform), "Player Settings");
                    E.i.fold.Toggle(E.FoldPlatform, fold);
                    if (EditorGUI.EndChangeCheck())
                    {
                        s_changed = true;
                    }

                    GUILayout.FlexibleSpace();

                    var r = EditorHelper.GetLayout(Styles.iconSettings, HEditorStyles.iconButton);

                    if (HEditorGUI.IconButton(r, Styles.iconSettings, 1))
                    {
                        if (PB.i.enableOldStyleProjectSettings)
                        {
                            Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityObject>(AssetDatabase.GUIDToAssetPath("00000000000000004000000000000000"));
                            EditorUtils.InspectorWindow().Focus();
                        }
                        else
                        {
                            UnityEditorMenu.Edit_Project_Settings();
                        }
                    }
                }

                EditorGUI.BeginChangeCheck();
                if (fold)
                {
                    EditorGUI.indentLevel++;

                    if (P.i.selectBuildTargetGroup == BuildTargetGroup.Standalone ||
                        P.i.selectBuildTargetGroup == BuildTargetGroup.Android)
                    {
                        currentParams.scriptingBackend = (ScriptingImplementation)EditorGUILayout.Popup(S._ScriptingBackend, (int)currentParams.scriptingBackend, B.kScriptingBackendNames);
                    }

                    bool backend = false;
                    if (P.i.selectBuildTargetGroup == BuildTargetGroup.WebGL)
                    {
                    }
                    else if (currentParams.scriptingBackend == ScriptingImplementation.Mono2x)
                    {
                        backend = true;
                    }
                    using (new EditorGUI.DisabledGroupScope(backend)) {
                        currentParams.il2CppCompilerConfiguration = (Il2CppCompilerConfiguration)EditorGUILayout.EnumPopup(S._C__CompilerConfiguration, currentParams.il2CppCompilerConfiguration);
                    }
                    EditorGUILayout.LabelField($"{S._ScriptingDefineSymbols} ({S._Applybuildonly})");


                    using (new GUILayout.HorizontalScope()) {
                        currentParams.scriptingDefineSymbols = EditorGUILayout.TextField(currentParams.scriptingDefineSymbols);
                        var mm = R.Method("GetSymbolList", "Hananoki.SymbolSettings.SettingsProject", "Hananoki.SymbolSettings.Editor");
                        if (mm != null)
                        {
                            var tc = GUILayoutUtility.GetRect(EditorHelper.TempContent(Styles.iconPlus), HEditorStyles.iconButton, GUILayout.Width(16), GUILayout.Height(16));

                            if (HEditorGUI.IconButton(tc, Styles.iconPlus, 3))
                            {
                                GUI.FocusControl("");
                                void add(object obj)
                                {
                                    var s  = obj as string;
                                    var ss = currentParams.scriptingDefineSymbols.Split(';');

                                    ArrayUtility.Add(ref ss, s);
                                    currentParams.scriptingDefineSymbols = string.Join(";", ss.Where(x => !x.IsEmpty()).Distinct().ToArray());
                                }

                                var hoge = (ValueTuple <string[], string[]>)mm.Invoke(null, null);
                                var lst  = new List <string>();
                                var m    = new GenericMenu();
                                foreach (var s in hoge.Item1)
                                {
                                    m.AddItem("Project/" + s, false, add, s);
                                }
                                foreach (var s in hoge.Item2)
                                {
                                    m.AddItem("Editor/" + s, false, add, s);
                                }
                                m.DropDown(tc);
                            }
                        }
                    }
                    EditorGUILayout.LabelField($"{S._ScriptingDefineSymbols} ({S._Current})");
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.TextField(B.scriptingDefineSymbols);
                    EditorGUI.EndDisabledGroup();

                    EditorGUI.indentLevel--;
                    GUILayout.Space(4);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    currentParams.platformOption = opt;
                    s_changed = true;
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// GUI Build Settingsの描画を行います
        /// </summary>
        public void DrawGUI_BuildSettings()
        {
            var currentParams = P.GetCurrentParams();

            EditorGUI.BeginChangeCheck();

            bool fold;

            using (new GUILayout.VerticalScope(Styles.helpBox)) {
                using (new GUILayout.HorizontalScope()) {
                    fold = HEditorGUILayout.Foldout(E.i.fold.Has(E.FoldBuildSettings), "Build Settings");
                    E.i.fold.Toggle(E.FoldBuildSettings, fold);
                    GUILayout.FlexibleSpace();
                    //EditorGUI.DrawRect( GUILayoutUtility.GetLastRect(), new Color( 0, 0, 1, 0.2f ) );

                    var r = EditorHelper.GetLayout(Styles.iconSettings, HEditorStyles.iconButton);
                    if (HEditorGUI.IconButton(r, Styles.iconSettings, B.kBuildSettings, 1))
                    {
                        UnityEditorMenu.File_Build_Settings();
                    }
                }

                if (fold)
                {
                    EditorGUI.indentLevel++;
                    currentParams.development = EditorGUILayout.Toggle(S._DevelopmentBuild, currentParams.development);

                    if (P.i.selectBuildTargetGroup == BuildTargetGroup.Android)
                    {
                        currentParams.buildAppBundle = EditorGUILayout.Toggle(S._BuildAppBundle_GooglePlay_, currentParams.buildAppBundle);
                    }

                    if (P.i.selectBuildTargetGroup == BuildTargetGroup.Standalone ||
                        P.i.selectBuildTargetGroup == BuildTargetGroup.Android)
                    {
                        string[] ss = { "Default", "LZ4", "LZ4HC" };
                        switch (EditorGUILayout.Popup(S._CompressionMethod, currentParams.compression.ToIndex(), ss, Styles.miniPopup))
                        {
                        case 0:
                            currentParams.compression = Compression.None;
                            break;

                        case 1:
                            currentParams.compression = Compression.Lz4;
                            break;

                        case 2:
                            currentParams.compression = Compression.Lz4HC;
                            break;
                        }
                    }

                    EditorGUI.indentLevel--;
                    GUILayout.Space(2);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                s_changed = true;
            }
        }
Exemplo n.º 9
0
        public void DrawGUI_AssetBundle()
        {
            if (!PB.i.enableAssetBundleBuild)
            {
                return;
            }

            var currentParams = P.GetCurrentParams();
            int opt           = currentParams.assetBundleOption;

            EditorGUI.BeginChangeCheck();
            using (new GUILayout.VerticalScope(Styles.helpBox)) {
                bool fold;
                using (new GUILayout.HorizontalScope()) {
                    fold = HEditorGUILayout.Foldout(E.i.fold.Has(E.FoldAssetBundle), "Asset Bundle");
                    E.i.fold.Toggle(E.FoldAssetBundle, fold);

                    GUILayout.FlexibleSpace();
                    bool b7 = HEditorGUILayout.ToggleLeft(S._ClearFiles, opt.Has(P.BUNDLE_OPTION_CLEAR_FILES));
                    opt.Toggle(P.BUNDLE_OPTION_CLEAR_FILES, b7);

                    var rc = EditorHelper.GetLayout(Styles.iconSettings, Styles.dropDownButton, GUILayout.Width(80), GUILayout.Height(16));

                    HEditorGUI.DropDown(rc, S._Build, Styles.dropDownButton, 18,
                                        () => {
                        if (IsSwitchPlatformAbort())
                        {
                            return;
                        }
                        ExecuteBuildBundle();
                    },
                                        () => {
                        var m = new GenericMenu();
                        if (Directory.Exists(P.i.outputAssetBundleDirectory))
                        {
                            m.AddItem(new GUIContent(SS._OpenOutputFolder), false, () => { EditorUtils.ShellOpenDirectory(P.i.outputAssetBundleDirectory); });
                        }
                        else
                        {
                            m.AddDisabledItem(new GUIContent($"{notDirectory}{P.i.outputAssetBundleDirectory.Replace( "/", "." )}"));
                        }
                        m.DropDown(HEditorGUI.lastRect.PopupRect());
                    });


                    if (_enableAssetBundle)
                    {
                        var r = EditorHelper.GetLayout(Styles.iconSettings, HEditorStyles.iconButton);
                        if (HEditorGUI.IconButton(r, Styles.iconSettings, 2))
                        {
                            EditorApplication.ExecuteMenuItem(Window_AssetBundle_Browser);
                            Event.current.Use();
                        }
                    }

                    rc = HEditorGUI.lastRect;
                    GUI.Label(rc.AddH(-3), GUIContent.none, Styles.dopesheetBackground);
                }
                GUILayout.Space(2);
                if (fold)
                {
                    EditorGUI.indentLevel++;
                    bool bst = HEditorGUILayout.ToggleLeft(S._CopyingthebuildresultstoStreamingAssets, opt.Has(P.BUNDLE_OPTION_COPY_STREAMINGASSETS));
                    currentParams.assetBundleCompressionMode = EditorGUILayout.Popup(S._Compression, currentParams.assetBundleCompressionMode, s_CompressionMode, Styles.miniPopup);
                    bool b1 = HEditorGUILayout.ToggleLeft(s_BundleOptions[0], opt.Has(P.BUNDLE_OPTION_EXCLUDETYPEINFORMATION));
                    bool b2 = HEditorGUILayout.ToggleLeft(s_BundleOptions[1], opt.Has(P.BUNDLE_OPTION_FORCEREBUILD));
                    bool b3 = HEditorGUILayout.ToggleLeft(s_BundleOptions[2], opt.Has(P.BUNDLE_OPTION_IGNORETYPETREECHANGES));
                    bool b4 = HEditorGUILayout.ToggleLeft(s_BundleOptions[3], opt.Has(P.BUNDLE_OPTION_APPENDHASH));
                    bool b5 = HEditorGUILayout.ToggleLeft(s_BundleOptions[4], opt.Has(P.BUNDLE_OPTION_STRICTMODE));
                    bool b6 = HEditorGUILayout.ToggleLeft(s_BundleOptions[5], opt.Has(P.BUNDLE_OPTION_DRYRUNBUILD));

                    opt.Toggle(P.BUNDLE_OPTION_COPY_STREAMINGASSETS, bst);
                    opt.Toggle(P.BUNDLE_OPTION_EXCLUDETYPEINFORMATION, b1);
                    opt.Toggle(P.BUNDLE_OPTION_FORCEREBUILD, b2);
                    opt.Toggle(P.BUNDLE_OPTION_IGNORETYPETREECHANGES, b3);
                    opt.Toggle(P.BUNDLE_OPTION_APPENDHASH, b4);
                    opt.Toggle(P.BUNDLE_OPTION_STRICTMODE, b5);
                    opt.Toggle(P.BUNDLE_OPTION_DRYRUNBUILD, b6);
                    GUILayout.Space(2);

                    EditorGUI.indentLevel--;
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                currentParams.assetBundleOption = opt;
                s_changed = true;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// GUI 構成の描画を行います
        /// </summary>
        public void DrawGUI_ConfigurationSelect()
        {
            var currentParams = P.GetCurrentParams();

            using (new GUILayout.HorizontalScope()) {
                void editBUto()
                {
                    var lsss = EditorGUI.PrefixLabel(GUILayoutUtility.GetLastRect(), EditorHelper.TempContent(S._Configuration));

                    lsss.x    -= Styles.iconEdit.width;
                    lsss.x    -= 2;
                    lsss.width = Styles.iconEdit.width;

                    if (HEditorGUI.IconButton(lsss, Styles.iconEdit, 2))
                    {
                        editMode = !editMode;
                        Repaint();
                        Event.current.Use();
                    }
                }

                var lst = m_currentPlatform.parameters.Select(x => x.name).ToArray();

                if (editMode)
                {
                    currentParams.name = EditorGUILayout.TextField(S._Configuration, currentParams.name);
                    editBUto();
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    P.i.selectParamsIndex = EditorGUILayout.Popup(S._Configuration, P.i.selectParamsIndex, lst);
                    if (EditorGUI.EndChangeCheck())
                    {
                        s_changed = true;
                    }

                    var ls = GUILayoutUtility.GetLastRect();

                    editBUto();

                    if (HEditorGUILayout.IconButton(Styles.iconPlus, 4))
                    {
                        m_currentPlatform.AddParams($"New ({m_currentPlatform.parameters.Count})");
                        P.i.selectParamsIndex = m_currentPlatform.parameters.Count - 1;
                        Event.current.Use();
                        s_changed = true;
                    }

                    if (HEditorGUILayout.IconButton(Styles.iconMinus, 4))
                    {
                        m_currentPlatform.parameters.RemoveAt(P.i.selectParamsIndex);
                        P.i.selectParamsIndex = m_currentPlatform.parameters.Count - 1;
                        Event.current.Use();
                        s_changed = true;
                    }
                }
            }


            EditorGUILayout.LabelField(S._BuildSceneSet, PB.i.GetSelectedPopupName(currentParams), EditorStyles.popup);
            var rrc = EditorGUI.PrefixLabel(GUILayoutUtility.GetLastRect(), S._BuildSceneSet.content());

            if (EditorHelper.HasMouseClick(rrc))
            {
                void OnSelect(object context)
                {
                    currentParams.buildSceneSetIndex = context.ToInt();
                    P.Save();
                }

                var m = new GenericMenu();
                m.AddItem(S._UsethestandardBuildSettings, false, OnSelect, -1);
                m.AddSeparator("");
                for (int idx = 0; idx < PB.i.profileList.Count; idx++)
                {
                    var p = PB.i.profileList[idx];
                    m.AddItem(p.profileName, false, OnSelect, idx);
                }
                m.DropDown(rrc);
                Event.current.Use();
            }
        }
Exemplo n.º 11
0
        static string BuildAssetBundle()
        {
            if (!PB.i.enableAssetBundleBuild)
            {
                return(string.Empty);
            }

            var    currentParams = P.GetCurrentParams();
            string result        = "";

            var outputPath = "AssetBundles/" + currentParams.buildTarget.ToString();

            if (currentParams.assetBundleOption.Has(P.BUNDLE_OPTION_CLEAR_FILES))
            {
                try {
                    fs.rm(outputPath, true);
                }
                catch (Exception e) {
                    Debug.LogException(e);
                }
            }

            try {
                string[] assetBundleNames = AssetDatabase.GetAllAssetBundleNames();

                AssetBundleBuild[] builds = new AssetBundleBuild[assetBundleNames.Length];
                for (int i = 0; i < builds.Length; i++)
                {
                    builds[i].assetBundleName = assetBundleNames[i];
                    builds[i].assetNames      = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleNames[i]);
                }

                fs.mkdir(outputPath);

                Debug.Log("# Start BuildPipeline.BuildAssetBundles:");
                var manifest = BuildPipeline.BuildAssetBundles(
                    outputPath,
                    builds,
                    currentParams.assetBundleOptions,
                    currentParams.buildTarget);

                if (currentParams.assetBundleOption.Has(P.BUNDLE_OPTION_COPY_STREAMINGASSETS))
                {
                    for (int i = 0; i < builds.Length; i++)
                    {
                        var p = builds[i].assetBundleName;
                        fs.cp($"{outputPath}/{p}", $"{Application.streamingAssetsPath}/{p}", true);
                    }
                }

                B.CallEvent(typeof(BuildAssistEventAssetBundleBuildPostProcess));

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
            catch (Exception e) {
                Debug.LogException(e);
                throw;
            }
            return(result);
        }