Question by
MegaDriver · Dec 28, 2015 at 05:20 AM ·
c#unity 5guibutton
Code is right (according to tutorial) but I still get a CS0428 error?
So I was following a GUI Button related tutorial for Unity 5+ and I copy the code on it exactly like it displayed, like this:
void Start ()
{
mainMenu = mainMenu.GetComponent <Canvas>;
startButton = startButton.GetComponent <Button>;
quitButton = quitButton.GetComponent <Button>;
}
but, unlike the tutorial, I get this error:
I dont see anything actually wrong with the tutorial nor the code I wrote myself. Why is this happening? Am I missing something?
(They are all stated as public right before void Start, btw. )
Thanks in advance!
Comment
Best Answer
Answer by mikelortega · Dec 28, 2015 at 09:27 AM
The parenthesis are missing. Check this:
void Start ()
{
mainMenu = mainMenu.GetComponent<Canvas>();
startButton = startButton.GetComponent<Button>();
quitButton = quitButton.GetComponent<Button>();
}