Muhammad Usama Alam commented on my question linking me to another similar post. But in said post they already solved my problem and were trying to solve another. The link is right here: stackoverflow.com/a/55407835/4812203
My problem was that (suggested by hijinxbassist and Cool guy) I wasn´t using [System.Serializable]
. But that didn't solve all my problems.
Then I had to [Suggested by S.Hoseinpoor] changed the type from array to List using List<>
.
And lastly, [extracted from Muhammad Usama Alam's comment] I needed to make an editor script to make the whole array of variables appear on the editor.}
To brake it down:
This is my script containing the dialogue line base:
[System.Serialible]
public class DialogueLine
{
[SerializeField] private string input;
[SerializeField] private Color textColor;
[SerializeField] private float delay;
}
Then my DialogueBase script:
public class DialogueBaseClass : MonoBehaviour
{
[SerializeField]
public List<DialogueLine> DialogueSize = new List<DialogueLine>();
(...)
}
And lastly my editor script so that the editor renders everything as I want it to (extrected directly from the link, credit goes to Dubi Duboni)
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(DialogueBase))]
public class DialogueBase : Editor
{
private SerializedProperty _dialogues;
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
_dialogues = serializedObject.FindProperty("dialogue");
serializedObject.Update();
for (int i = 0; i < _dialogues.arraySize; i++)
{
var dialogue = _dialogues.GetArrayElementAtIndex(i);
EditorGUILayout.PropertyField(dialogue, new GUIContent("Dialogue " + i));
}
}
}
Hope anyone who finds this gets what they need.
Again, credit for that last part goes to the real author, I do not claim to be the original writter of that code.
You can read the whole thread containing the last part here: stackoverflow.com/a/55407835/4812203 (Suggested by Muhammad Usama Alam).