- Home /
detect click on collider like button
OnMouseDown();
that one detects click. but what i want to do is making OnMouseUp() like a button the ui button doesnt work if user drag out of its place.
how can i make OnMouse~~() possible to cancle like ui button? will be much better without using raycast.
Not sure exactly what you aim to do but anyway you may find your answer here
Sounds like you want to use http://docs.unity3d.com/ScriptReference/EventSystems.IPointerUpHandler.html
how to use??
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class IEventTest: $$anonymous$$onoBehaviour, IPointerUpHandler
{
public void OnPointerUp(PointerEventData eventData)
{
Debug.Log("Button " + eventData.pointerId + " up");
}
}
this didnt work..
attached collider 2d and nothing was wrong.. sure this does same thing as ui button does?
For this "sure this does same thing as ui button does" : try deriving your class from the button class, rather than monobehavior. e.g. IEventTest:Button.
(note: that class already defines OnPointerUp, you can simply override it.)
Answer by softmarshmallow · Jun 27, 2016 at 01:49 PM
public void OnMouseUpAsButton()
{
card.CardSelected();
}
this does what i ment
Your answer
Follow this Question
Related Questions
Calling method once 2 Answers
Weird Boolean Problem c# 1 Answer
Adding Force with a GUI button 5 Answers
OnMouseUp and GUITexture 1 Answer
Activate an OnMouseDown event before clicking a UI button? 1 Answer