using System; using UnityEngine; public class LipSyncDemo_SetCurrentTarget : MonoBehaviour { private void Start() { OVRMessenger.AddListener("Touchpad", new OVRCallback(this.LocalTouchEventCallback)); this.targetSet = 0; this.SwitchTargets[0].SetActive(0); this.SwitchTargets[1].SetActive(0); } private void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { this.targetSet = 0; this.SetCurrentTarget(); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { this.targetSet = 1; this.SetCurrentTarget(); } else if (Input.GetKeyDown(KeyCode.Alpha3)) { this.targetSet = 2; this.SetCurrentTarget(); } else if (Input.GetKeyDown(KeyCode.Alpha4)) { this.targetSet = 3; this.SetCurrentTarget(); } else if (Input.GetKeyDown(KeyCode.Alpha5)) { this.targetSet = 4; this.SetCurrentTarget(); } else if (Input.GetKeyDown(KeyCode.Alpha6)) { this.targetSet = 5; this.SetCurrentTarget(); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } } private void SetCurrentTarget() { switch (this.targetSet) { case 0: this.SwitchTargets[0].SetActive(0); this.SwitchTargets[1].SetActive(0); break; case 1: this.SwitchTargets[0].SetActive(0); this.SwitchTargets[1].SetActive(1); break; case 2: this.SwitchTargets[0].SetActive(1); this.SwitchTargets[1].SetActive(2); break; case 3: this.SwitchTargets[0].SetActive(1); this.SwitchTargets[1].SetActive(3); break; case 4: this.SwitchTargets[0].SetActive(2); this.SwitchTargets[1].SetActive(4); break; case 5: this.SwitchTargets[0].SetActive(2); this.SwitchTargets[1].SetActive(5); break; } } private void LocalTouchEventCallback(OVRTouchpad.TouchEvent touchEvent) { if (touchEvent != OVRTouchpad.TouchEvent.Left) { if (touchEvent == OVRTouchpad.TouchEvent.Right) { this.targetSet++; if (this.targetSet > 3) { this.targetSet = 0; } this.SetCurrentTarget(); } } else { this.targetSet--; if (this.targetSet < 0) { this.targetSet = 3; } this.SetCurrentTarget(); } } public EnableSwitch[] SwitchTargets; private int targetSet; }