Setting unique data on a gameobject?


So I’m wondering if Unity gameobject’s have the option to set data on them. I’m imagining a way similar to that of box2D where every object has a UserData object that can is a basic object type and can have any value set on it.

So something like myGameObject.Data.uniqueValue = 10000

It seems like this isn’t possible and I’d need to give the gameobject a script component and set the value for that component directly but just wondering anyway.


There isn’t a generic data parameter available on all GameObjects.

So you could use a generic script component if you want simulate that, and add it to everything you wanted to set the value on. It’s lower performance that having the correctly typed value from a known specific script though. I might be able to offer more advice if you let me know what you are trying to achieve with this approach?