Event on mouse up
I have a button on a canvas.
The canvas appears when I select a character (the canvas is a child of the character) using SetActive().
What I want to be able to do is click the character, hold the mouse button down, and when I let go of the mouse button, trigger the button below the mouse.
PointerUp and PointerClick events don't seem to work for this ..
Is there any way I can create something like this?
Answer by azmundai · Aug 27, 2015 at 01:52 AM
So I am not sure I completely understand this solution, but ... it seems to be pretty easy to setup. The new event system appears to handle most of this, there just isn't anything built into the buttons like PointerUp.
What I did was just used a simple
             if(Input.GetMouseButtonUp (0) ) {
                 ControllerMouseUp();
             }
in Update, and then
         private void ControllerMouseUp(){
             PointerEventData ped = new PointerEventData(EventSystem.current);
             ped.position = Input.mousePosition;
             List<RaycastResult> rcr = new List<RaycastResult>();
             EventSystem.current.RaycastAll(ped, rcr);
             if(rcr.Count > 0){
                 foreach(RaycastResult r in rcr){
                     if(r.gameObject.tag == "Button"){
                         // DO STUFF
                     }
                 }
             }
         }
You also have to make sure to add
 using System.Collections.Generic;
 using UnityEngine.EventSystems;
at the top of your class. Anyway, hopefully this will help someone :)
Answer by Positive7 · Aug 24, 2015 at 08:47 PM
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseUp.html
 public void OnMouseUp(){
         Debug.Log("OnMouseUp triggered");
     }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                