using UnityEngine; public class EnableSwitch : MonoBehaviour { public GameObject[] SwitchTargets; /// /// Sets the active GameObject /// /// true, if active was set, false otherwise. /// Target. public bool SetActive(int target) where T : MonoBehaviour { if((target < 0) || (target >= SwitchTargets.Length)) return false; for (int i = 0; i < SwitchTargets.Length; i++) { SwitchTargets[i].SetActive(false); // Disable texture flip or morph target OVRLipSyncContextMorphTarget lipsyncContextMorph = SwitchTargets[i].GetComponent(); if (lipsyncContextMorph) lipsyncContextMorph.enabled = false; OVRLipSyncContextTextureFlip lipsyncContextTexture = SwitchTargets[i].GetComponent(); if (lipsyncContextTexture) lipsyncContextTexture.enabled = false; } SwitchTargets[target].SetActive(true); MonoBehaviour lipsyncContext = SwitchTargets[target].GetComponent(); if (lipsyncContext != null) { lipsyncContext.enabled = true; } return true; } }