- Home /
Array with two values per element
I need to create a Array with two values per element:
One bool and one string.
Is there a way to do that in unity (C#)?
Comment
Best Answer
Answer by fafase · Apr 18, 2014 at 01:58 PM
Make a struct
[System.Serializable]
public class Data{
public string theString;
public bool theBool;
}
then make an array of it:
public Data[] dataArray;
@fafase The public variable doesn't appear! If I add the System.SerializableAttribute it gives me an error:
The attribute `System.SerializableAttribute' is not valid on this declaration type. It is valid on `class, struct, enum, delegate' declarations only
struct cannot be serizaliable in Unity only classes so make it a class.
Your answer
Follow this Question
Related Questions
IndexOutOfRangeException help on debug 3 Answers
Add to Array 1 Answer
Array empties values on RunTime? 1 Answer
Array problems 3 Answers
How can i create array of texture2d with variables names ? 2 Answers