Is it possible to have 2 references in an array?
I have a dialogue script with an array that keeps all the sentences and names, however the names and the text are 2 separate arrays. Is it possible to have 2 grouped references in the same array instead of having 2 separate ones? For example if I increase the size of the array by 1 in the Inspector I want it to add both a sentence string AND a name string. So it goes name, sentence, name, sentence, etc. Is this possible to do with C#?
Comment
Answer by Vega4Life · Dec 15, 2018 at 01:50 AM
This looks a little cleaner
Here is the code I used.
using UnityEngine;
public class DialogueContainer : MonoBehaviour
{
public Dialogue[] dialogues;
}
[System.Serializable]
public class Dialogue
{
public string character;
public Sentence[] sentence;
}
[System.Serializable]
public class Sentence
{
public string sentence;
}
dialogue.jpg
(24.5 kB)
There are many ways to do it, what @Vega4Life suggested is a simple and good option for what dialogues.