- Home /
This question was
closed Apr 26, 2021 at 11:45 AM by
pommerose94 for the following reason:
The question is answered, right answer was accepted
Question by
pommerose94 · Apr 26, 2021 at 07:57 AM ·
buttonscript.select
how to select UI button with script
So i have a question. I would like to select another button when i click a button, with a script, not with UI navigation.
the script should look like this:
public GameObject ButtonToSelect; public void OnButtonClick () { //Select the button }
I probably miss only one line of code, I read documentation but fould nothing about this. woud lt be possible to please help me?
kind Regards, Leno
Comment
Answer by pommerose94 · Apr 26, 2021 at 11:44 AM
so the problem was resolved by myself
if you want to select a button on click you can use this script:
using UnityEngine; using UnityEngine.UI;
public class destinationButton : MonoBehaviour {
public void DestinationButton(Button destinationButton)
{
destinationButton.Select();
}
}