static void Init()
            {
                PreviewWindow.LoadSettings();
                window         = EditorWindow.GetWindow(typeof(PreviewWindowEditor));
                window.maxSize = new Vector2(320, 380);
                window.minSize = window.maxSize;

                if (window != null)
                {
                    window.Show();
                }
            }
Beispiel #2
0
        static void Init()
        {
            PreviewWindow.LoadSettings();
            window          = EditorWindow.GetWindow(typeof(PreviewWindowEditor));
            window.minSize  = new Vector2(400, 450);
            window.maxSize  = window.minSize * 2;
            selectedDisplay = 0;

            if (window != null)
            {
                window.Show();
            }
        }
Beispiel #3
0
        void OnGUI()
        {
            // load the settings if none are there
            if (PreviewWindow.previewWindowSettings == null)
            {
                PreviewWindow.LoadSettings();
            }

            GUILayout.Label("Selected Display: ");
            selectedDisplay = EditorGUILayout.Popup(selectedDisplay, displayNames);

            // making life a little easier
            GameWindowSettings[] settings = PreviewWindow.previewWindowSettings.gameWindowSettings;
            int i = selectedDisplay;

            // check if the display is activated
            settings[i].enabled = EditorGUILayout.Toggle(settings[i].enabled);

            // if it's not activated, gray out the options for this display
            GUI.enabled = settings[i].enabled;

            settings[i].position = EditorGUILayout.Vector2Field("Position", settings[i].position);
            EditorGUILayout.Space();

            GUILayout.Label("Presets: ");
            GUILayout.Label("Sets the position of the display window " +
                            "in relation to the previous display window",
                            EditorStyles.miniLabel);
            var width = GUILayout.Width(80);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool top = GUILayout.Button("Top", EditorStyles.miniButton, width);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool left = GUILayout.Button("Left", EditorStyles.miniButton, width);

            GUILayout.Space(80);
            bool right = GUILayout.Button("Right", EditorStyles.miniButton, width);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool bottom = GUILayout.Button("Bottom", EditorStyles.miniButton, width);

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

            // preset buttons
            // arranges based on the previous enabled display
            Rect previousDisplay = new Rect(0, 0, Screen.currentResolution.width, Screen.currentResolution.height);

            for (int j = i - 1; j >= 0; j--)
            {
                if (settings[j].enabled)
                {
                    previousDisplay.position = settings[j].position;
                    previousDisplay.size     = new Vector2(
                        Calibration.Main.screenW,
                        Calibration.Main.screenH
                        );
                    break;
                }
            }

            if (top)
            {
                settings[i].position = new Vector2(
                    previousDisplay.x,
                    -Calibration.Main.screenH + previousDisplay.y);
                EditorGUI.FocusTextInControl("");
                PreviewWindow.SaveSettings();
            }

            if (left)
            {
                settings[i].position = new Vector2(
                    -Calibration.Main.screenW + previousDisplay.x,
                    previousDisplay.y);
                EditorGUI.FocusTextInControl("");
                PreviewWindow.SaveSettings();
            }

            if (right)
            {
                settings[i].position = new Vector2(
                    previousDisplay.width + previousDisplay.x,
                    previousDisplay.y);
                EditorGUI.FocusTextInControl("");
                PreviewWindow.SaveSettings();
            }

            if (bottom)
            {
                settings[i].position = new Vector2(
                    previousDisplay.x,
                    previousDisplay.height + previousDisplay.y);
                EditorGUI.FocusTextInControl("");
                PreviewWindow.SaveSettings();
            }

            EditorGUILayout.Space();

            // re-enable gui
            GUI.enabled = true;

            if (GUILayout.Button("Toggle Preview"))
            {
                PreviewWindow.SaveSettings();
                PreviewWindow.ToggleWindow();
                // EditorApplication.ExecuteMenuItem("HoloPlay/Toggle Preview");
            }

            EditorGUILayout.HelpBox("Toggle the previewer to affect changes", MessageType.Info);

            EditorGUILayout.HelpBox
            (
                "Note: keeping your HoloPlay Preview Window to the left is recommended. " +
                "If you are using it to the right of your main display, you may need to " +
                "adjust the x position manually, as OS zoom can sometimes cause the positioning to fail.",
                MessageType.Warning
            );

            // experimental
            if (Calibration.Main != null)
            {
                // positioning visual
                EditorGUILayout.LabelField("Positioning:");
                Rect position = EditorGUILayout.BeginVertical();
                position.y += 30;     // a little padding
                float factor = 0.03f; // how much smaller this prop screen is

                // main display visual
                Rect mainDisplay = position;
                mainDisplay.width  = Screen.currentResolution.width * factor;
                mainDisplay.height = Screen.currentResolution.height * factor;
                mainDisplay.x     += position.width * 0.5f - mainDisplay.width * 0.5f;

                GUI.color = EditorGUIUtility.isProSkin ? Color.white : Color.black;
                GUI.DrawTexture(mainDisplay, displayFull);
                Rect mainDisplayLabel = mainDisplay;
                mainDisplayLabel.x += 4;
                mainDisplayLabel.y += 2;
                GUI.Label(mainDisplayLabel, "Main\nDisplay", EditorStyles.whiteMiniLabel);

                // extra display visuals
                int displayIndex = -1;
                foreach (var setting in settings)
                {
                    // advance display index
                    displayIndex++;

                    // disregard if it's disabled
                    if (!setting.enabled)
                    {
                        continue;
                    }

                    Rect lkgDisplay = position;
                    lkgDisplay.width  = Calibration.Main.screenW * factor;
                    lkgDisplay.height = Calibration.Main.screenH * factor;
                    lkgDisplay.x      = mainDisplay.x + setting.position.x * factor;
                    lkgDisplay.y      = mainDisplay.y + setting.position.y * factor;

                    GUI.color = Misc.guiColor;
                    GUI.DrawTexture(lkgDisplay, displayFull);
                    lkgDisplay.x += 4;
                    lkgDisplay.y += 2;
                    GUI.Label(lkgDisplay, "Display " + (displayIndex + 1), EditorStyles.whiteMiniLabel);
                }



                EditorGUILayout.EndVertical();
            }
        }