Trying to reach out again. Need to get this script working, but can't find the issue.

So the idea of this script. There are 3 arrays. xFlipObject, yFlipObject, and xyFlipObject. If there are objects assigned to these slots, then all of the objects in each slot will be mirrored to the parent. (The Object clicked upon) So the parent has 2 functions. A single click, which will flip it horizontally, and a double click which will flip it vertically. So for example. If there are any objects in xFlipObject slot, then when the parent is single clicked. The assigned objects in xFlipObject[ ] will filp horizontally. But if the parent is doubleclicked(Vertical flip function) the object in the xFlipSlot will not mirror the parent and do nothing. If there are any objects in the yFlipObject slot. Then if the parent is double clicked, then the assigned objects will will mirror the parent and flip vertically. But with a single click they will do nothing. Now for the xyFlipObject, the assigned objects will mirror both single and double click Horizontal and Vertical. The script I have written to my understanding is correct. However its not working. My only guess is that the way I am detecting the single click/double click. Because with the debug logs when I double click, I get the debug log for both single click and double click. As if a double click is acutally both a single and double click in 1. Any help with this script would be greatly appreciated. Here is the code.

using UnityEngine;
using System.Collections;

public class TransformTiles : MonoBehaviour
{
//First slot flips Horizontally.
//Second slot flips Vertically.
//Third slot flips bolth Horizontally and Vertically.
public GameObject[ ] xFlipObject;
public GameObject[ ] yFlipObject;
public GameObject[ ] xyFlipObject;

static float clickDelta = 0.35f; // Max between two click to be considered a double click

private bool click = false;
private float clickTime;

void OnMouseDown()
{
if (click && Time.time <= (clickTime + clickDelta))
{
Debug.Log(“Should flip Vertically”);
//Rotate Vertically.
click = false;
foreach (GameObject obj in yFlipObject)
{
if (obj != null)
{
Debug.Log(“Flip Each Obj in yFlipSlot”);
obj.GetComponent().turnVertically();
}
}
foreach (GameObject obj in xyFlipObject)
{
if (obj != null)
{
Debug.Log(“Flip Each Obj Vertically in xyFlipSlot”);
obj.GetComponent().turnVertically();
}
}
}
else
{
Debug.Log(“Should Flip Horizontaly”);
//Rotate Horizontally.
click = true;
clickTime = Time.time;

foreach (GameObject obj in xFlipObject)
{
if (obj != null)
{
Debug.Log(“Flip Each Obj in xFlipSlot”);
obj.GetComponent().turnHorizontally();
}
}

foreach (GameObject obj in xyFlipObject)
{
if (obj != null)
{
Debug.Log(“Flip Each Obj Horizontally in xyFlipSlot”);
obj.GetComponent().turnHorizontally();
}
}
}
}
}

1843551–118248–TransformTiles.cs (2.1 KB)

Please use code tags and proper indents when posting code.

One issue with your code is that you will always perform the single click action once. It is similar to your desktop. When you double click an icon you first select it (because that is what single click actions do).

The same behavior will be repeated if outside the double click period.

One thing you could try (not sure given your project or C#) how easy it is but you could on the first click do a yield waitforseconds for the deltatime allotted. After the wait period see if a second click was called, if it wasn’t do the single click action. If it was don’t go through the rest of the single click code, and because the second click was within threshold it will already be doing its logic.

Quite frankly unless you have something preventing it I’d just move the double click behavior to the right click but that’s just me.

Thank you for telling me how to post my code on the forums, I apologize for that. However I figured the issue out. It was the way I was detecting the single or double click. I forgot the Update() comepletely. The else statement should have been nothing but click = true; and clickTime = Time.time; the code I placed there should have all been in the update instead.