Example #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            position        = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
            position.width -= 34;
            position.height = 18;

            Rect valueRect = new Rect(position)
            {
                x     = position.x + 15,
                width = position.width - 15
            };

            Rect foldButtonRect = new Rect(position)
            {
                x     = position.x,
                width = 15
            };

            dropdown = EditorGUI.Foldout(foldButtonRect, dropdown, "");

            position.x     += 15;
            position.width -= 15;

            SerializedProperty key = property.FindPropertyRelative("key");

            key.stringValue = EditorGUI.TextField(position, key.stringValue);

            position.x     += position.width + 2;
            position.width  = 17;
            position.height = 17;
            GUIContent searchContent = new GUIContent(Resources.Load <Texture>("CoreScript/Texture/search"));

            if (GUI.Button(position, searchContent))
            {
                TextLocaliserSearchWindow.Open();
            }

            position.x += position.width + 2;

            GUIContent storeContent = new GUIContent(Resources.Load <Texture>("CoreScript/Texture/store"));

            if (GUI.Button(position, storeContent))
            {
                TextLocaliserEditWindow.Open(key.stringValue);
            }

            if (dropdown)
            {
                var      value = LocalisationData.GetLocalisedValue(key.stringValue);
                GUIStyle style = GUI.skin.box;
                height = style.CalcHeight(new GUIContent(value), valueRect.width);

                valueRect.height = height;
                valueRect.y     += 21;
                EditorGUI.LabelField(valueRect, value, EditorStyles.wordWrappedLabel);
            }

            EditorGUI.EndProperty();
        }
Example #2
0
        public static void Open()
        {
            TextLocaliserSearchWindow window = new TextLocaliserSearchWindow()
            {
                titleContent = new GUIContent("Localiser Window")
            };

            Vector2 mouse = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
            Rect    rect  = new Rect(mouse.x - 450, mouse.y + 10, 10, 10);

            window.ShowAsDropDown(rect, new Vector2(500, 300));

            window.ShowUtility();
        }