- Home /
Can I change the input "submit" and "cancel" button of an eventsystem from a script?
So basically I want to change the submit and cancel button by script. But I can't seem to get those variables out of this component.
Is this even possible? Or do I have to make an input module my self? How do I do that? Thanks for reading!
Answer by Nekosan_Metalcat · Jan 12, 2020 at 06:36 PM
so I was able to fix it myself with a small workaround. I made a small script that I put on every button:
Button = button; bool selected;
void start() { button = GetComponent(); }
void Update() { if (Input.GetKeyDown("Action") && selected) { button.onClick.Invoke(); } }
public void OnSelect(BaseEventData eventData) { selected = true; }
public void OnDeselect((BaseEventData eventData) { selected = false; }
Your answer
Follow this Question
Related Questions
How to create a turn based battle system? 3 Answers
EventSystem not detecting all UI elements 1 Answer
How do I stop EventSystem.currentSelectedGameObject from changing on a button press 0 Answers
How to send mouse events directly to the canvas in world pos 0 Answers
[C#] Unity asks for a } for a reason I don't know ( '}' expected ) 1 Answer