Search Unity

Event Trigger not working

Discussion in 'UGUI & TextMesh Pro' started by daisySa, Sep 6, 2014.

  1. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    I’m really loving the new UI but I can’t get a simple event trigger to work.

    I have a text field and I’d like to execute some code when I hover over it. I’ve attached a script to it and added an event trigger. The event trigger has a PointerEnter entry with the text field itself as the game object, and a function in the script as a parameter. The function just displays a Debug.Log message.

    When I hover over the text field, I’m not seeing the log message. Any ideas?
     
  2. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Works for me exactly as described. What did you name the function? Does the Canvas it's in have a Graphics Raycaster with the right mask?
     
    Holly_H likes this.
  3. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    The graphics raycaster is just set to the default options (priority=3, ignore reversed graphics, blocking objects=none, blocking mask=everything).

    The script names are nothing special - it's set up like this:
    https://www.dropbox.com/s/pt12h4zgqeobxg5/event trigger issue.png?dl=0

    I think it's some very basic error I'm making but I can't find it...
     
  4. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    I don't see anything wrong either. Perfect time to start a blank repro project and send it to UT if it's still wonky :)
     
  5. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    Thanks orb, the issue is solved now - your comment about the canvas put me on to the solution.

    The text field was a child of a panel. If I drag it out of there and place it directly under the canvas, it works perfectly. Not sure if that's intentional behaviour or a bug, but at least I have a workaround now. :)
     
  6. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Aha! That canvas is rather important, and yes, it's intentional :)