So I have code that turns items on/off for different options. When I tried to add a routine so I could make my code nicer I got an error saying the array was out of range. It’s commented out at the end. Not sure what’s up.
using Pixyz.Utils;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputTest : MonoBehaviour
{
public int aIndex;
public GameObject[] Collection1;
public GameObject[] Collection2;
public GameObject[] Collection3;
private bool blActive;
private int intCount;
private bool blOpt1;
private bool blOpt2;
private bool blOpt3;
private string strTemp;
private int i;
// Start is called before the first frame update
void Start()
{
intCount = 0;
}
// Update is called once per frame
void Update()
{
if (OVRInput.GetDown(OVRInput.Button.One))
{
//Set booleans to determine configuration for different options
blOpt1 = false;
blOpt2 = false;
blOpt3 = false;
if (intCount == 1)
{
blOpt1 = true;
blOpt2 = false;
blOpt3 = false;
intCount = intCount + 1;
}
else if (intCount==2)
{
blOpt1 = false;
blOpt2 = true;
blOpt3 = false;
intCount = intCount + 1;
}
else if (intCount==3)
{
blOpt1 = false;
blOpt2 = false;
blOpt3 = true;
intCount = 0;
}
else
{
intCount = intCount + 1;
}
//Set options based on bools
for (int i = 0; i < Collection1.Length; i++)
{
Collection1[i].SetActive(blOpt1);
}
for (int i =0; i < Collection2.Length; i++)
{
Collection2[i].SetActive(blOpt2);
}
for (int i =0; i < Collection3.Length; i++)
{
Collection3[i].SetActive(blOpt3);
}
//TurnObjectsOff(Collection1);
}
}
//void TurnObjectsOff(GameObject[] objects)
//{
// for ( i = 0; i < objects.Length; i++)
// blActive =! objects[i].activeSelf;
// objects[i].SetActive(blActive);
//}
}