So I have a script, what I want this script to do, have 3 arrays. xFlipObject, yFlipObject, and xyFlipObject. I when this object is clicked there are 2 ways. a single click, and a double click. Single click flips this object horizontally, and double click flips this object vertically. xFlipObject is an object that will flip horiztonally, yFlipObject will flip vertically, and xyFlipObject will be able to flip both vertically or horizontally, depending on single click or double click. These objects mirror the parent object. So xFlip, it will only mirror if the parent object is single clicked. and yFlipObject will only flip if the parent object is doubleclicked. and xyFlipObject will mirror the parent if the parent is single clicked or double clicked. So I have all the programing complete for the flipping and so on and all works just fine. However I want this to be set up where I can have several xFlip, yFlip, and xyFlip. That is where the array comes in. I know I need to be able to detect if there are objects in the slots, and if so, then they may have functionality. If not, then do nothing. How can I do this. Here is the script I have so far. You will notice commented out sections where the old code was. I had a complete code with the mentioned above functionality. Now I just need to set it up for multiple.
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;
public int transformer;
void Awake()
{/*
if (xFlip != null) { transformer = 1; }
else if (yFlip != null) { transformer = 2; }
else if (xyFlip != null) { transformer = 3; }
else { return; }*/
}
void OnMouseDown()
{
if (click && Time.time <= (clickTime + clickDelta))
{
//Rotate Vertically.
click = false;
if(
}
else
{
//Rotate Horizontally.
click = true;
clickTime = Time.time;
}
/*
// This "transformer" is a int.
switch (transformer)
{
//This "1" is an int. So if transformer = 1 then this code will run.
case 1:
// Rotate Functionality
if (click && Time.time <= (clickTime + clickDelta))
{
//Rotate Vertically.
click = false;
}
else
{
//Rotate Horizontally.
click = true;
clickTime = Time.time;
FlipHorizontally();
}
break;
//..This "2" is an int. So if transformer = 2 then this code will run.
case 2:
if (click && Time.time <= (clickTime + clickDelta))
{
click = false;
FlipVertically();
}
else
{
//Rotate Horizontally.
click = true;
clickTime = Time.time;
}
break;
case 3:
if (click && Time.time <= (clickTime + clickDelta))
{
//Rotate Vertically.
click = false;
FlipVertically();
}
else
{
//Rotate Horizontally.
click = true;
clickTime = Time.time;
FlipHorizontally();
}
break;
default:
* //do nothing..
* break;
}*/
}
void FlipHorizontally()
{
//xFlip.GetComponent<NumberMatch>().turnHorizontally();
}
void FlipVertically()
{
//yFlip.GetComponent<NumberMatch>().turnVertically();
}
void FlipXandY()
{
// xyFlip.GetComponent<NumberMatch>().turnVertically();
// xyFlip.GetComponent<NumberMatch>().turnHorizontally();
}
}