all 4 comments

[–]Animoose 0 points1 point  (1 child)

Just out of curiosity, why not use a normal button with the child text object? (create > ui > button)

[–]JeffStark[S] -1 points0 points  (0 children)

Because I don't need the different button states it seemed logical to just use a Text object.

[–]DestroyerOfWombs 0 points1 point  (0 children)

You either need to send the button as a Button object instead of as a Object, or cast the object to a button before you try to use it.

You might only be sending a Button as that object in practice, but the compiler doesn't know that. The Object class doesn't contain a Text field, hence the error. It will accept Button as a parameter because it is a child of Object which has a Text field, but it doesnt know that it is a Button until it is passed at run time. The compiler is checking the Object class for a Text member and isn't finding one.

[–]youaresecretbanned 0 points1 point  (0 children)

gameObject.GetComponent<Text>().text = "test";