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)