using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
[CustomEditor(typeof(DialogueTrigger))]
public class DialogueTriggerEditor : Editor
{
private SerializedProperty _conversations;
private void OnEnable()
{
_conversations = serializedObject.FindProperty("conversations");
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
serializedObject.Update();
_conversations.arraySize = EditorGUILayout.IntField("Conversations Size", _conversations.arraySize);
for (int x = 0; x < _conversations.arraySize; x++)
{
var conversation = _conversations.GetArrayElementAtIndex(x);
var conversationName = conversation.FindPropertyRelative("conversationName");
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(conversationName);
EditorGUI.indentLevel++;
var _dialogues = conversation.FindPropertyRelative("Dialogues");
_dialogues.arraySize = EditorGUILayout.IntField("Dialogues size", _dialogues.arraySize);
for (int i = 0; i < _dialogues.arraySize; i++)
{
var dialogue = _dialogues.GetArrayElementAtIndex(i);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(dialogue, new GUIContent("Dialogue " + i), true);
EditorGUI.indentLevel--;
}
if (_dialogues.arraySize > 0)
{
if (GUILayout.Button("Save Conversation"))
{
}
}
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
}
I'm using in some places the EditorGUI.indentLevel++; but the result is this:
But I want it to be like this:
Conversations Size
Conversation Name
Dialogue size
Conversation Name
Dialogue size
Conversation Name
Dialogue size
Conversation Name
Dialogue size
This is how it should look like in the Inspector.
The problem is in this part:
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(conversationName);
EditorGUI.indentLevel++;
var _dialogues = conversation.FindPropertyRelative("Dialogues");
_dialogues.arraySize = EditorGUILayout.IntField("Dialogues size", _dialogues.arraySize);
I can't make the "Conversation" Name the "Dialogues" and the "Dialogues size" the same as I wanted.
The "Dialogues" is fine but the others are not.
