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 How to Update in EditorWindow

Discussion in 'Scripting' started by Rachan, Sep 30, 2023.

  1. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    Hi there!

    I working on custom editor just for open some scene and play, just by only click on menu with mouse
    instead of open specific scene and click play on middle top button [>],

    so I really want to add some hot key to order this thing similar to click that menu by mouse
    I just want to know how to make an Update() in EditorWindow ?

    Thanks!!!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    This question seems to have nothing to do with Code Editors or IDEs (the subject of this sub-forum) but you tagged it Visual Studio though so I'm p

    Are you talking about Visual Studio? If so, I'm not following the EditorWindow Update has to do with it.

    If you are just asking about making a Custom Editor and doing certain things like loading a scene then yes, this is the wrong forum and I can move your post to the Scripting forum for you.

    If not, maybe you can clarify your question.
     
  3. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    Oh thank you for your answer!

    I thought this forum can talking about Editor script, But so sorry then.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    No problem, I can move it to the Scripting forum for you.
     
    Rachan likes this.
  5. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    Thanks!
    and so is this possible to get key press detector or update() in custom editor?

    I used by call even.current, But it always null if mouse not over the editor GUI
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
  7. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
  8. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    Oh! I found the way to use keyboard command, I actually don't make an Update() or get any keys

    just by add % (key) after menu item
    such as [MenuItem("Play %g")]

    so, it mean (Ctl + g) on keyboard to make it run that code

    But if I don't want to use ctl+ ?
    I just want to press only one key, this is possible?
     
    Last edited: Oct 1, 2023
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    Rachan likes this.
  10. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    MelvMay likes this.
  11. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    654
    and Oh! I know how to toggle 1 button to make it works,
    just use "_" +key name

    such as "_F5"
    this mean press F5 on keyboard to make it works!

    and why don't even have a list of button name for this in document?
    such as

    % is CTL
    # is Shift
    _ is only one button
    & is Alt