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. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

is new GUi Button support onMouseDown/Up/Enter/Exit events?

Discussion in 'UGUI & TextMesh Pro' started by icemedia, Aug 22, 2014.

  1. icemedia

    icemedia

    Joined:
    Jul 8, 2014
    Posts:
    10
    I see from tutorial movie the button in new GUI have only onClick .
    not sure are there any way I can detect mousePress/Up/Enter/Exist events like in other tools such as Flash?
     
  2. Legi

    Legi

    Joined:
    Jul 25, 2013
    Posts:
    19
    You can add an EventTrigger Component to the button to get all Events.
     
    Peotor likes this.
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,559
    Or, you can write your own MonoBehaviour that implements IPointerEnter, IPointerExit, etc, to just intercept the specific events that you care about, then expose your own UnityEvent-derived fields to wire up where they're sent. This is essentially what EventTrigger does, but EventTrigger is heavyweight as it implements all the interfaces rather than just the ones you care about.
     
  4. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
  5. icemedia

    icemedia

    Joined:
    Jul 8, 2014
    Posts:
    10
    Thank you all for great answers.