I've got a scene with 10,000 GameObjects in it and I need to associate some additional data with each object. I can accomplish this using a script with a class that derives from MonoBehaviour, but if I do this, my framerate drops because the engine calls Update() on every GameObject in every frame. I don't intend to implement Update(), but it's killing my framerate.
I tried making my class derive from Component, but then I cannot attach it to my GameObject prefab because it must derive from MonoBehaviour.
Is there a better way to attach a class to a GameObject to get more data without requiring the Update() logic to run every frame?
I didn't realize it was as simple as deleting the Update() function. In my mind, it was simply an override to a virtual function that would get called every frame regardless of the implementation. The solution really is as simple as deleting the Update() function from the script. Thanks Mike!
– anon93477660If it were a virtual function, you'd have to use the override keyword. The way it actually works is that it stores a pointer to your function when the script is instantiated, and calls that
– anon85704231Clever! I wondered why I didn't have to use the override keyword. Made that mistake a few times trying to actually implement some overrides.
– anon93477660