I have this code that lists an array of GUITextures, 16 in total. They all start disabled. What I want is that when I initially click the first GUI it activates the first object in my array; then when I click that GUITexture it is turned off and the next Texture in the array is turned on. I can turn them all off or on but for the life of me I can’t figure how to turn individual ones on.
I’m using C# too just fyi. Thanks!
public class LegZoom2 : MonoBehaviour {
public GameObject body;
public GameObject player;
public GameObject legcamera;
public GUITexture backbutton;
public GUITexture simtest;
public GUITexture simpract;
public GUIText simtext;
public string[] myStrings;
public int currIndex;
public GUITexture[] steps = new GUITexture [16];
public int currIndexep;
// Use this for initialization
void Start () {
Screen.showCursor = true;
}
// Update is called once per frame
void Update () {
Vector3 StartPos = legcamera.transform.position;
Vector3 EndPos = new Vector3 (6.1f, 9.1f, -4.017f);
if(((body.transform.position.x)-(player.transform.position.x)) <= 2.6f && (((body.transform.position.z)-(player.transform.position.z)) >= -1f||((body.transform.position.z)-(player.transform.position.z)) <=3.4f)) {
legcamera.SetActive(true);
player.GetComponent<AudioSource>().enabled = false;
legcamera.transform.position = Vector3.Lerp (StartPos, EndPos, Time.deltaTime * 2);
}
else {
legcamera.SetActive(false);
legcamera.transform.position = new Vector3(4.54f, 9.434f, -3.932f);
simtest.enabled = true;
simpract.enabled = true;
simtext.enabled = false;
foreach (GUITexture obj in steps)
{obj.active = false;
}
}
if (simtest.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0)){
simtext.enabled = true;
simtest.enabled = false;
simpract.enabled = false;
}
if(simpract.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0)){
simtest.enabled = false;
simpract.enabled = false;
steps[0].enabled = true;
}
if (steps[0].HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0)){
currIndexep++;
steps[currIndexep].enabled = true;
steps[currIndexep--].enabled = false;
}
myStrings= new string[]{"Lateral Incision", "Mark Incision", "Incise skin &
Subcutaneous Tissue", "Perform 'H-cut';
watch for peroneal nerve", "Lateral Incision Complete", "Medial Incision", "Mark Incision", "Expose and free Muscles", "Fasciotomy Complete"};
if (simtext.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0)){
currIndex++;
simtext.text = myStrings[currIndex];
}
}
}