For example, several of my scripts need to work with a reference to the same CharacterController. I could store the component in a variable in one script, and have a bunch of others call “thatScript.controller”. Or, I could create a local variable for each script, which will look cleaner down the road, but require more declarations, and use more memory.
How do you handle this stuff? Is there a certain way that yields best performance? How about a way that lends itself well to human brains?
These are very difficult to cache, and the reward is seldom worth the effort.
However, a technique that works well with other things is to declare a class with a static variable to reference the cached object (just set this value in a Start function, say, or just after an instantiate call). You can then refer to the object without an object reference, so it is rather like a global variable.