Right now, to access my assets using scripts, I have an object with a variable referencing each asset I want to use. They are assigned using the inspector. I could clean up my code a lot if instead of having this object lying around, I could just make them static variables in the class of the object. Is there a way to assign to these though? If the inspector can’t do it, is there a way to reference them by name in the code or something?
- You can load them if they are in a Resources folder using Resources.Load (I do this sometimes).
- You could keep them as variables in an object, but have the object set a static Current when it does Awake(), then you can get it pretty easily from elsewhere (I do this too - this is also nice for overriding on a level by level basis
- You can have them copy from a local variable to a static when an object does its Awake