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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug Can't interact with buttons on build.

Discussion in 'UI Toolkit' started by Gekigengar, Oct 1, 2022.

  1. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    706
    Unity 2022.2.0b8
    Experimental Packages : Entities 1.0.e8
    Input Handler : Both

    Button can be clicked in the editor, but not on build.
    Also cannot change focus on buttons using tab/arrow keys.

    It works previously on 2021.3.10f1 LTS, both Editor and Build.

    Is there some build settings I am missing?
     
  2. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    117
    Oh, same here Editor works perfect, Build is broken. I also tried 2022.2.0b8 and 2022.2.0b9.

    I tried to register some Callbackhandlers: I figured out, that:
    MouseOverEvents are working fine
    MouseDownEvent Not firing
    MouseUpEventNot Not firing
    ClickedEvent Not firing

    It seems its not just buttons. I played a bit around with a Lable, there all the events were not fired. Textboxes are also completely broken. So no idea, why just the MouseOverEvent of the button works :(
     
    Gekigengar likes this.
  3. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    117
    Fixed/Workaround: I found, that there is a DefaultEventSystem used to fire the events in the editor. It seems, this is broken somehow for the new Unity Version.
    => I added next to all of my UiDocument a StandaloneInputModule Component from the UI Framework and its worked again.
     
    Gekigengar likes this.
  4. pierre_10

    pierre_10

    Unity Technologies

    Joined:
    Apr 1, 2016
    Posts:
    33
    HI guys, can one of you log a defect with the project and let us know the ticket id?
     
  5. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    198
    Hi Gekigengar,

    The philosophy we have in UIToolkit for now is that if you want to use the new Input in your project alongside UIToolkit, you have to go through UGUI's EventSystem (see Unity Manual here), because at the moment we're not directly integrated with the new Input. That being said, we are actively working on completing that direct integration in the near future.

    However, it's true that having a certain behaviour in the Editor and not in the Build is problematic. I confirm from testing your setup that, indeed, when in a Build and using Active Input Handling = "Both" with only a UIDocument on the scene, no PointerDownEvent, PointerUpEvent, ClickEvent, MouseDownEvent, MouseUpEvent are received.

    Oddly enough, I've found that adding a script with an empty OnGUI method seems to fix the problem.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class ScriptWithEmptyOnGUI : MonoBehaviour
    4. {
    5.     void OnGUI()
    6.     {
    7.        
    8.     }
    9. }
    10.  
    I'm pretty sure the problem comes from some optimization in our Build code that detects there's no GUI active in the game, and seeing that the new Input is also present (because you have "Both" selected) it probably discards the old input events. On the other hand UIToolkit detects that the old input also available and it tries to consume the GUI events, which aren't there.

    In all cases, what you get in the Editor and what you get in the Build shouldn't differ by that much of a margin, so I think we can treat this as a bug despite your setup not being officially supported right now. Like Pierre said, if you can log a bug we'll do our best to come up with a fix as soon as possible.
     
    Gekigengar likes this.
  6. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    706
    Sorry for the late reply, thanks for acknowledging and investigating the issue! I was worried this is not logged because its never in the "Known Issue" among the patches, and there are currently 3 threads about the same issue with no replies.

    I guess I will be using the workaround until this is fixed on later patches!

    The project is gigabytes in size, I will need to decouple a lot of things and create a new project to create an isolated environment for this specific issue. But it seems like uBenoitA has been able to reproduce the issue with the current setup. Is it still needed?
     
  7. uBenoitA

    uBenoitA

    Unity Technologies

    Joined:
    Apr 15, 2020
    Posts:
    198
    > But it seems like uBenoitA has been able to reproduce the issue with the current setup. Is it still needed?

    No, it's alright, here's my simple repro in case anyone else needs it. We can create a ticket internally, no problem.
     

    Attached Files:

    Gekigengar likes this.
  8. pierre_10

    pierre_10

    Unity Technologies

    Joined:
    Apr 1, 2016
    Posts:
    33
    Yup it's fine, i'll log something on our side and reply with the ticket number.
     
  9. pierre_10

    pierre_10

    Unity Technologies

    Joined:
    Apr 1, 2016
    Posts:
    33
  10. AAK_Lebanon

    AAK_Lebanon

    Joined:
    May 30, 2015
    Posts:
    77
    This is still happening in the latest version of Unity 2022.2.16: Simply create a new project, install the Input System package (in my case it was the latest one, 1.5.1), change the Active Input Handling to the new input system (from player settings), create a button that enables, for example, an image on click. build to Android and when you press the button it will remain in the clicked status without enabling the image ...
    It works fine in the Editor but not on the device.
    I tried everything mentioned in this discussion but never succeed.
    This is very annoying because I can't test my app (I want to use the new Memory profiler that is only available in Unity 2022)...
     
  11. huwp

    huwp

    Joined:
    May 22, 2013
    Posts:
    33
    Noticed a missed step there, is the Event System configured to use the new Input System?

    inputsys.png
     
  12. AAK_Lebanon

    AAK_Lebanon

    Joined:
    May 30, 2015
    Posts:
    77
    Yes, it is configured correctly. I would like to mention that I am using a Mac, so my version of unity is the Silicon one.
     
    Last edited: May 1, 2023