112 lines
2.4 KiB
C#
112 lines
2.4 KiB
C#
using UnityEngine;
|
|
|
|
public class LipSyncDemo_SetCurrentTarget : MonoBehaviour
|
|
{
|
|
public EnableSwitch[] SwitchTargets;
|
|
|
|
private int targetSet;
|
|
|
|
private int maxTarget = 6;
|
|
|
|
private void Start()
|
|
{
|
|
OVRTouchpad.AddListener(LocalTouchEventCallback);
|
|
targetSet = 0;
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextMorphTarget>(0);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextMorphTarget>(0);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Alpha1))
|
|
{
|
|
targetSet = 0;
|
|
SetCurrentTarget();
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.Alpha2))
|
|
{
|
|
targetSet = 1;
|
|
SetCurrentTarget();
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.Alpha3))
|
|
{
|
|
targetSet = 2;
|
|
SetCurrentTarget();
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.Alpha4))
|
|
{
|
|
targetSet = 3;
|
|
SetCurrentTarget();
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.Alpha5))
|
|
{
|
|
targetSet = 4;
|
|
SetCurrentTarget();
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.Alpha6))
|
|
{
|
|
targetSet = 5;
|
|
SetCurrentTarget();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
Application.Quit();
|
|
}
|
|
}
|
|
|
|
private void SetCurrentTarget()
|
|
{
|
|
switch (targetSet)
|
|
{
|
|
case 0:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextMorphTarget>(0);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextMorphTarget>(0);
|
|
break;
|
|
case 1:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextTextureFlip>(0);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextTextureFlip>(1);
|
|
break;
|
|
case 2:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextMorphTarget>(1);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextMorphTarget>(2);
|
|
break;
|
|
case 3:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextTextureFlip>(1);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextTextureFlip>(3);
|
|
break;
|
|
case 4:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextMorphTarget>(2);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextMorphTarget>(4);
|
|
break;
|
|
case 5:
|
|
SwitchTargets[0].SetActive<OVRLipSyncContextTextureFlip>(2);
|
|
SwitchTargets[1].SetActive<OVRLipSyncContextTextureFlip>(5);
|
|
break;
|
|
}
|
|
OVRLipSyncDebugConsole.Clear();
|
|
}
|
|
|
|
private void LocalTouchEventCallback(OVRTouchpad.TouchEvent touchEvent)
|
|
{
|
|
switch (touchEvent)
|
|
{
|
|
case OVRTouchpad.TouchEvent.Left:
|
|
targetSet--;
|
|
if (targetSet < 0)
|
|
{
|
|
targetSet = maxTarget - 1;
|
|
}
|
|
SetCurrentTarget();
|
|
break;
|
|
case OVRTouchpad.TouchEvent.Right:
|
|
targetSet++;
|
|
if (targetSet >= maxTarget)
|
|
{
|
|
targetSet = 0;
|
|
}
|
|
SetCurrentTarget();
|
|
break;
|
|
}
|
|
}
|
|
}
|