예제 #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();
        }
예제 #2
0
        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();
        }