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

Question Is there way to prevent automatic navigation on disabled canvas?

Discussion in 'Scripting' started by Lekret, Jan 24, 2023.

  1. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    272
    I'm using UI plugin which adds different animation functionalities to UI and that's one of the reasons I can't disable UI gameObjects, I can only disable Canvas and Graphic Raycaster on specific UI views.
    But when I'm using gamepad for navigation it can select objects under invisible canvas.
    Is there a workaround apart from using explicit navigation for each element?
     
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,051
    You could try adding a CanvasGroup and disabling interactable when disabling the canvas. This will be applied recursively to all Selectable children and prevent gamepad navigation.
     
    Lekret likes this.
  3. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    272
    Yeah, that works, thanks.