예제 #1
0
            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();
                }
            }
예제 #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();
            }
        }
예제 #3
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();
                Quilt quilt = (Quilt)target;

                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Quilt -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                GUI.enabled = false;
                EditorGUILayout.PropertyField(quiltRT);
                GUI.enabled = true;

                advancedFoldout.boolValue = EditorGUILayout.Foldout(
                    advancedFoldout.boolValue,
                    "Advanced",
                    true
                    );
                if (advancedFoldout.boolValue)
                {
                    EditorGUI.indentLevel++;

                    EditorGUILayout.PropertyField(captures, true);
                    EditorGUILayout.PropertyField(overrideQuilt);
                    // EditorGUILayout.PropertyField(overrideViews, true);
                    EditorGUILayout.PropertyField(renderOverrideBehind);
                    EditorGUILayout.PropertyField(debugPrintoutKey);
                    EditorGUILayout.PropertyField(screenshot2DKey);
                    EditorGUILayout.PropertyField(screenshot3DKey);
                    EditorGUILayout.PropertyField(forceConfigResolution);

                    List <string> tilingPresetNames = new List <string>();
                    foreach (var p in Quilt.tilingPresets)
                    {
                        tilingPresetNames.Add(p.presetName);
                    }
                    tilingPresetNames.Add("Default (determined by quality setting)");
                    tilingPresetNames.Add("Custom");

                    EditorGUI.BeginChangeCheck();
                    tilingPresetIndex.intValue = EditorGUILayout.Popup(
                        "Tiling",
                        tilingPresetIndex.intValue,
                        tilingPresetNames.ToArray()
                        );
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }

                    // if it's a custom
                    int custom = Quilt.tilingPresets.Length + 1;
                    if (tilingPresetIndex.intValue == custom)
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PropertyField(tilesX);
                        EditorGUILayout.PropertyField(tilesY);
                        EditorGUILayout.PropertyField(quiltW);
                        EditorGUILayout.PropertyField(quiltH);
                        if (EditorGUI.EndChangeCheck())
                        {
                            quilt.ApplyPreset();
                        }
                    }

                    string tilingDisplay = numViews.displayName + ": " + numViews.intValue.ToString() + "\n";
                    tilingDisplay += "Tiles: " + tilesX.intValue + " x " + tilesY.intValue.ToString() + "\n";
                    tilingDisplay += "Quilt Size: " + quiltW.intValue.ToString() + " x " +
                                     quiltH.intValue.ToString() + " px" + "\n";
                    tilingDisplay += "Tile Size: " + tileSizeX.intValue.ToString() + " x " +
                                     tileSizeY.intValue.ToString() + " px";

                    EditorGUILayout.LabelField(tilingDisplay, EditorStyles.helpBox);

                    // on quilt setup event
                    EditorGUILayout.PropertyField(onQuiltSetup);

                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Preview -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                EditorGUILayout.PropertyField(renderIn2D);

                string previewerShortcutKey = "Ctrl + E";
                string settingsShortcutKey  = "Ctrl + Shift + E";

#if UNITY_EDITOR_OSX
                previewerShortcutKey = "⌘E";
                settingsShortcutKey  = "⌘^E";
#endif

                if (GUILayout.Button(new GUIContent(
                                         "Toggle Preview (" + previewerShortcutKey + ")",
                                         "If your LKG device is set up as a second display, " +
                                         "this will generate a game window on it to use as a " +
                                         "realtime preview"),
                                     EditorStyles.miniButton
                                     ))
                {
                    PreviewWindow.ToggleWindow();
                }

                if (GUILayout.Button(new GUIContent(
                                         "Settings (" + settingsShortcutKey + ")",
                                         "Use to set previewer position"),
                                     EditorStyles.miniButton
                                     ))
                {
                    EditorApplication.ExecuteMenuItem("HoloPlay/Preview Settings");
                }

                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Config -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

#if CALIBRATOR
                EditorGUILayout.PropertyField(config, true);
#endif

                if (GUILayout.Button(new GUIContent(
                                         "Reload Config",
                                         "Reload the config, only really necessary if " +
                                         "you edited externally and the new config settings won't load"),
                                     EditorStyles.miniButton
                                     ))
                {
                    quilt.LoadConfig();
                }

                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Project Settings -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                if (GUILayout.Button(new GUIContent(
                                         "Optimization Settings",
                                         "Open a window that will let you select project settings " +
                                         "to be optimized for best performance with HoloPlay"),
                                     EditorStyles.miniButton
                                     ))
                {
                    OptimizationSettings window = EditorWindow.GetWindow <OptimizationSettings>();
                    window.Show();
                }

                EditorGUILayout.Space();

                serializedObject.ApplyModifiedProperties();
            }
예제 #4
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();
            }
        }
예제 #5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Quilt quilt = (Quilt)target;

            EditorGUILayout.Space();

            GUI.color = Misc.guiColor;
            EditorGUILayout.LabelField("- Quilt -", EditorStyles.whiteMiniLabel);
            GUI.color = Color.white;

            GUI.enabled = false;
            EditorGUILayout.PropertyField(quiltRT);
            GUI.enabled = true;

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Take 2D Screenshot", EditorStyles.miniButton))
            {
                quilt.Screenshot2D();
            }
            if (GUILayout.Button("Take 3D Screenshot", EditorStyles.miniButton))
            {
                quilt.Screenshot3D();
            }
            EditorGUILayout.EndHorizontal();

            advancedFoldout.boolValue = EditorGUILayout.Foldout(
                advancedFoldout.boolValue,
                "Advanced",
                true
                );
            if (advancedFoldout.boolValue)
            {
                EditorGUI.indentLevel++;

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Captures -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                EditorGUILayout.PropertyField(captures, true);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Add Capture", EditorStyles.miniButton))
                {
                    AddCapture(quilt);
                    EditorUtility.SetDirty(quilt);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUI.BeginChangeCheck();
                if (GUILayout.Button("Remove Capture", EditorStyles.miniButton))
                {
                    RemoveCapture(quilt);
                    EditorUtility.SetDirty(quilt);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Quilt Settings -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                EditorGUILayout.PropertyField(overrideQuilt);
                // EditorGUILayout.PropertyField(overrideViews, true);
                EditorGUILayout.PropertyField(renderOverrideBehind);
                EditorGUILayout.PropertyField(debugPrintoutKey);
                EditorGUILayout.PropertyField(screenshot2DKey);
                EditorGUILayout.PropertyField(screenshot3DKey);

                EditorGUILayout.PropertyField(forceResolution);

                List <string> tilingPresetNames = new List <string>();
                foreach (var p in System.Enum.GetValues(typeof(Quilt.QuiltPreset)))
                {
                    tilingPresetNames.Add(p.ToString());
                }
                tilingPresetNames.Add("Default (determined by quality setting)");
                tilingPresetNames.Add("Custom");

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(currentQuiltPreset);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                // if it's a custom
                if (currentQuiltPreset.intValue == (int)Quilt.QuiltPreset.Custom)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(viewWidth);
                    EditorGUILayout.PropertyField(viewHeight);
                    EditorGUILayout.PropertyField(numViews);
                    if (EditorGUI.EndChangeCheck())
                    {
                        quilt.ApplyPreset();
                        EditorUtility.SetDirty(quilt);
                    }
                }

                string tilingDisplay = numViews.displayName + ": " + numViews.intValue.ToString() + "\n";

                tilingDisplay += "View Tiling: " + viewsHorizontal.intValue + " x " +
                                 viewsVertical.intValue.ToString() + "\n";

                tilingDisplay += "View Size: " + viewWidth.intValue.ToString() + " x " +
                                 viewHeight.intValue.ToString() + " px" + "\n";

                tilingDisplay += "Quilt Size: " + quiltWidth.intValue.ToString() + " x " +
                                 quiltHeight.intValue.ToString() + " px";

                EditorGUILayout.LabelField(tilingDisplay, EditorStyles.helpBox);
                EditorGUILayout.Space();

                GUI.color = Misc.guiColor;
                EditorGUILayout.LabelField("- Multi Display -", EditorStyles.whiteMiniLabel);
                GUI.color = Color.white;

                EditorGUILayout.PropertyField(calibrationIndex);

                // change display if displayIndex changes
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(displayIndex);
                if (EditorGUI.EndChangeCheck())
                {
                    quilt.QuiltCam.targetDisplay = displayIndex.intValue;
                }

                EditorGUILayout.PropertyField(multiDisplayKey);
                EditorGUILayout.HelpBox(
                    "Display Index 0 = Display 1.\n" +
                    "Unity names it Display 1 but the array is 0 indexed.\n\n" +
                    "Keep in mind that the main display is usually Display 1, and the plugged in Looking Glass is likely Display 2.\n\n" +
                    "In most cases, you will want to leave this at 0 and set the display in the Launch window, but " +
                    "if you're using Multi Display you can set this manually for multiple Looking Glasses.",
                    MessageType.None);

                // on quilt setup event
                EditorGUILayout.PropertyField(onQuiltSetup);

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            GUI.color = Misc.guiColor;
            EditorGUILayout.LabelField("- Preview -", EditorStyles.whiteMiniLabel);
            GUI.color = Color.white;

            EditorGUILayout.PropertyField(renderIn2D);

            string previewerShortcutKey = "Ctrl + E";
            string settingsShortcutKey  = "Ctrl + Shift + E";

#if UNITY_EDITOR_OSX
            previewerShortcutKey = "⌘E";
            settingsShortcutKey  = "⌘^E";
#endif

            if (GUILayout.Button(new GUIContent(
                                     "Toggle Preview (" + previewerShortcutKey + ")",
                                     "If your LKG device is set up as a second display, " +
                                     "this will generate a game window on it to use as a " +
                                     "realtime preview"),
                                 EditorStyles.miniButton
                                 ))
            {
                PreviewWindow.ToggleWindow();
            }

            if (GUILayout.Button(new GUIContent(
                                     "Settings (" + settingsShortcutKey + ")",
                                     "Use to set previewer position"),
                                 EditorStyles.miniButton
                                 ))
            {
                EditorApplication.ExecuteMenuItem("HoloPlay/Preview Settings");
            }

            EditorGUILayout.Space();

            GUI.color = Misc.guiColor;
            EditorGUILayout.LabelField("- Calibration -", EditorStyles.whiteMiniLabel);
            GUI.color = Color.white;

            if (GUILayout.Button(new GUIContent(
                                     "Reload Calibration",
                                     "Reload the calibration, only really necessary if " +
                                     "you edited externally and the new calibration settings won't load"),
                                 EditorStyles.miniButton
                                 ))
            {
                CalibrationManager.LoadCalibrations();
                EditorUtility.SetDirty(quilt);
            }

            EditorGUILayout.Space();

            GUI.color = Misc.guiColor;
            EditorGUILayout.LabelField("- Project Settings -", EditorStyles.whiteMiniLabel);
            GUI.color = Color.white;

            if (GUILayout.Button(new GUIContent(
                                     "Optimization Settings",
                                     "Open a window that will let you select project settings " +
                                     "to be optimized for best performance with HoloPlay"),
                                 EditorStyles.miniButton
                                 ))
            {
                OptimizationSettings window = EditorWindow.GetWindow <OptimizationSettings>();
                window.Show();
            }

            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();
        }
예제 #6
0
            void OnGUI()
            {
                PreviewWindow.position = EditorGUILayout.Vector2Field("Position", PreviewWindow.position);
                EditorGUILayout.Space();

                GUILayout.Label("Presets: ");
                GUILayout.BeginHorizontal();
                bool left  = GUILayout.Button("Left", EditorStyles.miniButton);
                bool right = GUILayout.Button("Right", EditorStyles.miniButton);

                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                bool lowerLeft  = GUILayout.Button("Lower Left", EditorStyles.miniButton);
                bool lowerRight = GUILayout.Button("Lower Right", EditorStyles.miniButton);

                GUILayout.EndHorizontal();

                if (left)
                {
                    PreviewWindow.position = new Vector2(-Config.Instance.screenW, 0);
                    EditorGUI.FocusTextInControl("");
                    PreviewWindow.SaveSettings();
                }

                if (right)
                {
                    PreviewWindow.position = new Vector2(Screen.currentResolution.width, 0);
                    EditorGUI.FocusTextInControl("");
                    PreviewWindow.SaveSettings();
                }

                if (lowerLeft)
                {
                    PreviewWindow.position = new Vector2(-Config.Instance.screenW, Screen.currentResolution.height - Config.Instance.screenH);
                    EditorGUI.FocusTextInControl("");
                    PreviewWindow.SaveSettings();
                }

                if (lowerRight)
                {
                    PreviewWindow.position = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height - Config.Instance.screenH);
                    EditorGUI.FocusTextInControl("");
                    PreviewWindow.SaveSettings();
                }

                // GUILayout.FlexibleSpace();

                EditorGUILayout.Space();

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

                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 (Config.Instance != null)
                {
                    EditorGUILayout.LabelField("Positioning:");
                    Rect position = EditorGUILayout.BeginVertical();
                    position.y += 30;      // a little padding
                    float factor = 0.033f; // how much smaller this prop screen is

                    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;
                    // mainDisplay.x = Mathf.FloorToInt(mainDisplay.x);
                    // mainDisplay.y = Mathf.FloorToInt(mainDisplay.y);

                    Rect lkgDisplay = position;
                    lkgDisplay.width  = Config.Instance.screenW * factor;
                    lkgDisplay.height = Config.Instance.screenH * factor;
                    lkgDisplay.x      = mainDisplay.x + PreviewWindow.position.x * factor;
                    lkgDisplay.y      = mainDisplay.y + PreviewWindow.position.y * factor;

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

                    GUI.color = Misc.guiColor;
                    GUI.DrawTexture(lkgDisplay, displayFull);
                    lkgDisplay.x += 4;
                    lkgDisplay.y += 2;
                    GUI.Label(lkgDisplay, "HoloPlay\ndisplay", EditorStyles.whiteMiniLabel);

                    EditorGUILayout.EndVertical();
                }
            }