- Home /
Add on click event to canvas button
Given this Scene (see picture).
How do I add an on click event to the Button_Login in the Start()
method of the MonoBehaviour
class connected to my camera. So that when it is clicked the button the method TryLogin(string username, string password)
is called.
I assume I have to get a hold of the button object but I cant find any examples of how to manipulate it as it does not exist in the namespace as Button_Login
and I can't find any way to get the button object.
Answer by Shiro_Rin · Jun 16, 2015 at 06:07 AM
Assuming you're using c From what I understand you're trying to access your code from a button press. If in your code you have it set up to be public , then you can add the object holding the script, and access that function from the button.
Just make sure you set it from "void Start" to "public void Start"
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Change position of a text prefab added to a world space canvas via scripting 0 Answers
[c#] first script isnt disabling canvas and player cant move (issue with first script) 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer