Disable script on other game object

hey everyone,

how would i go about disabling a script on my camera when i touch a gui button?

i need this because i dont want the ray script on the camera to be called when touching a GUI

i have it set up right now to limit the ray in a rectangle, but with requiring pop up GUI elements the rectangle doesnt really help that much unless the GUI is outside of it.

any help?

If you’ve figured out how to create the gui button and all you need to do is disable the script you do this:

MyScriptName myScript = gameObject.GetComponent<MyScriptName>();
myScript.enabled = false;

But you won’t be able to dynamically type it, something worth remembering :slight_smile: Don’t forget casting.