Exemple #1
0
        protected override void ShowButton(Rect r)
        {
            base.ShowButton(r);
            if (HEditorGUI.IconButton(r, EditorIcon.editicon_sml, "Save WindowLayout"))
            {
                UnityEditorWindowLayout.SaveWindowLayout(kWLT.ToAssetPath());
                EditorHelper.ShowMessagePop(SS._Saved);
            }

            var exist = kPath.IsExistsFile();

            r.x -= 16;
            ScopeChange.Begin();
            GUI.Toggle(r, exist, EditorHelper.TempContent("", "Change WindowLayout"));
            if (ScopeChange.End())
            {
                if (exist)
                {
                    UnityEditorWindowLayout.LoadWindowLayout(kPath, false);
                    fs.rm(kPath);;
                }
                else
                {
                    UnityEditorWindowLayout.SaveWindowLayout(kPath);
                    UnityEditorWindowLayout.LoadWindowLayout(kWLT.ToAssetPath(), false);
                }
            }
        }
Exemple #2
0
        /////////////////////////////////////////
        void OnRowGUISceneFiles(RowGUIArgs args, Item item)
        {
            var rect = args.rowRect;

            if (item.sceneReg)
            {
                var col1 = ColorUtils.RGB(169, 201, 255);
                col1.a = 0.5f;
                EditorGUI.DrawRect(args.rowRect, col1);
            }

            rect.x += 4;
            if (HEditorGUI.IconButton(rect.W(16), EditorIcon.plus))
            {
                EditorHelper.AddSceneToBuildSetting(item.path);
                item.sceneReg = true;
            }
            rect.x += 16;
            if (HEditorGUI.IconButton(rect.W(16), item.icon))
            {
                EditorHelper.PingObject(item.path);
            }
            rect.x += 20;
            Label(args, rect.TrimR(40), item.displayName);
        }
Exemple #3
0
        /////////////////////////////////////////
        void OnRowGUISceneSet(RowGUIArgs args, Item item)
        {
            if (item.title)
            {
                if (item.id == 1)
                {
                    s_buildNo = 0;
                }
                if (!args.selected)
                {
                    HEditorStyles.sceneTopBarBg.Draw(args.rowRect);
                }
                DefaultRowGUI(args);
                return;
            }

            //DefaultRowGUI( args );
            var rect = args.rowRect;

            rect.x += 4;

            if (HEditorGUI.IconButton(rect.W(16), EditorIcon.minus))
            {
                EditorHelper.RemoveSceneToBuildSetting(item.path);
                m_registerItems.Remove(item);
                ReloadAndSorting();
                //EditorApplication.delayCall += () => RegisterFiles( m_profile );
            }

            rect.x += 16;
            if (HEditorGUI.IconButton(rect.W(16), EditorIcon.sceneasset))
            {
                EditorHelper.PingObject(item.path);
            }

            rect.x += 16;
            ScopeChange.Begin();
            item.toggle = EditorGUI.Toggle(rect.W(16), item.toggle);
            if (ScopeChange.End())
            {
                m_profile.Toggle(item.toggle, item.path);
                PB.Save();
            }

            rect.x += 20;

            Label(args, rect, item.displayName);

            if (item.toggle)
            {
                var ss = $"{s_buildNo}";
                var sz = ss.CalcSize(HEditorStyles.treeViewLine);
                rect    = args.rowRect.AlignR(sz.x);
                rect.x -= 4;
                Label(args, rect, ss);
                s_buildNo++;
            }
        }
Exemple #4
0
        public bool UIDraw(Rect rect, P.Params currentParams)
        {
            if (!HEditorGUI.IconButton(rect.W(16), EditorIcon.settings))
            {
                return(false);
            }

            UnityEditorMenu.File_Build_Settings();

            return(false);
        }
 public override void OnGUI(Rect rc)
 {
     try {
         HEditorGUI.HeaderTitle(rc, atb.name);
     }
     catch (ExitGUIException) {
     }
     catch (System.Exception e) {
         Debug.LogError(e);
     }
 }
Exemple #6
0
 public bool UIDraw(Rect rect, P.Params currentParams)
 {
     ScopeChange.Begin();
     currentParams.WebGL_exceptionSupport = (WebGLExceptionSupport)EditorGUI.EnumPopup(rect.TrimR(20), currentParams.WebGL_exceptionSupport);
     if (HEditorGUI.IconButton(rect.AlignR(16).AddX(-4), EditorIcon._help))
     {
         EditorUtility.DisplayDialog(SS._Info, infoText, SS._OK);
     }
     if (ScopeChange.End())
     {
         P.Save();
         return(true);
     }
     return(false);
 }
Exemple #7
0
 public bool UIDraw(Rect rect, P.Params currentParams)
 {
     ScopeChange.Begin();
     currentParams.WebGL_threadsSupport = EditorGUI.Toggle(rect.W(16), currentParams.WebGL_threadsSupport);
     if (HEditorGUI.IconButton(rect.AlignR(16).AddX(-4), EditorIcon._help))
     {
         EditorUtility.DisplayDialog(SS._Info, infoText, SS._OK);
     }
     if (ScopeChange.End())
     {
         P.Save();
         return(true);
     }
     return(false);
 }
        protected override void OnRowGUI(Item item, RowGUIArgs args)
        {
            DefaultRowGUI(args);

            if (!IsSelected(item.id))
            {
                return;
            }

            if (item.assetPath.IsEmpty())
            {
                return;
            }

            if (HEditorGUI.IconButton(args.rowRect.AlignR(16), EditorIcon.editicon_sml))
            {
                ReferenceEditor.Open(item.assetPath);
            }
        }
Exemple #9
0
        public bool UIDraw(Rect rect, P.Params currentParams)
        {
            if (!HEditorGUI.IconButton(rect.W(16), EditorIcon.settings))
            {
                return(false);
            }

            if (PB.i.enableOldStyleProjectSettings)
            {
                Selection.activeObject = AssetDatabase.LoadAssetAtPath <UnityObject>(AssetDatabase.GUIDToAssetPath("00000000000000004000000000000000"));
                EditorWindowUtils.Find(UnityTypes.UnityEditor_InspectorWindow)?.Focus();
            }
            else
            {
                //UnityEditorMenu.Edit_Project_Settings();
                UnityEditorSettingsWindow.Show(SettingsScope.Project, "Project/Player");
            }

            return(false);
        }
        /////////////////////////////////////////
        static ReorderableList MakeRLFromHierarchy()
        {
            if (E.i.m_dirList == null)
            {
                E.i.m_dirList = new List <string>();
            }
            var r = new ReorderableList(E.i.m_dirList, typeof(string));

            r.drawHeaderCallback = (rect) => {
                EditorGUI.LabelField(rect, S._LocalPackagePaths);
            };

            r.onAddCallback = (rect) => {
                if (E.i.m_dirList.Count == 0)
                {
                    E.i.m_dirList.Add(string.Empty);
                }
                else
                {
                    E.i.m_dirList.Add(E.i.m_dirList[r.count - 1]);
                }
            };

            r.drawElementCallback = (rect, index, isActive, isFocused) => {
                EditorGUI.BeginChangeCheck();
                var p = E.i.m_dirList[index];
                var w = rect.width;
                var x = rect.x;
                rect.y     += 1;
                rect.height = EditorGUIUtility.singleLineHeight;

                EditorGUI.BeginChangeCheck();
                E.i.m_dirList[index] = HEditorGUI.FolderFiled(rect, p);
                if (EditorGUI.EndChangeCheck())
                {
                    s_changed = true;
                }
            };

            return(r);
        }
        protected override void OnRowGUI(Item item, RowGUIArgs args)
        {
            if (0 <= m_scriptingDefineSymbols.IndexOf(item.displayName))
            {
                var col1 = ColorUtils.RGB(169, 201, 255);
                col1.a = 0.5f;
                EditorGUI.DrawRect(args.rowRect, col1);

                if (HEditorGUI.IconButton(args.rowRect.AlignR(16), EditorIcon.minus))
                {
                    EditorApplication.delayCall += () => {
                        _removeSymbol(item.displayName);
                    };
                }
            }

            for (var i = 0; i < args.GetNumVisibleColumns(); i++)
            {
                var rect        = args.GetCellRect(i);
                var columnIndex = args.GetColumn(i);

                var labelStyle = args.selected ? EditorStyles.whiteLabel : EditorStyles.label;

                switch (columnIndex)
                {
                case kCLIP_BOARD: {
                    if (HEditorGUI.IconButton(rect.AlignCenter(18, 16), EditorIcon.clipboard))
                    {
                        Clipboard.SetText(item.displayName);
                        EditorHelper.ShowMessagePop($"{SS._Copytoclipboard}\n{item.displayName}");
                    }
                    break;
                }

                case kTOGGLE: {
                    Label(args, rect, item.displayName);
                    break;
                }
                }
            }
        }
Exemple #12
0
        static Utils()
        {
            ExternalPackages.AddPB((string assetPath, string guid, ref Rect selectionRect) => {
                // Favoriteが必ず一番上に来る前提とするとrect.yは0
                // ここでは適当に1行の高さより大きいかぐらいの意味で判定している
                if (assetPath.IsEmpty() && selectionRect.y < 16 && ExternalPackages.ManifestJsonUtility)
                {
                    var r = selectionRect.AlignR(16);
#if UNITY_2020_1_OR_NEWER
                    if (HEditorGUI.IconButton(r, EditorIcon.package_manager))
                    {
                        EditorApplication.ExecuteMenuItem("Window/Package Manager");
                    }
                    r.x -= 16;
#endif
                    if (HEditorGUI.IconButton(r, EditorIcon.icons_processed_unityengine_textasset_icon_asset))
                    {
                        EditorApplication.ExecuteMenuItem("Window/Hananoki/Manifest Json Utility");
                    }
                    selectionRect.width -= 32;
                }
            });
        }
        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;
            }
        }
        /// <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();
            }
        }
Exemple #15
0
        static void DrawContentConfig()
        {
            ScopeChange.Begin();

            //PB.i.enableAssetBundleBuild = HEditorGUILayout.ToggleLeft( S._EnableAssetBundleBuild, PB.i.enableAssetBundleBuild );
            //HEditorGUI.DrawDebugRectAtLastRect();
            PB.i.enableOldStyleProjectSettings = HEditorGUILayout.ToggleLeft(S._Usingtheold_styleProjectSettings, PB.i.enableOldStyleProjectSettings);
            GUILayout.Space(8);
            PB.i.enableExlusionAssets = HEditorGUILayout.ToggleLeft(S._Enablingassetexclusionatbuildtime, PB.i.enableExlusionAssets);

            GUILayout.Label(S._ExclusionAssetsList, EditorStyles.boldLabel);

            if (s_exclusionContents == null)
            {
                if (PB.i.exclusionAssets == null)
                {
                    PB.i.exclusionAssets = new List <PB.ExclusionSets>();
                }

                //foreach(var p in PB.i.exclusionAssets ) {
                //	Debug.Log( GUIDUtils.GetAssetPath( p.GUID ) );
                //}
                s_exclusionContents = PB.i.exclusionAssets.Select(x => x.GUID.ToAssetPath()).OrderBy(value => value).Select(x => new GUIContent(x, AssetDatabase.GetCachedIcon(x))).ToArray();
            }

            int removeIndex = -1;

            ScopeVertical.Begin(EditorStyles.helpBox);
            for (int i = 0; i < s_exclusionContents.Length; i++)
            {
                var s = s_exclusionContents[i];
                ScopeHorizontal.Begin();
                GUILayout.Label(EditorHelper.TempContent(""), GUILayout.ExpandWidth(true), GUILayout.Height(18));
                ScopeHorizontal.End();

                var rc = GUILayoutUtility.GetLastRect();
                GUI.Box(rc, "", Styles.projectBrowserHeaderBgMiddle);
                GUI.Label(rc, s, Styles.labelAndIcon);
                rc.x     = rc.xMax - 16;
                rc.width = 16;
                if (HEditorGUI.IconButton(rc, EditorIcon.minus))
                {
                    removeIndex = i;
                }
            }
            GUILayout.FlexibleSpace();
            if (0 <= removeIndex)
            {
                var findGUID = s_exclusionContents[removeIndex].text.ToGUID();
                var rIndex   = PB.i.exclusionAssets.FindIndex(x => x.GUID == findGUID);
                PB.i.exclusionAssets.RemoveAt(rIndex);
                s_exclusionContents = null;
                s_changed           = true;
            }
            ScopeVertical.End();

            var dropRc = GUILayoutUtility.GetLastRect();
            var evt    = Event.current;

            switch (evt.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dropRc.Contains(evt.mousePosition))
                {
                    break;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                void AddFiles(params string[] paths)
                {
                    PB.i.exclusionAssets.AddRange(paths.Select(x => new PB.ExclusionSets(x.ToGUID(), x)).ToArray());
                    PB.i.exclusionAssets = PB.i.exclusionAssets.Distinct(x => x.GUID).ToList();
                    PB.Save();
                }

                string[] DirFiles(string path)
                {
                    return(DirectoryUtils.GetFiles(path, "*", SearchOption.AllDirectories).Where(x => x.Extension() != ".meta").ToArray());
                }

                if (evt.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();
                    if (DragAndDrop.paths.Length == 1)
                    {
                        if (Directory.Exists(DragAndDrop.paths[0]))
                        {
                            var m = new GenericMenu();
                            m.AddItem(S._Registerasafolder, false, (context) => {
                                AddFiles((string)context);
                            }, DragAndDrop.paths[0]);
                            m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => {
                                AddFiles(DirFiles((string)context));
                                ;
                            }, DragAndDrop.paths[0]);
                            m.DropDownAtMousePosition();
                        }
                        else
                        {
                            AddFiles(DragAndDrop.paths);
                        }
                    }
                    else
                    {
                        bool dirChekc = false;
                        foreach (var s in DragAndDrop.paths)
                        {
                            if (Directory.Exists(s))
                            {
                                dirChekc = true;
                                break;
                            }
                        }
                        if (dirChekc)
                        {
                            var m = new GenericMenu();
                            m.AddItem(S._Registerasafolder, false, (context) => {
                                AddFiles((string[])context);
                            }, DragAndDrop.paths);
                            m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => {
                                foreach (var s in ((string[])context))
                                {
                                    if (Directory.Exists(s))
                                    {
                                        AddFiles(DirFiles(s));
                                    }
                                    else
                                    {
                                        AddFiles(s);
                                    }
                                }
                            }, DragAndDrop.paths);
                            m.DropDownAtMousePosition();
                        }
                        else
                        {
                            AddFiles(DragAndDrop.paths);
                        }
                    }

                    DragAndDrop.activeControlID = 0;

                    s_exclusionContents = null;
                }
                s_changed = true;
                Event.current.Use();
                break;
            }

            if (ScopeChange.End())
            {
                s_changed = true;
            }
        }
        /// <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);
        }
        /// <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;
                    }
                }
            }
        }
        /// <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;
                }
            }
        }
Exemple #19
0
        public void SceneSelectTabOnGUI()
        {
            PB.Load();
            using (new VerticalScope(Styles.helpBox)) {
                using (new HorizontalScope()) {
                    void editButton()
                    {
                        var lsss = PrefixLabel(GUILayoutUtility.GetLastRect(), EditorHelper.TempContent(S._BuildSceneSet));

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

                        if (HEditorGUI.IconButton(lsss, Styles.iconEdit, 2))
                        {
                            editMode         = !editMode;
                            PB.i.profileList = PB.i.profileList.Distinct(a => a.profileName).ToList();

                            Repaint();
                        }
                    }

                    if (PB.i.profileList.Count <= PB.i.selectIndex)
                    {
                        PB.i.selectIndex = PB.i.profileList.Count - 1;
                    }

                    var lst = PB.i.profileList.Select(x => x.profileName).ToArray();

                    BeginChangeCheck();

                    if (editMode)
                    {
                        PB.i.selectProfile.profileName = EditorGUILayout.TextField(S._BuildSceneSet, PB.i.selectProfile.profileName);
                        editButton();
                    }
                    else
                    {
                        PB.i.selectIndex = EditorGUILayout.Popup(S._BuildSceneSet, PB.i.selectIndex, lst);

                        //var ls = GUILayoutUtility.GetLastRect();

                        editButton();

                        if (HEditorGUILayout.IconButton(Styles.iconPlus, 4))
                        {
                            PB.i.profileList.Add(new PB.Profile($"BuildScene ({PB.i.profileList.Count})"));
                            PB.i.selectIndex = PB.i.profileList.Count - 1;
                            s_changed        = true;
                        }
                        BeginDisabledGroup(PB.i.selectIndex == 0);
                        if (HEditorGUILayout.IconButton(Styles.iconMinus, 4))
                        {
                            PB.i.profileList.RemoveAt(PB.i.selectIndex);
                            PB.i.selectIndex = PB.i.profileList.Count - 1;
                            s_changed        = true;
                        }
                        EndDisabledGroup();
                    }

                    if (EndChangeCheck())
                    {
                        PB.Save();
                    }
                }
                BeginHorizontal();
                BeginChangeCheck();
                PB.i.selectProfile.exclusionScene = EditorGUILayout.ToggleLeft(S._ExcludescenesfromthebuildthatarenotregisteredinBuildSettings, PB.i.selectProfile.exclusionScene);
                if (Button(S._Checktheorderofthebuild, ExpandWidth(false)))
                {
                    var s = string.Join("\n", PB.GetBuildSceneName().Select((x, i) => $"{i}: {x}").ToArray());
                    EditorUtility.DisplayDialog(S._Checktheorderofthebuild, s, SS._OK);
                }
                if (EndChangeCheck())
                {
                    PB.Save();
                }

                EndHorizontal();
            }


            // Build SettingsにセットされているScene
            if (0 < m_scenePaths.Count)
            {
                Space(8);
                BeginHorizontal();
                Label(S._BuildSettingsScenes, Styles.boldLabel);
                var r = EditorHelper.GetLayout(Styles.iconSettings, HEditorStyles.iconButton);
                if (HEditorGUI.IconButton(r, Styles.iconSettings, B.kBuildSettings, 1))
                {
                    UnityEditorMenu.File_Build_Settings();
                }
                EndHorizontal();

                foreach (var p in m_scenePaths)
                {
                    BeginHorizontal(Styles.helpBox);
                    BeginDisabledGroup(true);
                    Toggle(p.enabled, "");
                    EndDisabledGroup();
                    Label(EditorHelper.TempContent(SceneName(p.path), EditorIcon.SceneAsset), Height(16));
                    if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
                    {
                        EditorHelper.PingObject(p.path);
                        Event.current.Use();
                    }
                    FlexibleSpace();

                    foreach (var pp in PB.i.profileList)
                    {
                        BeginChangeCheck();
                        var toggle = Toggle(pp.Has(p.path), pp.profileName, "Button");
                        if (EndChangeCheck())
                        {
                            pp.Toggle(toggle, p.path);
                            PB.Save();
                        }
                    }
                    EndHorizontal();
                }
            }

            // Build SettingsにセットされていないScene
            Space(8);
            Label(S._ScenesotherthanBuildSettings, Styles.boldLabel);
            foreach (var scenePath in m_leakedScenes)
            {
                BeginHorizontal(Styles.helpBox);
                Space(20);
                Label(EditorHelper.TempContent(scenePath, EditorIcon.SceneAsset), Height(16));
                if (EditorHelper.HasMouseClick(GUILayoutUtility.GetLastRect()))
                {
                    EditorHelper.PingObject(scenePath);
                    Event.current.Use();
                }
                FlexibleSpace();
                foreach (var pp in PB.i.profileList)
                {
                    BeginChangeCheck();
                    var toggle = Toggle(pp.Has(scenePath), pp.profileName, "Button");
                    if (EndChangeCheck())
                    {
                        pp.Toggle(toggle, scenePath);
                        PB.Save();
                    }
                }
                EndHorizontal();
            }
        }
        /// <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;
            }
        }