using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using SC.XR.Unity.Module_InputSystem.InputDeviceHand; public class HandEvent : MonoBehaviour { private List dynamicEvents; private List staticEvents; public Material outlineL; public Material outlineR; public Material outlineRB; public Material outlineRL; public Material outlineRR; // Start is called before the first frame update void Start() { InputDeviceHandPartEventBase.eventDelegate += HandEventDelegate; dynamicEvents = GameObject.Find("DynamicEvent").GetAllChildren(); staticEvents = GameObject.Find("StaticEvent").GetAllChildren(); } // Update is called once per frame void Update() { } void OnDestroy() { InputDeviceHandPartEventBase.eventDelegate -= HandEventDelegate; } void HandEventDelegate(InputDeviceHandPart inputDeviceHandPart, HandEventType eventType, float EventPercent) { if (inputDeviceHandPart.PartType == SC.XR.Unity.Module_InputSystem.InputDevicePartType.HandLeft) { if (eventType == HandEventType.Static_Fist) { staticEvents[0].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 0); } else if (eventType == HandEventType.Static_Point) { staticEvents[1].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 1); } else if (eventType == HandEventType.Static_Peace) { staticEvents[2].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 2); } else if (eventType == HandEventType.Static_Three) { staticEvents[3].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 3); } else if (eventType == HandEventType.Static_Four) { staticEvents[4].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 4); } else if (eventType == HandEventType.Static_Five) { staticEvents[5].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 5); } else if (eventType == HandEventType.Static_Phone) { staticEvents[6].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 6); } else if (eventType == HandEventType.Static_Damn) { staticEvents[7].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 7); } else if (eventType == HandEventType.Static_Gun) { staticEvents[8].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 8); } else if (eventType == HandEventType.Static_Like) { staticEvents[9].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 9); } else if (eventType == HandEventType.Static_No_Like) { staticEvents[10].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 10); } else if (eventType == HandEventType.Static_OK) { staticEvents[11].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 11); } else if (eventType == HandEventType.Static_RockAndRoll) { staticEvents[12].GetComponent().material = outlineL; StartCoroutine("SetToOrigin", 12); } else if (eventType == HandEventType.Dynamic_Click_Down || eventType == HandEventType.Dynamic_Click_Hold) { if (dynamicEvents[0].GetComponent().material == outlineRR || dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRB; } else { dynamicEvents[0].GetComponent().material = outlineRL; } } else if (eventType == HandEventType.Dynamic_Click) { if (dynamicEvents[0].GetComponent().material == outlineRR || dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRB; } else { dynamicEvents[0].GetComponent().material = outlineRL; } StartCoroutine("SetAboutClick", 0); } else if (eventType == HandEventType.Dynamic_Click_Up) { if (dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRR; } else { dynamicEvents[0].GetComponent().material = null; } } else if (eventType == HandEventType.Dynamic_Open) { if (dynamicEvents[0].GetComponent().material == outlineRB || dynamicEvents[0].GetComponent().material == outlineRR) { dynamicEvents[0].GetComponent().material = outlineRR; } else { dynamicEvents[0].GetComponent().material = null; } dynamicEvents[1].GetComponent().material = outlineRL; StartCoroutine("SetToOrigin", 21); } else if (eventType == HandEventType.Dynamic_Flip) { if (dynamicEvents[0].GetComponent().material == outlineRB || dynamicEvents[0].GetComponent().material == outlineRR) { dynamicEvents[0].GetComponent().material = outlineRR; } else { dynamicEvents[0].GetComponent().material = null; } dynamicEvents[2].GetComponent().material = outlineRL; StartCoroutine("SetToOrigin", 22); } else if (eventType == HandEventType.Null) { if (dynamicEvents[0].GetComponent().material == outlineRL) { dynamicEvents[0].GetComponent().material = null; } } } else if (inputDeviceHandPart.PartType == SC.XR.Unity.Module_InputSystem.InputDevicePartType.HandRight) { if (eventType == HandEventType.Static_Fist) { staticEvents[0].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 0); } else if (eventType == HandEventType.Static_Point) { staticEvents[1].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 1); } else if (eventType == HandEventType.Static_Peace) { staticEvents[2].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 2); } else if (eventType == HandEventType.Static_Three) { staticEvents[3].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 3); } else if (eventType == HandEventType.Static_Four) { staticEvents[4].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 4); } else if (eventType == HandEventType.Static_Five) { staticEvents[5].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 5); } else if (eventType == HandEventType.Static_Phone) { staticEvents[6].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 6); } else if (eventType == HandEventType.Static_Damn) { staticEvents[7].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 7); } else if (eventType == HandEventType.Static_Gun) { staticEvents[8].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 8); } else if (eventType == HandEventType.Static_Like) { staticEvents[9].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 9); } else if (eventType == HandEventType.Static_No_Like) { staticEvents[10].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 10); } else if (eventType == HandEventType.Static_OK) { staticEvents[11].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 11); } else if (eventType == HandEventType.Static_RockAndRoll) { staticEvents[12].GetComponent().material = outlineR; StartCoroutine("SetToOrigin", 12); } else if (eventType == HandEventType.Dynamic_Click_Down || eventType == HandEventType.Dynamic_Click_Hold) { if (dynamicEvents[0].GetComponent().material == outlineRL || dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRB; } else { dynamicEvents[0].GetComponent().material = outlineRR; } } else if (eventType == HandEventType.Dynamic_Click) { if (dynamicEvents[0].GetComponent().material == outlineRL || dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRB; } else { dynamicEvents[0].GetComponent().material = outlineRR; } StartCoroutine("SetAboutClick", 1); } else if (eventType == HandEventType.Dynamic_Click_Up) { if (dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRL; } else { dynamicEvents[0].GetComponent().material = null; } } else if (eventType == HandEventType.Dynamic_Open) { if (dynamicEvents[0].GetComponent().material == outlineRB || dynamicEvents[0].GetComponent().material == outlineRL) { dynamicEvents[0].GetComponent().material = outlineRL; } else { dynamicEvents[0].GetComponent().material = null; } dynamicEvents[1].GetComponent().material = outlineRR; StartCoroutine("SetToOrigin", 21); } else if (eventType == HandEventType.Dynamic_Flip) { if (dynamicEvents[0].GetComponent().material == outlineRB || dynamicEvents[0].GetComponent().material == outlineRL) { dynamicEvents[0].GetComponent().material = outlineRL; } else { dynamicEvents[0].GetComponent().material = null; } dynamicEvents[2].GetComponent().material = outlineRR; StartCoroutine("SetToOrigin", 22); } else if (eventType == HandEventType.Null) { if (dynamicEvents[0].GetComponent().material == outlineRR) { dynamicEvents[0].GetComponent().material = null; } } } } private IEnumerator SetToOrigin(int keynumber) { yield return new WaitForSeconds(1); if (keynumber < 20) { staticEvents[keynumber].GetComponent().material = null; } else { keynumber -= 20; dynamicEvents[keynumber].GetComponent().material = null; } } private IEnumerator SetAboutClick(int lr) { yield return new WaitForSeconds(1); if (lr == 0) { if (dynamicEvents[0].GetComponent().material == outlineRL) { dynamicEvents[0].GetComponent().material = null; } else if (dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRR; } } else if (lr == 1) { if (dynamicEvents[0].GetComponent().material == outlineRR) { dynamicEvents[0].GetComponent().material = null; } else if (dynamicEvents[0].GetComponent().material == outlineRB) { dynamicEvents[0].GetComponent().material = outlineRL; } } } }