private void ShowTextureFallbackWarning(ref Terrain terrain)
        {
            if (!UnityEngine.Experimental.Rendering.GraphicsFormatUtility.IsCompressedFormat(terrain.terrainData.atlasFormat))
            {
                using (new EditorGUILayout.VerticalScope())
                {
                    GUILayout.Space(3);
                    using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
                    {
                        // Copied from LabelField called by HelpBox - using so that label and button link are in the same helpbox
                        var  infoLabel = EditorGUIUtility.TempContent("Atlas uncompressed. This can be caused by mismatched texture formats.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                        Rect r         = GUILayoutUtility.GetRect(infoLabel, EditorStyles.wordWrappedLabel);
                        int  oldIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel = 0;
                        EditorGUI.LabelField(r, infoLabel, EditorStyles.wordWrappedLabel);
                        EditorGUI.indentLevel = oldIndent;

                        using (new EditorGUILayout.VerticalScope())
                        {
                            GUILayout.FlexibleSpace();
                            if (EditorGUILayout.LinkButton("Read More"))
                            {
                                Help.BrowseURL($"https://docs.unity3d.com//{Application.unityVersionVer}.{Application.unityVersionMaj}/Documentation/ScriptReference/Texture2D.PackTextures.html");
                            }
                            GUILayout.FlexibleSpace();
                        }
                    }
                }
            }
        }
예제 #2
0
    public static void SetupEnumField <T>(Object target, GUIContent name, ref T member, ref bool modified, string docLink = "") where T : struct
    {
        GUILayout.BeginHorizontal();
        if (!string.IsNullOrEmpty(docLink))
        {
#if UNITY_2021_1_OR_NEWER
            if (EditorGUILayout.LinkButton(tooltipLink))
            {
                Application.OpenURL(docLink);
            }
#else
            if (GUILayout.Button(tooltipLink, GUILayout.ExpandWidth(false)))
            {
                Application.OpenURL(docLink);
            }
#endif
        }

        EditorGUI.BeginChangeCheck();
        T value = (T)(object)EditorGUILayout.EnumPopup(name, member as System.Enum);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "Changed " + name);
            member   = value;
            modified = true;
        }
        GUILayout.EndHorizontal();
    }
예제 #3
0
    public static void DisplayDocLink(string docLink)
    {
#if UNITY_2021_1_OR_NEWER
        if (EditorGUILayout.LinkButton(tooltipLink))
        {
            Application.OpenURL(docLink);
        }
#else
        if (GUILayout.Button(tooltipLink, GUILayout.ExpandWidth(false)))
        {
            Application.OpenURL(docLink);
        }
#endif
    }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.HelpBox(
                "This script is controlled by HostManager component and keeps resolved MonoBehaviour services.",
                MessageType.Info);

            // ReSharper disable once InvertIf
            if (EditorGUILayout.LinkButton("For additional information visit the GitHub link"))
            {
                var ps = new ProcessStartInfo(GITHUB_URL)
                {
                    UseShellExecute = true,
                    Verb            = "open"
                };
                Process.Start(ps);
            }
        }
        void OnGUIHandler(string searchContext)
        {
            m_SerializedObject.Update();
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField(Styles.CustomInterpLabel, EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            int newError = EditorGUILayout.IntField(Styles.CustomInterpErrorThresholdLabel, m_customInterpError.intValue);

            m_customInterpError.intValue = Mathf.Clamp(newError, kMinChannelThreshold, kMaxChannelThreshold);

            int oldWarn = m_customInterpWarn.intValue;
            int newWarn = EditorGUILayout.IntField(Styles.CustomInterpWarnThresholdLabel, m_customInterpWarn.intValue);

            // If the user did not modify the warning field, restore their previous input and reclamp against the new error threshold.
            if (oldWarn == newWarn)
            {
                newWarn = oldWarningThreshold;
            }
            else
            {
                oldWarningThreshold = newWarn;
            }

            m_customInterpWarn.intValue = Mathf.Clamp(newWarn, kMinChannelThreshold, m_customInterpError.intValue);

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label(EditorGUIUtility.IconContent("console.infoicon"), GUILayout.ExpandWidth(true));
            GUILayout.Box(kCustomInterpolatorHelpBox, EditorStyles.wordWrappedLabel);
            if (EditorGUILayout.LinkButton(Styles.ReadMore))
            {
                System.Diagnostics.Process.Start(kCustomInterpolatorDocumentationURL);
            }
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel--;

            if (EditorGUI.EndChangeCheck())
            {
                m_SerializedObject.ApplyModifiedProperties();
                ShaderGraphProjectSettings.instance.Save();
            }
        }
예제 #6
0
    // The actual window code goes here
    void OnGUI()
    {
        if (odhCalloutBackgroundStyle == null)
        {
            odhCalloutBackgroundStyle = new GUIStyle(EditorStyles.helpBox);
            var odhCalloutBackgroundStyleTex = new Texture2D(1, 1);
            odhCalloutBackgroundStyleTex.SetPixel(0, 0, new Color(0.9f, 0.8f, 0.2f, 0.2f));
            odhCalloutBackgroundStyleTex.Apply();
            odhCalloutBackgroundStyle.normal.background = odhCalloutBackgroundStyleTex;
        }

        if (odhCalloutTextStyle == null)
        {
            odhCalloutTextStyle          = new GUIStyle(EditorStyles.label);
            odhCalloutTextStyle.richText = true;
            odhCalloutTextStyle.wordWrap = true;
        }

        // ODH Callout Section
        GUILayout.BeginHorizontal(odhCalloutBackgroundStyle);
        var     script      = MonoScript.FromScriptableObject(this);
        string  assetPath   = AssetDatabase.GetAssetPath(script);
        string  editorPath  = Path.GetDirectoryName(assetPath);
        string  odhIconPath = Path.Combine(editorPath, "Textures\\odh_icon.png");
        Texture ODHIcon     = (Texture)EditorGUIUtility.Load(odhIconPath);

        GUILayout.Box(ODHIcon, GUILayout.Width(60.0f), GUILayout.Height(60.0f));

        GUILayout.BeginVertical();

        EditorGUILayout.LabelField("<b>This tool is deprecated.</b> Oculus recommends profiling builds through the Metrics section of "
                                   + "<b>Oculus Developer Hub</b>, a desktop companion tool that streamlines the Quest development workflow.",
                                   odhCalloutTextStyle);
        GUIContent ODHLabel = new GUIContent("Download Oculus Developer Hub");

#if UNITY_2021_1_OR_NEWER
        if (EditorGUILayout.LinkButton(ODHLabel))
#else
        if (GUILayout.Button(ODHLabel, GUILayout.ExpandWidth(false)))
#endif
        {
#if UNITY_EDITOR_WIN
            Application.OpenURL("https://developer.oculus.com/downloads/package/oculus-developer-hub-win/?source=unity");
#elif UNITY_EDITOR_OSX
            Application.OpenURL("https://developer.oculus.com/downloads/package/oculus-developer-hub-mac/?source=unity");
#endif
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.Space(15.0f);

        showAndroidOptions = EditorGUILayout.Foldout(showAndroidOptions, "Android Tools");

        if (showAndroidOptions)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Android SDK root path: ", androidSdkRootPath);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Start Server"))
            {
                if (adbTool == null)
                {
                    adbTool = new OVRADBTool(androidSdkRootPath);
                }
                if (adbTool.isReady)
                {
                    int exitCode = adbTool.StartServer(null);
                    EditorUtility.DisplayDialog("ADB StartServer", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
                }
            }
            if (GUILayout.Button("Kill Server"))
            {
                if (adbTool == null)
                {
                    adbTool = new OVRADBTool(androidSdkRootPath);
                }
                if (adbTool.isReady)
                {
                    int exitCode = adbTool.KillServer(null);
                    EditorUtility.DisplayDialog("ADB KillServer", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
                }
            }
            if (GUILayout.Button("Forward Port"))
            {
                if (adbTool == null)
                {
                    adbTool = new OVRADBTool(androidSdkRootPath);
                }
                if (adbTool.isReady)
                {
                    int exitCode = adbTool.ForwardPort(remoteListeningPort, null);
                    EditorUtility.DisplayDialog("ADB ForwardPort", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
                    OVRPlugin.SendEvent("device_metrics_profiler", (exitCode == 0 ? "adb_forward_success" : "adb_forward_failure"));
                }
                else
                {
                    EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
                }
            }
            if (GUILayout.Button("Release Port"))
            {
                if (adbTool == null)
                {
                    adbTool = new OVRADBTool(androidSdkRootPath);
                }
                if (adbTool.isReady)
                {
                    int exitCode = adbTool.ReleasePort(remoteListeningPort, null);
                    EditorUtility.DisplayDialog("ADB ReleasePort", (exitCode == 0 ? "Success" : "Failure. ExitCode = " + exitCode.ToString()), "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("Can't locate ADBTool", adbTool.adbPath, "Ok");
                }
            }
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        GUILayout.BeginHorizontal();
        remoteListeningPort = EditorGUILayout.DelayedIntField("Remote Port", remoteListeningPort);

        if (tcpClient.connectionState == OVRNetwork.OVRNetworkTcpClient.ConnectionState.Disconnected)
        {
            if (GUILayout.Button("Connect"))
            {
                ConnectPerfMetricsTcpServer();
                pauseReceiveMetrics = false;
                OVRPlugin.SendEvent("device_metrics_profiler", "connect");
            }
        }
        else
        {
            if (tcpClient.connectionState == OVRNetwork.OVRNetworkTcpClient.ConnectionState.Connecting)
            {
                if (GUILayout.Button("Connecting ... Click again to Cancel"))
                {
                    DisconnectPerfMetricsTcpServer();
                    OVRPlugin.SendEvent("device_metrics_profiler", "cancel");
                }
            }
            else
            {
                if (GUILayout.Button("Disconnect"))
                {
                    DisconnectPerfMetricsTcpServer();
                    OVRPlugin.SendEvent("device_metrics_profiler", "disconnect");
                }

                if (GUILayout.Button(pauseReceiveMetrics ? "Continue" : "Pause"))
                {
                    pauseReceiveMetrics = !pauseReceiveMetrics;
                }
            }
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        lock (receivedMetricsList)
        {
            PresentIntProperty("Frame Count", "frameCount");
            PresentIntProperty("Dropped Frame Count", "compositorDroppedFrameCount");

            float?avgFrameTime = GetAveragePerfValueFloat("deltaFrameTime");
            if (avgFrameTime.HasValue)
            {
                float fps = 1.0f / avgFrameTime.Value;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("FPS", GUILayout.Width(labelWidth));
                EditorGUILayout.LabelField(string.Format("{0:F1}", fps));
                EditorGUILayout.EndHorizontal();
            }

            int?  deviceCpuClockLevel          = GetLatestPerfValueInt("deviceCpuClockLevel");
            int?  deviceGpuClockLevel          = GetLatestPerfValueInt("deviceGpuClockLevel");
            float?deviceCpuClockFrequencyInMHz = GetLatestPerfValueFloat("deviceCpuClockFrequencyInMHz");
            float?deviceGpuClockFrequencyInMHz = GetLatestPerfValueFloat("deviceGpuClockFrequencyInMHz");

            if (deviceCpuClockLevel.HasValue || deviceCpuClockFrequencyInMHz.HasValue)
            {
                string cpuLabel;
                string cpuText;
                if (deviceCpuClockLevel.HasValue && deviceCpuClockFrequencyInMHz.HasValue)
                {
                    cpuLabel = "CPU Level (Freq)";
                    cpuText  = string.Format("{0} ({1:F0} MHz)", deviceCpuClockLevel, deviceCpuClockFrequencyInMHz);
                }
                else if (deviceCpuClockLevel.HasValue)
                {
                    cpuLabel = "CPU Level";
                    cpuText  = string.Format("{0}", deviceCpuClockLevel);
                }
                else
                {
                    cpuLabel = "CPU Frequency";
                    cpuText  = string.Format("{0:F0} MHz", deviceCpuClockFrequencyInMHz);
                }
                PresentText(cpuLabel, cpuText);
            }

            if (deviceGpuClockLevel.HasValue || deviceGpuClockFrequencyInMHz.HasValue)
            {
                string cpuLabel;
                string cpuText;
                if (deviceGpuClockLevel.HasValue && deviceGpuClockFrequencyInMHz.HasValue)
                {
                    cpuLabel = "GPU Level (Freq)";
                    cpuText  = string.Format("{0} ({1:F0} MHz)", deviceGpuClockLevel, deviceGpuClockFrequencyInMHz);
                }
                else if (deviceGpuClockLevel.HasValue)
                {
                    cpuLabel = "GPU Level";
                    cpuText  = string.Format("{0}", deviceGpuClockLevel);
                }
                else
                {
                    cpuLabel = "GPU Frequency";
                    cpuText  = string.Format("{0:F0} MHz", deviceGpuClockFrequencyInMHz);
                }
                PresentText(cpuLabel, cpuText);
            }

            PresentColumnTitles("Current", "Average", "Peak");

            PresentFloatTimeInMs("Frame Time", "deltaFrameTime", 0.020f, true, true);
            PresentFloatTimeInMs("App CPU Time", "appCpuTime", 0.020f, true, true);
            PresentFloatTimeInMs("App GPU Time", "appGpuTime", 0.020f, true, true);
            PresentFloatTimeInMs("Compositor CPU Time", "compositorCpuTime", 0.020f, true, true);
            PresentFloatTimeInMs("Compositor GPU Time", "compositorGpuTime", 0.020f, true, true);
            PresentFloatPercentage("CPU Util (Average)", "systemCpuUtilAveragePercentage", false, false);
            PresentFloatPercentage("CPU Util (Worst Core)", "systemCpuUtilWorstPercentage", false, false);
            PresentFloatPercentage("GPU Util", "systemGpuUtilPercentage", false, false);
        }
    }
예제 #7
0
파일: Settings.cs 프로젝트: godjammit/GDX
            /// <summary>
            ///     Draw the packages status section of the settings window.
            /// </summary>
            public static void PackageStatus()
            {
                GUI.enabled = true;

                // ReSharper disable ConditionIsAlwaysTrueOrFalse
                EditorGUILayout.BeginHorizontal();

                // Information
                GUILayout.BeginVertical();

                GUILayout.Label(Content.AboutBlurb, Styles.WordWrappedLabelStyle);
                GUILayout.Space(10);


                GUILayout.BeginHorizontal();
                GUILayout.Label("-", Styles.BulletLayoutOptions);
#if UNITY_2021_1_OR_NEWER
                if (EditorGUILayout.LinkButton("Repository"))
#else
                if (GUILayout.Button("Repository", EditorStyles.linkLabel))
#endif
                {
                    GUIUtility.hotControl = 0;
                    Application.OpenURL("https://github.com/dotBunny/GDX/");
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("-", Styles.BulletLayoutOptions);
#if UNITY_2021_1_OR_NEWER
                if (EditorGUILayout.LinkButton("Documentation"))
#else
                if (GUILayout.Button("Documentation", EditorStyles.linkLabel))
#endif
                {
                    GUIUtility.hotControl = 0;
                    Application.OpenURL(DocumentationUri);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("-", Styles.BulletLayoutOptions);
#if UNITY_2021_1_OR_NEWER
                if (EditorGUILayout.LinkButton("Report an Issue"))
#else
                if (GUILayout.Button("Report an Issue", EditorStyles.linkLabel))
#endif
                {
                    GUIUtility.hotControl = 0;
                    Application.OpenURL("https://github.com/dotBunny/GDX/issues");
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();


                GUILayout.EndVertical();

                GUILayout.Space(15);
                GUILayout.FlexibleSpace();

                // CHeck Packages
                // ReSharper disable UnreachableCode
#pragma warning disable 162
                EditorGUILayout.BeginVertical(Styles.InfoBoxStyle);
                GUILayout.Label("Packages Found", Styles.SubSectionHeaderTextStyle);
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                // ReSharper disable once StringLiteralTypo
                GUILayout.Label("Addressables");
                GUILayout.FlexibleSpace();
                GUILayout.Label(Conditionals.HasAddressablesPackage
                    ? Content.TestPassedIcon
                    : Content.TestNormalIcon);

                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Burst");
                GUILayout.FlexibleSpace();
                GUILayout.Label(Conditionals.HasBurstPackage
                    ? Content.TestPassedIcon
                    : Content.TestNormalIcon);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Mathematics");
                GUILayout.FlexibleSpace();
                GUILayout.Label(Conditionals.HasMathematicsPackage
                    ? Content.TestPassedIcon
                    : Content.TestNormalIcon);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Platforms");
                GUILayout.FlexibleSpace();
                GUILayout.Label(Conditionals.HasPlatformsPackage
                    ? Content.TestPassedIcon
                    : Content.TestNormalIcon);
                GUILayout.EndHorizontal();

                EditorGUILayout.EndVertical();
                // ReSharper restore UnreachableCode
#pragma warning restore 162

                EditorGUILayout.EndHorizontal();

                // ReSharper enable ConditionIsAlwaysTrueOrFalse

                GUILayout.Space(5);
            }
예제 #8
0
    private void OnGUI()
    {
        this.titleContent.text = "OVR Scene Quick Preview";

        if (panelInitialized)
        {
            CheckForTransitionAPK();
            CheckForDeployedScenes();
            panelInitialized = false;
        }

        if (windowStyle == null)
        {
            windowStyle        = new GUIStyle();
            windowStyle.margin = new RectOffset(10, 10, 10, 10);
        }

        if (logBoxStyle == null)
        {
            logBoxStyle                  = new GUIStyle();
            logBoxStyle.margin.left      = 5;
            logBoxStyle.wordWrap         = true;
            logBoxStyle.normal.textColor = logBoxStyle.focused.textColor = EditorStyles.label.normal.textColor;
            logBoxStyle.richText         = true;
        }

        if (statusStyle == null)
        {
            statusStyle          = new GUIStyle(EditorStyles.label);
            statusStyle.richText = true;
        }

        EditorGUILayout.BeginVertical(windowStyle);

        GUILayout.BeginHorizontal(EditorStyles.helpBox);
        GUILayout.BeginVertical();
        EditorGUILayout.LabelField("OVR Scene Quick Preview generates a version of your app which supports hot-reloading "
                                   + "content changes to individual scenes, reducing iteration time.",
                                   EditorStyles.wordWrappedLabel);

#if UNITY_2021_1_OR_NEWER
        if (EditorGUILayout.LinkButton("Documentation"))
#else
        if (GUILayout.Button("Documentation", GUILayout.ExpandWidth(false)))
#endif
        {
            Application.OpenURL("https://developer.oculus.com/documentation/unity/unity-build-android-tools/");
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(10f);
        GUIContent transitionContent = new GUIContent("Modified APK [?]",
                                                      "Build and deploy an APK that can hot-reload scenes. This enables fast iteration on content changes to scenes.");
        GUILayout.Label(transitionContent, EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Status: ", statusStyle, GUILayout.ExpandWidth(false));

            string statusMesssage;
            switch (currentApkStatus)
            {
            case ApkStatus.OK:
                statusMesssage = "<color=green>APK installed. Ready to build and deploy scenes.</color>";
                break;

            case ApkStatus.NOT_INSTALLED:
                statusMesssage = "<color=red>APK not installed. Press \"Build and Deploy APK\" to install the modified APK.</color>";
                break;

            case ApkStatus.DEVICE_NOT_CONNECTED:
                statusMesssage = "<color=red>Device not connected via ADB. Please connect device and allow debugging.</color>";
                break;

            case ApkStatus.UNKNOWN:
            default:
                statusMesssage = "<color=red>Failed to get APK status!</color>";
                break;
            }
            GUILayout.Label(statusMesssage, statusStyle, GUILayout.ExpandWidth(true));
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Build and Deploy APK", GUILayout.Width(200)))
        {
            action = GuiAction.BuildAndDeployApp;
        }
        EditorGUI.BeginDisabledGroup(currentApkStatus != ApkStatus.OK);
        if (GUILayout.Button("Launch APK", GUILayout.Width(120)))
        {
            action = GuiAction.LaunchApp;
        }
        EditorGUI.EndDisabledGroup();
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(10f);

        GUIContent scenesContent = new GUIContent("Scenes [?]",
                                                  "Build and deploy individual scenes, which can be hot-reloaded at runtime by the modified APK.");
        GUILayout.Label(scenesContent, EditorStyles.boldLabel);

        GUIContent buildSettingsBtnTxt = new GUIContent("Open Build Settings");
        GUIContent deployLabelTxt      = new GUIContent("Deploy?",
                                                        "If true, this scene will be hot-reloaded. To reduce iteration time, only deploy scenes under active iteration.");
        if (buildableScenes == null || buildableScenes.Count == 0)
        {
            string sceneErrorMessage;
            if (invalidBuildableScene)
            {
                sceneErrorMessage = "Invalid scene selection. \nPlease remove OVRTransitionScene in the project's build settings.";
            }
            else
            {
                sceneErrorMessage = "No scenes detected. \nTo get started, add scenes in the project's build settings.";
            }
            GUILayout.Label(sceneErrorMessage);

            var buildSettingBtnRt = GUILayoutUtility.GetRect(buildSettingsBtnTxt, GUI.skin.button, GUILayout.Width(150));
            if (GUI.Button(buildSettingBtnRt, buildSettingsBtnTxt))
            {
                action = GuiAction.OpenBuildSettingsWindow;
            }
        }
        else
        {
            float currWidth      = EditorGUIUtility.currentViewWidth;
            float sceneNameWidth = Math.Max(EditorGUIUtility.currentViewWidth - 170, 60);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Scene Name", GUI.skin.box, GUILayout.Width(sceneNameWidth));
            EditorGUILayout.LabelField("Status", GUI.skin.box, GUILayout.Width(80));
            EditorGUILayout.LabelField(deployLabelTxt, GUI.skin.box, GUILayout.Width(60));
            EditorGUILayout.EndHorizontal();

            foreach (EditorSceneInfo scene in buildableScenes)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(scene.sceneName, GUILayout.Width(sceneNameWidth + 8));
                EditorGUILayout.LabelField(GetEnumDescription(scene.buildStatus), GUILayout.Width(80));
                scene.shouldDeploy = EditorGUILayout.Toggle(scene.shouldDeploy, GUILayout.Width(50));
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Build and Deploy Scene(s)", GUILayout.Width(200)))
                {
                    action = GuiAction.BuildAndDeployScenes;
                }
                GUILayout.Space(10);
                GUIContent forceRestartLabel = new GUIContent("Force Restart [?]", "Relaunch the application after scene bundles are finished deploying.");
                forceRestart = GUILayout.Toggle(forceRestart, forceRestartLabel, GUILayout.ExpandWidth(true));
            }
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.Space(10.0f);
        GUILayout.Label("Utilities", EditorStyles.boldLabel);

        showBundleManagement = EditorGUILayout.BeginFoldoutHeaderGroup(showBundleManagement, "Bundle Management", EditorStyles.foldoutHeader);
        if (showBundleManagement)
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.Space(EditorGUI.indentLevel * spacesPerIndent, false);                 //to match indentLevel
                GUIContent clearDeviceBundlesTxt = new GUIContent("Delete Device Bundles [?]",
                                                                  "Asset bundles to support hot-reloading are stored in an external location on-device. Click to delete them, freeing up space on-device.");
                if (GUILayout.Button(clearDeviceBundlesTxt, GUILayout.ExpandWidth(true)))
                {
                    action = GuiAction.ClearDeviceBundles;
                }

                GUIContent clearLocalBundlesTxt = new GUIContent("Delete Local Bundles [?]",
                                                                 $"Locally, asset bundles are built into the \"{OVRBundleManager.BUNDLE_MANAGER_OUTPUT_PATH}\" folder at project root. "
                                                                 + "Click to delete them, freeing up local space.");
                if (GUILayout.Button(clearLocalBundlesTxt, GUILayout.ExpandWidth(true)))
                {
                    action = GuiAction.ClearLocalBundles;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndFoldoutHeaderGroup();

        GUILayout.Space(5.0f);
        showOther = EditorGUILayout.BeginFoldoutHeaderGroup(showOther, "Other", EditorStyles.foldoutHeader);
        if (showOther)
        {
            const float otherLabelsWidth = 240f;
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();

            GUIContent deployScenesWithApkLabel = new GUIContent("Deploy scenes with APK deploy [?]",
                                                                 "If checked, all scenes will be built & deployed when pressing \"Build and Deploy APK\". This takes longer, but provides more expected behavior.");

            EditorGUILayout.LabelField(deployScenesWithApkLabel, GUILayout.Width(otherLabelsWidth));
            bool newToggleValue = EditorGUILayout.Toggle(deployScenesWhenDeployingApk);

            if (newToggleValue != deployScenesWhenDeployingApk)
            {
                deployScenesWhenDeployingApk = newToggleValue;
                EditorPrefs.SetBool(deployScenesWhenDeployingApkPrefName, deployScenesWhenDeployingApk);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUIContent useOptionalTransitionPackageLabel = new GUIContent("Use optional APK package name [?]",
                                                                          "This allows both full build APK and transition APK to be installed on device. However, platform services like Entitlement check may fail.");

            EditorGUILayout.LabelField(useOptionalTransitionPackageLabel, GUILayout.Width(otherLabelsWidth));
            newToggleValue = EditorGUILayout.Toggle(useOptionalTransitionApkPackage);

            if (newToggleValue != useOptionalTransitionApkPackage)
            {
                useOptionalTransitionApkPackage = newToggleValue;
                EditorPrefs.SetBool(useOptionalTransitionApkPackagePrefName, useOptionalTransitionApkPackage);
                // New package name = new check for associated data
                CheckForTransitionAPK();
                CheckForDeployedScenes();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space(EditorGUI.indentLevel * spacesPerIndent, false);             //to match indentLevel
            if (GUILayout.Button(buildSettingsBtnTxt, GUILayout.ExpandWidth(true)))
            {
                action = GuiAction.OpenBuildSettingsWindow;
            }
            if (GUILayout.Button("Uninstall APK", GUILayout.ExpandWidth(true)))
            {
                action = GuiAction.UninstallApk;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndFoldoutHeaderGroup();

        GUILayout.Space(6f);
        GUILayout.Label("", GUI.skin.horizontalSlider);
        GUILayout.Space(10f);

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Log", EditorStyles.boldLabel);
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Clear Log", EditorStyles.miniButton))
        {
            action = GuiAction.ClearLog;
        }
        EditorGUILayout.EndHorizontal();

        debugLogScroll = EditorGUILayout.BeginScrollView(debugLogScroll, EditorStyles.helpBox, GUILayout.ExpandHeight(true));
        if (!string.IsNullOrEmpty(toolLog))
        {
            EditorGUILayout.SelectableLabel(toolLog, logBoxStyle, GUILayout.Height(logBoxSize.y));
        }
        EditorGUILayout.EndScrollView();

        EditorGUILayout.EndVertical();
    }
예제 #9
0
        public void OnGUI()
        {
            using (var currentStateNameSlip = Neo.Utility.DataStructureLibrary <List <string> > .Instance.CheckOut())
                using (var previousStateNameSlip = Neo.Utility.DataStructureLibrary <List <string> > .Instance.CheckOut())
                {
                    currentStateNameSlip.Value.Clear();
                    previousStateNameSlip.Value.Clear();

                    if (Selection.activeGameObject == null)
                    {
                        EditorGUILayout.LabelField("Select a state machine game object");
                    }
                    else if (MonitoredStateMachine == null)
                    {
                        var monitor = Selection.activeGameObject.GetComponent <Wrappers.InspectorStateMachine>();
                        if (monitor != null)
                        {
                            MonitoredStateMachine = monitor;
                        }
                        else
                        {
                            EditorGUILayout.LabelField("Select a state machine game object");
                        }
                    }

                    EditorGUILayout.LabelField("Selected State Machine", EditorStyles.boldLabel);

                    if (MonitoredStateMachine != null)
                    {
                        if (MonitoredStateMachine.CurrentState != null)
                        {
                            MonitoredStateMachine.CurrentState.gameObject.BuildFullName(currentStateNameSlip);
                        }

                        if (MonitoredStateMachine.PreviousState != null)
                        {
                            MonitoredStateMachine.PreviousState.gameObject.BuildFullName(previousStateNameSlip);
                        }

                        if (EditorGUILayout.LinkButton(m_MonitoredStateMachineName))
                        {
                            GameObject stateGO = GameObject.Find(m_MonitoredStateMachineName);
                            Selection.activeGameObject = stateGO;
                        }
                    }

                    EditorGUILayout.Space();

                    using (var nameBuilderSlip = Neo.Utility.DataStructureLibrary <System.Text.StringBuilder> .Instance.CheckOut())
                        using (var tabBuilderSlip = Neo.Utility.DataStructureLibrary <System.Text.StringBuilder> .Instance.CheckOut()) {
                            EditorGUILayout.LabelField("Current State:", EditorStyles.boldLabel);
                            nameBuilderSlip.Value.Clear();
                            tabBuilderSlip.Value.Clear();

                            int indention = 0;
                            foreach (var subName in currentStateNameSlip.Value)
                            {
                                EditorGUILayout.BeginHorizontal();

                                nameBuilderSlip.Value.Append(string.Format("/{0}", subName));

                                EditorGUILayout.LabelField(tabBuilderSlip.Value.ToString(), GUILayout.MaxWidth(20 * indention));

                                if (EditorGUILayout.LinkButton(subName))
                                {
                                    GameObject stateGO = GameObject.Find(nameBuilderSlip.Value.ToString());
                                    Selection.activeGameObject = stateGO;
                                }
                                indention += 1;
                                tabBuilderSlip.Value.Append("     ");

                                EditorGUILayout.EndHorizontal();
                            }

                            EditorGUILayout.Space();

                            EditorGUILayout.LabelField("Previous State:", EditorStyles.boldLabel);
                            nameBuilderSlip.Value.Clear();
                            tabBuilderSlip.Value.Clear();

                            indention = 0;
                            foreach (var subName in previousStateNameSlip.Value)
                            {
                                EditorGUILayout.BeginHorizontal();

                                nameBuilderSlip.Value.Append(string.Format("/{0}", subName));

                                EditorGUILayout.LabelField(tabBuilderSlip.Value.ToString(), GUILayout.MaxWidth(indention));
                                if (EditorGUILayout.LinkButton(subName))
                                {
                                    GameObject stateGO = GameObject.Find(nameBuilderSlip.Value.ToString());
                                    Selection.activeGameObject = stateGO;
                                }
                                indention += 20;
                                tabBuilderSlip.Value.Append("     ");

                                EditorGUILayout.EndHorizontal();
                            }
                        }
                }
        }
예제 #10
0
    private void OnGUI()
    {
        if (windowStyle == null)
        {
            windowStyle        = new GUIStyle();
            windowStyle.margin = new RectOffset(10, 10, 10, 10);
        }

        if (calloutStyle == null)
        {
            calloutStyle          = new GUIStyle(EditorStyles.label);
            calloutStyle.richText = true;
            calloutStyle.wordWrap = true;
        }

        // Fix progress bar window size
        minSize = new Vector2(500, 305);

        float oldLabelWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 160;

        EditorGUILayout.BeginVertical(windowStyle);

        GUILayout.BeginHorizontal(EditorStyles.helpBox);
        GUILayout.BeginVertical();
        EditorGUILayout.LabelField("Builds created in the <b>OVR Build APK</b> window are identical to Unity-built APKs, but use the Gradle cache to only touch changed files, resulting in shorter build times.",
                                   calloutStyle);

#if UNITY_2021_1_OR_NEWER
        if (EditorGUILayout.LinkButton("Documentation"))
#else
        if (GUILayout.Button("Documentation", GUILayout.ExpandWidth(false)))
#endif
        {
            Application.OpenURL("https://developer.oculus.com/documentation/unity/unity-build-android-tools/");
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space(15f);

        scrollViewPos = EditorGUILayout.BeginScrollView(scrollViewPos, GUIStyle.none, GUI.skin.verticalScrollbar);
        using (new EditorGUI.DisabledScope(buildInProgress))
        {
            EditorGUILayout.BeginHorizontal();
            outputApkPath = EditorGUILayout.TextField("Built APK Path", outputApkPath);
            if (GUILayout.Button("Browse...", GUILayout.Width(80)))
            {
                DisplayAPKPathDialog();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            PlayerSettings.Android.bundleVersionCode = EditorGUILayout.IntField(new GUIContent("Version Number",
                                                                                               "Builds uploaded to the Oculus storefront are required to have incrementing version numbers.\nThis value is exposed to players."),
                                                                                PlayerSettings.Android.bundleVersionCode, GUILayout.Width(220));

            EditorGUI.BeginChangeCheck();
            bool isAutoIncrement = PlayerPrefs.GetInt(OVRGradleGeneration.prefName, 0) != 0;
            isAutoIncrement = EditorGUILayout.ToggleLeft(new GUIContent("Auto-Increment?",
                                                                        "If true, version number will be automatically incremented after every successful build."),
                                                         isAutoIncrement, EditorStyles.miniLabel, GUILayout.Width(120));
            if (EditorGUI.EndChangeCheck())
            {
                OVRGradleGeneration.ToggleUtilities();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space(15f);

            EditorGUILayout.BeginHorizontal();
            using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(currConnectedDevice)))
            {
                isRunOnDevice = EditorGUILayout.Toggle("Install & Run on Device?", isRunOnDevice);
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField(string.IsNullOrEmpty(currConnectedDevice) ? "No device connected" : $"Device: {currConnectedDevice}");
            }
            if (GUILayout.Button("Refresh", GUILayout.Width(80)))
            {
                CheckADBDevices(out currConnectedDevice);
            }
            EditorGUILayout.EndHorizontal();

            EditorUserBuildSettings.development = EditorGUILayout.Toggle(new GUIContent("Development Build?",
                                                                                        "Development builds allow you to debug scripts. However, they're slightly slower, and they're not allowed on the Oculus storefront."),
                                                                         EditorUserBuildSettings.development);

            EditorGUILayout.Space(15f);

            EditorGUILayout.BeginHorizontal();
            saveKeystorePasswords = EditorGUILayout.Toggle(new GUIContent("Save Keystore Passwords?",
                                                                          "These values are also found in Project Settings > Player > [Android] > Publishing Settings > Project Keystore.\nStoring passwords is convenient, but reduces security."),
                                                           saveKeystorePasswords);
            if (GUILayout.Button("Select Keystore...", GUILayout.Width(150)))
            {
                SettingsService.OpenProjectSettings("Project/Player");
            }
            EditorGUILayout.EndHorizontal();

            if (saveKeystorePasswords)
            {
                EditorGUI.indentLevel++;

                EditorGUILayout.LabelField("Keystore Path", PlayerSettings.Android.keystoreName);
                PlayerSettings.Android.keystorePass = EditorGUILayout.PasswordField("Keystore Password", PlayerSettings.Android.keystorePass);

                EditorGUILayout.LabelField("Key Alias Name", PlayerSettings.Android.keyaliasName);
                PlayerSettings.Android.keyaliasPass = EditorGUILayout.PasswordField("Alias Password", PlayerSettings.Android.keyaliasPass);

                EditorGUI.indentLevel--;
            }
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        //better to perform these at end of GUI
        bool shouldCancel = false;
        bool shouldBuild  = false;
        if (showCancel)
        {
            shouldCancel = GUILayout.Button("Cancel", GUILayout.Height(30), GUILayout.Width(100));
        }
        else
        {
            using (new EditorGUI.DisabledScope(buildInProgress))
            {
                shouldBuild = GUILayout.Button("Build", GUILayout.Height(30), GUILayout.Width(100));
            }
        }
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space(10);

        // Show progress bar
        Rect  progressRect = EditorGUILayout.GetControlRect(GUILayout.Height(25));
        float progress     = currentStep / (float)totalBuildSteps;
        EditorGUI.ProgressBar(progressRect, progress, progressMessage);

        EditorGUIUtility.labelWidth = oldLabelWidth;
        EditorGUILayout.EndVertical();

        if (shouldBuild)
        {
            StartBuild();
        }
        else if (shouldCancel)
        {
            CancelBuild();
        }
    }