Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Solved] Getting Navigation.selectOn___ from automatic Navigation?

Discussion in 'UGUI & TextMesh Pro' started by Senshi, Aug 23, 2014.

  1. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    556
    Hey guys,

    Does anyone know if there's a way to extract the Selectable to be selected after a Move event from the "Automatic" Navigation type?

    Motivation:
    I'm extending both EventSystem and BaseInputModue for a two-player character selection screen. As such, I need to replace the standard EventSystem's "currentSelectedObject" to keep track of multiple selections. While it seems to be working, I can't manage to find which object will be selected after sending my moveHandler.

    My (failing) code:
    Code (csharp):
    1. CharacterSelectionEventSystem eventSystem = GetComponent<CharacterSelectionEventSystem>();
    2. ExecuteEvents.Execute(eventSystem.GetSelectedGameObject(0), axisEventData[i], ExecuteEvents.moveHandler);
    3. Debug.Log(testBtn.navigation.selectOnRight); //prints null
    4. GameObject rightSelectable = eventSystem.GetSelectedGameObject(0).GetComponent<Button>().navigation.selectOnRight.gameObject; //selectable
    5. eventSystem.SetSelectedGameObject(0, rightSelectable);
    Thanks in advance as always,
    Patrick
     
    Last edited: Aug 23, 2014
    antonin-deudon likes this.
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    Selectable has the public functions:
    Code (csharp):
    1.  
    2. FindSelectableOnUp
    3. FindSelectableOnDown
    4. FindSelectableOnLeft
    5. FindSelectableOnRight
    6.  
    You should be able to use this to find out what will be selected :)
     
  3. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    556
    ...Well now I just feel dumb. Thanks a bunch!
     
    antonin-deudon and mashiro11 like this.
  4. mashiro11

    mashiro11

    Joined:
    Dec 2, 2017
    Posts:
    7
    7 years later, I end here and feel dumb as well
     
    Last edited: Apr 1, 2021
    Senshi and antonin-deudon like this.
  5. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,592
    but is there anyway to tell it what to use without using explicit?