Как я могу изменить размер EditorWindow до высоты 20? - PullRequest
0 голосов
/ 24 сентября 2018
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor.IMGUI.Controls;
using UnityEditor.SceneManagement;


    public class Prefab : EditorWindow
    {
        private bool stop;
        private bool minimizeToZero;
        private static Prefab editor;
        private static int width = 300;
        private static int height = 100;
        private static int x = 0;
        private static int y = 0;

        [MenuItem("Window/Test")]
        static void ShowEditor()
        {


            x = (Screen.currentResolution.width - width) / 2;
            y = (Screen.currentResolution.height - height) / 2;

            editor = EditorWindow.GetWindow<Prefab>();

            editor.position = new Rect(x, y, width, height);
            //editor.minSize = new Vector2(width, height);
            editor.maxSize = new Vector2(width, height);

            editor.Init();
        }
    }

Затем в OnGUI я добавляю несколько меток, а затем проверяю, изменились ли размер и положение окна:

void OnGUI()
        {
            GUILayout.Label("Testing now");
            minimizeToZero = GUILayout.Toggle(minimizeToZero, "Minimize To Zero");
            stop = GUILayout.Toggle(stop, "Stop");
            GUILayout.Space(10);

            if(minimizeToZero)
            {
                editor = null;
                Prefab editor1 = (PrefabReplace)EditorWindow.GetWindow(typeof(Prefab), true, "My Empty Window");
                x = (Screen.currentResolution.width / 2);
                y = (Screen.currentResolution.height * 4 );// - height - height / 2);
                width = 300;
                height = 20;
                editor1.position = new Rect(x, 0, width, height);

            }
            else
            {
                editor = EditorWindow.GetWindow<Prefab>();
                x = (Screen.currentResolution.width - width) / 2;
                y = (Screen.currentResolution.height - height) / 2;
                width = 300;
                height = 100;
                editor.position = new Rect(x, y, width, height);
            }
        }

Внутри OnGUI, когда я сверну окно, я хочу к немудвигаться к верхней высоте в средней ширине.ширина 300 высота 20

но это не меняется.Я думаю, я не могу изменить размер окна, чтобы он был меньше, чем материал внутри размера, как метки.Поэтому я попытался создать новое пустое окно для тестирования, попробовал editor = null, затем попытался использовать editor1, но ничего.Он не создал новое пустое окно и не изменил его размер.

Основная цель - не создавать новое пустое окно, а каким-либо образом изменить его размер и переместить.Перемещение - это хорошо, но меняя размеры, я не могу сделать высоту 20.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...