Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity UI focus system is total mess.

Discussion in 'Scripting' started by leegod, Aug 2, 2020.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    1,924
    In most cases, I should set UI button navigation explicit because there are many UI layers,

    but this is default situation most game faced.

    And if pop up window opened, focus goes to there and don't return automatically, so should set again to previous UI button.

    So this means programmer should know all UI control cases, and manually code all those cases.
     
  2. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,075
    If you want to use automatic navigation, you need to disable all controls that you don't want to be accessible at a given time--NOT merely e.g. move them off-screen, or conceal them by drawing other stuff on top of them, which are tricks that work fine if you only care about pointer input. This will probably involve a lot of Canvas Groups used to disable an entire screen or window of controls.

    If you have a screen where some controls get dynamically added, removed, or moved around, automatic navigation can save a lot of effort because it will update on the fly to compensate for those changes. Explicit navigation will require that you reassign those fields yourself as things change.

    But automatic navigation is also not terribly smart. It sometimes makes wonky decisions about what goes where, and I don't think it's guaranteed to make every control reachable in extreme cases (it's certainly not guaranteed symmetrical). You can almost certainly make things sleeker if you devise a custom solution that takes your specific screen layout into account.
     
unityunity