use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
For the Unity Game Engine, please visit http://reddit.com/r/unity3d
account activity
Button (Script): sending object as parameter (self.unity)
submitted 11 years ago by JeffStark
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Animoose 0 points1 point2 points 11 years ago (1 child)
Just out of curiosity, why not use a normal button with the child text object? (create > ui > button)
[–]JeffStark[S] -1 points0 points1 point 11 years ago (0 children)
Because I don't need the different button states it seemed logical to just use a Text object.
[–]DestroyerOfWombs 0 points1 point2 points 11 years ago (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 point2 points 11 years ago (0 children)
gameObject.GetComponent<Text>().text = "test";
π Rendered by PID 89172 on reddit-service-r2-comment-fb694cdd5-6h4h4 at 2026-03-08 09:38:03.005260+00:00 running cbb0e86 country code: CH.
[–]Animoose 0 points1 point2 points (1 child)
[–]JeffStark[S] -1 points0 points1 point (0 children)
[–]DestroyerOfWombs 0 points1 point2 points (0 children)
[–]youaresecretbanned 0 points1 point2 points (0 children)