r/UnityHelp • u/Placeboy0 • Aug 29 '21
PROGRAMMING How do I get a component's property as method parameter?
So I'm trying to change the Light component's Range property but I'm not sure what to put as its type. I tried to get it as string and then convert that to the Range property but I couldn't figure out how. Does anyone know how to do this?
4
Upvotes
2
u/Bonejob Code Guru Aug 29 '21
the Range is a property of the light object so you would get an instance of the light and then reference it by {reference}.Range Don't forget to check if it is a Light type that supports range or it will error out.