i'm making a showroom, and the object i'm showing is rotating due to a script i wrote...now i want to be able to toggle this script on and off by pressing R on the keyboard...this is what i got so far
If the script is disabled, then Update (which presumably is where this code is) isn't running, so naturally it can't reenable itself. You'd want to enable/disable it from another script. (As an aside, better to not use strings with GetComponent...slower and not type-safe.)
A bit curious, so instead of putting a string there I suppose getting the Type would work, but what if we would have multiple objects of the same type possible to grab from GetComponents? How to identify the specific component needed. Or could we cache the string _name in a constructor or is that pretty much the same deal as hardcasting it?
A bit curious, so instead of putting a string there I suppose getting the Type would work, but what if we would have multiple objects of the same type possible to grab from GetComponents? How to identify the specific component needed. Or could we cache the string _name in a constructor or is that pretty much the same deal as hardcasting it?
– Kona