Question by
this_Jamal · Nov 02, 2018 at 07:07 PM ·
uibuttoncanvas
How to find an UI button by name?
using UnityEngine.UI;
public class myPlayerController : MonoBehaviour {
public Button mybutton;
void Start(){
mybutton = GameObject.Find("Canvas/mybutton");
}
}
Can someone help me?
I can't get the button in the canvas via script
and googling did not help!
Thank you;
Comment
Answer by HellAvalor · Mar 19, 2019 at 06:06 PM
Something like
Button yourButton = GameObject.Find("yourButton Name").GetComponent<Button>();
Your answer
Follow this Question
Related Questions
UI Button not working? 0 Answers
AddListener fuction throwing a NullReferenceException error 1 Answer
Button custom collider 0 Answers