I have been trying to figure this out for weeks now and still having some trouble with this. I want to be able to click my text and have roughly 7 game objects appear in a selected position.
using UnityEngine;
using System.Collections;
public class FormationToPlays : MonoBehaviour
{
public bool Play1 = false;
public GameObject Player1 = null;
public GameObject Player2 = null;
public GameObject Player3 = null;
public GameObject Player4 = null;
public GameObject Player5 = null;
public GameObject Player6 = null;
public GameObject Player7 = null;
void OnMouseEnter ()
{
//change text color
renderer.material.color=Color.black;
}
void OnMouseExit ()
{
//change text color
renderer.material.color=Color.white;
}
void OnMouseDown ()
{
//is this Play1
if (Play1 ==true)
{
if (Player1 != null && Player1.gameObject != null)
Player1.gameObject.enabled = !Player1.gameObject.enabled;
if (Player2 != null && Player2.gameObject != null)
Player2.gameObject.enabled = !Player2.gameObject.enabled;
if (Player3 != null && Player3.gameObject != null)
Player3.gameObject.enabled = !Player3.gameObject.enabled;
if (Player4 != null && Player4.gameObject != null)
Player4.gameObject.enabled = !Player4.gameObject.enabled;
if (Player5 != null && Player5.gameObject != null)
Player5.gameObject.enabled = !Player5.gameObject.enabled;
if (Player6 != null && Player6.gameObject != null)
Player6.gameObject.enabled = !Player6.gameObject.enabled;
if (Player7 != null && Player7.gameObject != null)
Player7.gameObject.enabled = !Player7.gameObject.enabled;
}
}
}