using System; using System.Collections.Generic; using UnityEngine; public class ViveHandAnimator : OvrHandAnimator { protected override void Start() { for (int i = 0; i < this.m_aryFingerData.Length; i++) { this.m_aryFingerData[i] = new OvrHandAnimator.FingerMorph(); } List list = new List(); this.FindChild(list, this.m_trRootGrasp); for (int j = 0; j < this.m_listRoot.Length; j++) { List list2 = new List(); List list3 = new List(); this.FindChild(list3, this.m_trFingerRoot[j]); using (List.Enumerator enumerator = list3.GetEnumerator()) { while (enumerator.MoveNext()) { Transform trBase = enumerator.Current; Transform transform = list.Find((Transform a) => a.name == trBase.name); if (transform != null) { list2.Add(new OvrHandAnimator.BonePair(trBase, transform)); } else { Debug.LogWarning("指ペアが見つかりません。" + trBase.name); } } } this.m_listRoot[j] = list2; } } public override void Init(AVRControllerButtons f_CtrlBtn) { this.m_CtrlBtn = f_CtrlBtn; } private void OnEnable() { this.OnChangeScreenSizeOrAA(); } protected override void FindChild(List f_list, Transform f_trParent) { for (int i = 0; i < f_trParent.childCount; i++) { this.FindChild(f_list, f_trParent.GetChild(i)); } f_list.Add(f_trParent); } public override void FingerRateTarget(OvrHandAnimator.Finger f_eFinger, float f_fRate) { this.m_fTargetRate[(int)f_eFinger] = f_fRate; } protected override void FingerRateUpdate(OvrHandAnimator.Finger f_eFinger, float f_fRate) { OvrHandAnimator.FingerMorph fingerMorph = this.m_aryFingerData[(int)f_eFinger]; fingerMorph.fTarget = f_fRate; float num = fingerMorph.fTarget - fingerMorph.fNow; float num2 = num * this.m_fEaseRate; fingerMorph.fNow += num2; List list = this.m_listRoot[(int)f_eFinger]; for (int i = 0; i < list.Count; i++) { OvrHandAnimator.BonePair bonePair = list[i]; bonePair.trMain.localRotation = Quaternion.Slerp(bonePair.qBackRot, bonePair.trGrasp.localRotation, fingerMorph.fNow); } } public void OnChangeScreenSizeOrAA() { bool flag = QualitySettings.antiAliasing == 0 && !GameMain.Instance.MainCamera.IsBloomEnabled; if (GameMain.Instance.VRMode && !GameMain.Instance.VRDummyMode) { flag = false; } foreach (Renderer renderer in base.transform.GetComponentsInChildren(true)) { if (renderer == null || renderer.materials == null) { return; } foreach (Material material in renderer.materials) { if (flag) { material.EnableKeyword("UV_POS_REVERSE"); material.DisableKeyword("UV_POS_NORMAL"); } else { material.DisableKeyword("UV_POS_NORMAL"); material.DisableKeyword("UV_POS_REVERSE"); } } } } protected override void Update() { float triggerRate = this.m_CtrlBtn.GetTriggerRate(); this.FingerRateTarget(OvrHandAnimator.Finger.Thumb, triggerRate); this.FingerRateTarget(OvrHandAnimator.Finger.Index, triggerRate); this.FingerRateTarget(OvrHandAnimator.Finger.Middle, triggerRate); this.FingerRateTarget(OvrHandAnimator.Finger.Ring, triggerRate); this.FingerRateTarget(OvrHandAnimator.Finger.Little, triggerRate); for (int i = 0; i < 5; i++) { this.FingerRateUpdate((OvrHandAnimator.Finger)i, this.m_fTargetRate[i]); } } }