50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class VoiceModEnableSwitch : MonoBehaviour
|
|
{
|
|
public GameObject[] SwitchTargets;
|
|
|
|
public bool SetActive<T>(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);
|
|
OVRLipSyncContextMorphTarget component = SwitchTargets[i].GetComponent<OVRLipSyncContextMorphTarget>();
|
|
if ((bool)component)
|
|
{
|
|
component.enabled = false;
|
|
}
|
|
OVRLipSyncContextTextureFlip component2 = SwitchTargets[i].GetComponent<OVRLipSyncContextTextureFlip>();
|
|
if ((bool)component2)
|
|
{
|
|
component2.enabled = false;
|
|
}
|
|
}
|
|
SwitchTargets[target].SetActive(true);
|
|
MonoBehaviour component3 = SwitchTargets[target].GetComponent<T>();
|
|
if (component3 != null)
|
|
{
|
|
component3.enabled = true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool SetActive(int target)
|
|
{
|
|
if (target < 0 || target >= SwitchTargets.Length)
|
|
{
|
|
return false;
|
|
}
|
|
for (int i = 0; i < SwitchTargets.Length; i++)
|
|
{
|
|
SwitchTargets[i].SetActive(false);
|
|
}
|
|
SwitchTargets[target].SetActive(true);
|
|
return true;
|
|
}
|
|
}
|