So I am instantiating an object and I am specifying its component. How do I call the constructor for Item?
Here is the overloaded function that I’m calling:
public GameObject(string name, params Type[] components);
And here is the line that creates the new object with the Item class. How do I call Item’s constructor?
GameObject g = new GameObject("Item", typeof(Item));
You don’t want to have constructors on your MonoBehaviour’s for various reasons.
Initialize your data in the Awake, Start or OnEnable functions.
1 Like
Why the hell am I an idiot? like wtf how did I not think of this. how stupid do I have to be to not think of this? Please tell me. wow
The Item class was originally not a monobehavior so that’s why it had a constructor. But I totally forgot that once you have monobehavior, you have the start function. Wow I think Im going to sleep for the rest of the night
2 Likes