Пример #1
0
 public void SelectItemUpdate()
 {
     if (m_currentPlatform != null && m_currentPlatform.buildTargetGroup != P.i.selectBuildTargetGroup)
     {
         m_currentPlatform = null;
     }
     if (m_currentPlatform == null)
     {
         m_currentPlatform = P.GetSelectPlatform();
         //BMS.i.platformList.Add( m_currentPlatform );
     }
     if (m_currentPlatform.parameters.Count == 0)
     {
         m_currentPlatform.AddParams("Debug");
         m_currentPlatform.AddParams("Release");
         m_currentPlatform.AddParams("Master");
         s_changed = true;
     }
     if (P.i.selectParamsIndex < 0)
     {
         P.i.selectParamsIndex = 0;
     }
     else if (m_currentPlatform.parameters.Count <= P.i.selectParamsIndex)
     {
         P.i.selectParamsIndex = m_currentPlatform.parameters.Count - 1;
     }
 }
Пример #2
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);
        }