Ejemplo n.º 1
0
        public static void Show(Rect r, SerializedProperty prop)
        {
            if (instance == null)
            {
                instance = (CustomTextEditorWindow)EditorWindow.CreateInstance <CustomTextEditorWindow>();
            }

            //instance.ShowAsDropDown(r, r.size);
            //instance.ShowUtility();
            r.y     -= 16;
            r.height = 360;
            r.xMax  += 1;
            var screen_rect = Screen.safeArea;

            if (r.yMax > screen_rect.yMax)
            {
                r.y -= (r.yMax - screen_rect.yMax - 20);
            }

            instance.target   = (System.Object)prop.GetValue();
            instance.property = prop;
            instance.Enable();
            instance.ShowPopup();
            instance.basePosition = r;
            instance.position     = r;
            instance.Focus();

            if (styleHint == null)
            {
                styleHint         = new GUIStyle(EditorStyles.label);
                styleHintSelected = new GUIStyle(EditorStyles.label);
                Texture2D tex = new Texture2D(1, 1); tex.SetPixel(0, 0, Color.blue); tex.Apply();
                styleHintSelected.normal.background = tex;
                styleHintSelected.normal.textColor  = Color.white;
            }
        }