playMaker

Author Topic: Have a button auto selected when opening new UI window?  (Read 424 times)

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Have a button auto selected when opening new UI window?
« on: April 03, 2023, 12:35:05 PM »
When you talk to an NPC in my game, or open a menu, a new UI window opens up with different options: I want to allow the player to scroll up / down to select an option.

The problem is that when a menu is opened up, nothing is selected, so it won't let a player scroll through the various buttons. Moving the control stick doesn't auto select a button either. I can select a button with the mouse and THEN the controller / keyboard will work. If I can have a button auto-selected already when the menu opens, this will solve the problem for me. Any ideas or how to do this with playmaker?

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Have a button auto selected when opening new UI window?
« Reply #1 on: April 03, 2023, 01:07:20 PM »
I ended up using the invoke method action with this:

Code: [Select]
    Button button;
   
    void Select_Button()
    {
        button = GetComponent<Button>();
        button.Select();
    }

Just copied this from something on the Unity forums. Works for me.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7621
    • jinxtergames
Re: Have a button auto selected when opening new UI window?
« Reply #2 on: April 04, 2023, 07:26:02 AM »
Hi.
There is an action for it :)
"Ui Set Selected Game Object"