Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UI Navigation Group

Discussion in 'UGUI & TextMesh Pro' started by Vallcrist, Mar 15, 2016.

  1. Vallcrist

    Vallcrist

    Joined:
    Aug 24, 2012
    Posts:
    8
    Hello there everyone. :)

    Does any of you know of a way to "lock" auto navigation inside a group?

    Imagine this scenario


    What I want is to have automatic layout, but I don't want for the player to be able to navigate from the red group to the green group, and vice-versa.

    At the moment in my UI I have various panels, each with their own set of Canvas/Raycaster/CanvasGroup, this allows me to hide unwanted parts of the UI easily without a huge performance impact, but since the selectables inside those panels are still active, even tho hidden, they still are considered for the auto layout system. So what ends up happening if I use auto layout sometimes is: you're on a Menu, you press right on the keyboard and then it selects something that's not even visible to the player, on a panel that has both it's canvas and graphic raycaster disabled.

    I can't just disable the group that's not active, since on more complex UI the performance cost of disabling/enabling a whole group is usually not acceptable.

    Any thoughts on this?
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I dont have an answer, but I also would like to know how unityUI does this.

    kissUI, still in development, tries to do the same thing with many individual Focus Group`ing's.
    webplayer example: http://kissui.izzysoft.com/Examples/FocusGroup 401.html
    (Tab or Shift + Tab, as well as Ctrl + Tab or Ctrl + Shift + Tab)

    I want to make it even better if possible, so that's why I'm curious as well. :)
     
  3. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Set the "interactable" property on the Canvas Group to false. I uploaded a few images to illustrate: http://imgur.com/a/Z6NcH
     
  4. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Did you ever solve this?
    The interactable property doesn't do anything
     
  5. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    K so I needed this exact thing and I got it working.
    Basically you'll have to assign or code the connections explicitly.

    If you spawn the buttons at runtime you'll just have to figure out an alghoritm that connects each button with the button next to it and above/beneath it.

    I looked into overriding the button script to create a custom button, cause according to the UI code on the git you could adjust the code that collects all the elements and connects them, but there's too much code that's hidden to make it work.
     
  6. unity_RdLfcwE4TdLgSA

    unity_RdLfcwE4TdLgSA

    Joined:
    May 18, 2019
    Posts:
    2
    I'm not sure if anyone has answered this, but set all your buttons navigation to explicit using the unity inspector. From there you can tell each button where it can navigate when you press up, down, left, or right. No need for doing anything programmatically.
     
  7. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Well I answered it right before your comment :D

    If you spawn buttons at runtime, which is a common use case, you'll need to do it programmatically