Search Unity

UI event triggers and what they do.

Discussion in 'UGUI & TextMesh Pro' started by Clintmcc, Apr 24, 2015.

  1. Clintmcc

    Clintmcc

    Joined:
    Nov 8, 2014
    Posts:
    5
    Hi all, long time reader, first time poster!

    I am using Unity's new UI. well its new to me at least. I am making a system for if an object is clicked, while the mouse button is held option icons pop up, when you move your mouse to an icon and release the mouse button it does something. I cant figure out what the event trigger is for mouse button released. I believe I used the OnMouseUp method in the past but as far as triggers go I have PointerDown, PointerUp & PointerClick. Logic suggests PointerUp is what I'm after but if getting the click is PointerClick then this makes no sense and what would PointerDown do? I have set my icon up as a raw image and the enter/exit triggers are working fine(changing colors on mouse enter/exit). I just can't get the PointerUp trigger to run my public method on button released. I don't get any errors, I assume the problem is with the event trigger. Out of interest sake here is the method I'm calling on PointerUp:
    Code (CSharp):
    1.     public void onMouseUp(){
    2.         mouseReleased = true;
    3.         Debug.Log ("mouseUpWorking");
    4.     }
    Searching online hasn't helped me thus far so I am wondering, does anyone know what each event trigger actually does or where I can find out? Unity documentation doesn't actually give any descriptions and leads me down a rabbit hole and the tutorial video simply states that there are event triggers.

    Any help is much appreciated and thanks in advance.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    In general down detects when a button is pressed. Up detects when it is released. A click is composed of a down event then an up event on the same element.

    The list of all the events can be found in the API under UnityEngine.EventSystems, or in the manual under Scripting/EventSystem
     
    Clintmcc likes this.
  3. Clintmcc

    Clintmcc

    Joined:
    Nov 8, 2014
    Posts:
    5
    Thank's for responding. This is all making sense now and seems quite obvious hearing someone else say it. Looks like my UI stuff is set up correctly after all. Time to triple check my code. Thanks again.

    **Edit**
    If anyone else has the same problem, It's really simple. I called my method onMouseUp which exists as a method already. Simply changing it to MouseUp fixed it.
     
    Last edited: Apr 26, 2015
    Kiwasi likes this.
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Yes, you cannot create your own functions with the same names as MonoBehaviour or other build in function, else it will override (hide) it when it is compiled.
     
    Clintmcc likes this.