Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
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();
            }
        }