Issue with in-game double clicking?

Hey everyone,
I have this issue with double clicking in-game. I wrote this code that checks for input and returns the type of input it received.

In editor it works just fine, but when I export the game it always returns double click type. Even if I click just once. Not sure what’s causing this issue…

Below is the mouse input script and other is how I use it in other scripts.

Mouse Input script:

```csharp
**using System.Collections;
using UnityEngine.EventSystems;

public class MouseInput : MonoBehaviour
{
#region Variables

private enum ClickType      { None, Single, Double }

private static ClickType    currentClick    = ClickType.None;
readonly float              clickdelay      = 0.25f;

#endregion

void OnEnable()
{
    StartCoroutine(InputListener());
}
void OnDisable()
{
    StopAllCoroutines();
}

public static bool SingleMouseClick()
{
    if (currentClick == ClickType.Single)
    {
        currentClick = ClickType.None;
        return true;
    }

    return false;
}
public static bool DoubleMouseClick()
{
    if (currentClick == ClickType.Double)
    {
        currentClick = ClickType.None;
        return true;
    }

    return false;
}

private IEnumerator InputListener()
{
    while (enabled)
    {
        if (Input.GetMouseButtonDown(0))
        { yield return ClickEvent(); }

        yield return null;
    }
}
private IEnumerator ClickEvent()
{
    if (EventSystem.current.IsPointerOverGameObject()) yield break;

    yield return new WaitForEndOfFrame();

    currentClick = ClickType.Single;
    float count = 0f;
    while (count < clickdelay)
    {
        if (Input.GetMouseButtonDown(0))
        {
            currentClick = ClickType.Double;
            yield break;
        }
        count += Time.deltaTime;
        yield return null;
    }
}

}**
** **Usage:** **csharp
if (MouseInput.SingleMouseClick())
{
Debug.Log(“Single click”);
Select(true);
}
else if (MouseInput.DoubleMouseClick())
{
Debug.Log(“Double click”);
Select(false);
}

```

So you’re trying to detect when the user single- or double-clicks on the “background”, not pointed at any object?

Why is MouseInput line 59 waiting for end-of-frame instead of waiting for the next frame? I haven’t tested, but my expectation would be that GetMouseButtonDown() will continue to return true until you actually get to the next frame, which means a single click could get the code through both checks. Not sure why it would be different in the editor than in the build, though.

Also, I assume you realize that (if this code were working properly) every double-click would first be counted as a single-click, since there will be a window of time between the first and second click when currentClick has a value of Single.