- Home /
Double Click problems with NGUI?
Hey guys I have an object that will open a level when clicked and will go into "delete/edit mode" if double clicked, problem is with ngui if I used OnDoubleClick() it seems to be called after the OnClick(), I've searched online and have failed at every solution google has to offer, any advice?
I've been racking my brain trying that but nothing I've tried works, I'm fairly new to coding with no experience, could you give me an example?
Answer by Hellium · Aug 18, 2015 at 11:05 AM
Here is the I made. I have tested it with a NGUI button.
In the inspector :
using UnityEngine;
using System.Collections;
public class DoubleClick : MonoBehaviour
{
public float delayBetween2Clicks ; // Change value in editor
private float lastClickTime = 0 ;
public void OnClickCallBack()
{
if( Time.time - lastClickTime < delayBetween2Clicks )
{
Debug.Log( "Double clicked" );
}
else
{
StartCoroutine( OnClickCoroutine() ) ;
}
lastClickTime = Time.time ;
}
IEnumerator OnClickCoroutine()
{
yield return new WaitForSeconds( delayBetween2Clicks ) ;
if( Time.time - lastClickTime < delayBetween2Clicks )
{
yield break ;
}
Debug.Log( "Simple click" );
}
} // class DoubleClick
THAN$$anonymous$$ YOU SO $$anonymous$$UCH! I had developed a work around that, while it was efficient, was less than what I wanted. You just made my day
Your answer
Follow this Question
Related Questions
Want to move object slowly to where the mouse clicks? 1 Answer
How to brows local folders and get images from it and display them in a unity application? 1 Answer
Multiple Cars not working 1 Answer
how to use onmousedown() or onmouseup() unity on local multiplayer/vs mode? 0 Answers
Distribute terrain in zones 3 Answers