I have a number of gameobjects that get created dynamically (via Instantiate) that have a main controlling script on them. After they are created I need to access the transform and the main controlling script frequently from another script on the parent object. In order to avoid using GetComponent all the time I have created a wrapping class for the Instantiated gameObjects. The wrapping class does not inherit from Monobehaviour. It takes in an instance of the GameObject created via Instantiate and saves Public references to the transform and main controlling scripts. This way I can instantiate each object, wrap it in the wrapper class and then pop it into a Javascript Array. I can then iterate through the array and access the transform and script via WrapperClass.trans and WrapperClass.script. The reason for the wrapper class was to allow direct references to the transform and controlling script of the object without using GetComponent.
Now I thought that that would be a fast solution. However I am now having my doubts as it seems that there is some overhead I am not aware of in doing what I am doing. Can anyone shed some light on this?
I guess the simple answer I am looking for is whether what I am doing is a bad idea or not. Should my wrapping class inherit from MonoBehaviour? Am I meddling with non-managed code if I don't inherit from monobehaviour? Or is it slow because the type is being determined at runtime when I access it from the array? Hmmmm should I use C# with generics?