Search Unity

How to make UI button work in editor

Discussion in 'UGUI & TextMesh Pro' started by Wulirocks, Apr 20, 2021.

  1. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Hi,

    I am trying to make Ui button register a click in the editor but can't figure out how...

    Under On Click, I set to "Editor and runtime", I even set my script to [ExecuteInEditMode],
    then click on the button on Display1 and nothing happens. I still have to launch the game to test it out....

    What s the secret?

    Thanks!
    upload_2021-4-20_20-34-19.png
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Events won't work in the game view unless it's playing, so you can't make a button work like that.

    If you explain what you're trying to accomplish maybe someone could have a different solution though :)
     
  3. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    I am just trying to test out as much as possible of what I am developing without running the game to save time. I was doing that when using some IMGUI button combined with [ExecuteInEditMode] on my classes, where I could test the navigation of my UI (pressing tab, opening menu etc ) in the editor. I feel Unity UI system is missing that aspect although it is highly convenient on many other different level. For now to test a button, I do have an editorWindow that call the button function to test things out... it is ok but it is just that for every Unity Ui button method I want to test I have to create an equivalent button on the EditorWindow...
    upload_2021-4-23_19-21-22.png