Rick74
1
So I’ve heard this trick is pretty great at just handling data storage. And I wanna learn how to use it, but a few things I’m fuzzy on.
I’ve read this answer, Store multiple types of data in an Array? - Questions & Answers - Unity Discussions but unfortunately I’m still learning C# and there are some things I’m fuzzy on.
If I create a class;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ButtonData : MonoBehaviour
{
public GameObject buttonGameObject;
public Image buttonImage;
public Button button;
public float coolDown;
public int value;
}
And then I call that class to create an array within another class;
public ButtonData[] allButtonData;
How come if I remove : MonoBehavior from the ButtonData class, the array of buttonData disappears in the inspector?
And where do I fill in the values of each entry? It can’t be done within the inspector as that only seems to be looking for objects containing that class?
I guess I was sort of expecting a means to house data and then enter that data in the inspector like you can with any other single data type array.
So if anyone knows of a great tutorial page or documentation as to how and coders use this method, I’d love to read it.
You have to serialize the Class.
So above the class declaration type:
[System.Serializable]
And you can remove the MonoBehaviour inheritance. You can just leave it as class, that doesn’t inherit from anything.
Now you can declare an instance of that class in a MonoBehaviour script…
If i understand correctly your question…