Howdy!
It's better if I show some script to explain this.
This is what my custom class looks like:
public class ButtonData : Object {
public Rect pos;
public string label;
public ButtonData(Rect p_pos, string p_label) {
pos = p_pos;
label = p_label;
}
}
In another class(in the same script component), I've created this monstrosity:
private ArrayList buttons = new ArrayList();
void Start() {
buttons.Add(new ButtonData(new Rect(100,100,Screen.width-200,40),"Start Game"));
buttons.Add(new ButtonData(new Rect(100,160,Screen.width-200,40),"Exit Game"));
}
Afterwards, I'm trying to do this:
print((ButtonData)buttons[0].label);
However, I seem to be getting the following error:
Assets/Custom Assets/Scripts/controller_startscreen.cs(26,46): error CS1061: Type `object' does not contain a definition for`label' and no extension method `label' of type`object' could be found (are you missing a using directive or an assembly reference?)
Didn't I make it clear enough that the object in buttons[0] is of type ButtonData, and not object?
Could use some help :P
-Tijmen