vendredi 31 juillet 2015

Accessing Public 2D Array Variables via Script in Unity

So I figured out how to make a 2D array that is viewable in the inspector via the code below.

[System.Serializable]
 public class QuestPhase {
     [HideInInspector]
     public string name;
     public int[] Phase = new int[5];
 }
 public QuestPhase[] questPhase    = new QuestPhase[5];

That works just fine, but I'm trying to figure out how to access that information via script and I can't figure it out.

 questVariable = questPhase[1,1];

That returns an error of "Expected 1 index, got 2", and just using one index gives me "Cannot convert type QuestPhase into type int." I'm sure the answer is obvious, but if anyone could answer it for me I would be most appreciative.

Aucun commentaire:

Enregistrer un commentaire