GetComponent on new UI (Unity 5)

Hello i want my button to not be interactable. But im not very good with GetComponent so i get a lot of errors. “BuilderButton” is the button that i dont want to have interactable. And i need to write it in a script. And the “Button” is of course the button propeties on the button gameobject.
Then the other line is going to be placed in the middle of my code (the code is not visable here), and it’s going to make my button not clickable. But of course its wrong and i really need your guys help.
~carlqwe

BuilderButton = GameObject.Find("BuilderButton").GetComponent(Button);

BuilderButton.Interactable = false;

First of all, always go to the docs first: Unity - Scripting API: Component.GetComponent

GetComponent returns a Component reference unless you use the generics version, so BuilderButton variable should be of type Component for the first line to compile, and the Component class does not have a “interactable” property.

If you use that version of GetComponent you have to cast the component to the type you want (look at the second example in the docs). If you use the generics version it returns a reference to that type, I always use that one:

Button BuilderButton = GameObject.Find("BuilderButton").GetComponent<Button>();
BuilderButton.interactable = false;

Also, note that the “interactable” property is in lowercase, casing is important when coding.

And one more thing, I think GetComponent(Button) works only in UnityScript, in C# you should do this instead:

GetComponent(typeof(Button)); //send a variable of type "Type"