Esempio n. 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            languageCount = BlazeDialogueSettingsEditor.GetOrCreateSettings().languageDefinition.Length;

            EditorGUI.LabelField(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight), label, EditorStyles.miniBoldLabel);

            if (GUI.Button(new Rect(position.x + position.width - 30, position.y + EditorGUIUtility.singleLineHeight, 30, EditorGUIUtility.singleLineHeight * GetLineCount()), EditorGUIUtility.IconContent("_Popup")))
            {
                showTranslation = !showTranslation;
            }

            var tempRect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width - 30, EditorGUIUtility.singleLineHeight * GetLineCount());
            var contents = property.FindPropertyRelative("contents");

            if (contents.arraySize != languageCount)
                contents.arraySize = languageCount;

            for (int i = 0; i < contents.arraySize; i++)
            {
                EditorGUI.PropertyField(tempRect, contents.GetArrayElementAtIndex(i), GUIContent.none);
                tempRect.y += (EditorGUIUtility.singleLineHeight + itemSpacing) * GetLineCount();

                if (!showTranslation && i == 0)
                {
                    //only draw the first item if we don't show the translation
                    break;
                }
            }

            EditorGUI.EndProperty();
        }
        public static SettingsProvider CreateMyCustomSettingsProvider()
        {
            var provider = new SettingsProvider("Project/Blaze/Dialogue", SettingsScope.Project)
            {
                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = (searchContext) =>
                {
                    var settings = BlazeDialogueSettingsEditor.GetSerializedSettings();
                    EditorGUILayout.PropertyField(settings.FindProperty("languageDefinition"), new GUIContent("Languages"), true);
                    settings.ApplyModifiedProperties();
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = new HashSet <string>(new[] { "Translation" })
            };

            return(provider);
        }
        public void AddNewItem(bool insert)
        {
            var index = contentsProp.arraySize;

            if (insert && m_TreeView.HasSelection() && m_TreeView.GetSelection()[0] < contentsProp.arraySize)
            {
                index = m_TreeView.GetSelection()[0];
            }

            contentsProp.InsertArrayElementAtIndex(index);
            var array = contentsProp.GetArrayElementAtIndex(index).FindPropertyRelative("content").FindPropertyRelative("contents");

            array.ClearArray();
            array.arraySize = BlazeDialogueSettingsEditor.GetOrCreateSettings().languageDefinition.Length;

            m_TreeView.SetSelection(new int[] { index });

            m_TreeView.Reload();
        }