I have an array in c sharp that I want to inherit from a class in another script. How would I write this? Help
Arrays are native types. They do not inherit.
You can have an array of a particular type by declaring it as follows…
public MyCustomType[] myArray;
… and then instantiating it like this…
void Start() {
// Creates an array that holds 6 elements.
myArray = new MyCustomType[6];
}
Note that the above creates the array of references of the appropriate type. It does not create the objects, so the references are all null until you assign them.
For some reason after I do it the array is not accessible in the inspector. Why?
Post some code maybe? I don’t understand if you want an array of a custom type, and array of a derived type, an array in a derived type or an array in a parent type.
Hi, is your class serializable ? Otherwise you’ll need to create a Property Drawer using your own setters and getters for your class if you want it displayed as a field in a component.
I worked it out. Thanks for the help. I made the class serialiazable and that fixed it!