Search Unity

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:
    20
    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,659
    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.