using System; using System.Collections.Generic; using System.IO; using I2.Loc; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using wf; public class HandSignShortcut : MonoBehaviour { public static HandSignShortcut.Serializer config { get { HandSignShortcut.LoadDefault(); return HandSignShortcut.m_Config; } } private static void LoadDefault() { if (HandSignShortcut.m_IsLoadedDefault) { return; } HandSignShortcut.m_IsLoadedDefault = true; HandSignShortcut.m_Config = HandSignShortcut.m_Config.ReadAndSet(); } public bool IsLeftHand { get { return this.m_IsLeftHand; } set { this.m_IsLeftHand = value; } } public AVRController controller { get { return this.m_Controller; } private set { this.m_Controller = value; } } private CircleListSelectUI circleList { get { return this.m_CircleList; } set { this.m_CircleList = value; } } public bool isEnableHandUI { get { return this.circleList != null && this.circleList.gameObject.activeSelf; } set { if (this.circleList != null && this.circleList.gameObject.activeSelf != value) { this.circleList.gameObject.SetActive(value); } } } public void Init(bool isLeftHand) { this.IsLeftHand = isLeftHand; Debug.Log("初期化:ハンドサインのショートカットを実行するコンポーネント"); this.controller = ((!isLeftHand) ? GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller : GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller); this.InitHand(); this.InitCircleUI(); } private void InitHand() { Maid maid = this.GetMaid(); Transform t; string[] array; if (this.IsLeftHand) { t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true); array = HandSignShortcut.strHandBoneNameL; } else { t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true); array = HandSignShortcut.strHandBoneNameR; } this.m_TransformFingerArray = new Transform[array.Length]; for (int i = 0; i < array.Length; i++) { this.m_TransformFingerArray[i] = CMT.SearchObjName(t, array[i], true); } } private void InitCircleUI() { string text = "OVR/CircleCommandUI/HandSignDataShortcut(Cotroller)"; GameObject gameObject = Resources.Load(text); if (gameObject == null) { NDebug.Assert("[HandSignShortcut] " + text + "\nプレハブが見つかりません", false); } GameObject gameObject2 = UnityEngine.Object.Instantiate(gameObject); this.circleList = gameObject2.GetComponent(); this.CreateItemList(8); CircleCommandUI circleCommandUI = this.circleList.circleCommandUI; circleCommandUI.onSelect.AddListener(new UnityAction(this.OnSelectItem)); circleCommandUI.onDeselect.AddListener(new UnityAction(this.OnDeselectItem)); circleCommandUI.onDecide.AddListener(new UnityAction(this.OnDecide)); this.circleList.controller = this.controller; Transform transform = gameObject2.transform; transform.SetParent(base.transform); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; Vector3 b = new Vector3(0.03f, 0.15f, -0.05f); Vector3 localEulerAngles = new Vector3(35f, 15f, 0f); if (this.IsLeftHand) { b.Scale(new Vector3(-1f, 1f, 1f)); localEulerAngles.Scale(new Vector3(1f, -1f, -1f)); } transform.localPosition += b; transform.localEulerAngles = localEulerAngles; GameObject childObject = UTY.GetChildObject(this.circleList.gameObject, "CircleCommandUI/text right hand", false); childObject.GetComponent().text = ((!this.IsLeftHand) ? "右" : "左"); Localize localize = childObject.AddComponent(); if (this.IsLeftHand) { Utility.SetLocalizeTerm(localize, "System/左", false); } else { Utility.SetLocalizeTerm(localize, "System/右", false); } } private void CreateItemList(int count) { List dataList = HandSignShortcut.config.maidFingerDataList; CircleCommandUI circleCommandUI = this.circleList.circleCommandUI; circleCommandUI.Show(count, delegate(int index, Transform trans) { Text componentInChildren = trans.GetComponentInChildren(); trans.localScale = Vector3.one * 0.5f; HandSignShortcut.ItemData itemData = trans.gameObject.AddComponent(); itemData.text = componentInChildren; itemData.SetLocalizeTerm("VAS/" + componentInChildren); if (index == 0) { itemData.data = null; return; } if (dataList.Count > index - 1) { itemData.data = dataList[index - 1]; } else { itemData.data = null; } }); } private void OnSelectItem(GameObject item) { if (item == null) { return; } Graphic component = item.GetComponent(); if (component != null) { component.color = Color.red; } item.transform.localScale = Vector3.one; item.transform.SetAsLastSibling(); if (ControllerShortcutSettingData.config.isDirectMode) { HandSignShortcut.ItemData component2 = item.GetComponent(); if (component2 != null) { this.m_NowTargetFingerData = component2.data; } else { this.m_NowTargetFingerData = null; } } } private void OnDeselectItem(GameObject item) { if (item == null) { return; } Graphic component = item.GetComponent(); if (component != null) { Color white = Color.white; white.a = 0.5f; component.color = white; } item.transform.localScale = Vector3.one * 0.5f; } private void OnDecide(GameObject selectItem) { if (selectItem == null) { Debug.LogWarning("選択項目にnullが入った"); return; } this.OnDeselectItem(selectItem); if (!ControllerShortcutSettingData.config.isEveryShowMode) { this.m_CircleList.SetActiveUI(false); } if (ControllerShortcutSettingData.config.isDirectMode) { return; } HandSignShortcut.ItemData component = selectItem.GetComponent(); if (component != null) { this.m_NowTargetFingerData = component.data; } else { this.m_NowTargetFingerData = null; } } private void Update() { if (this.m_NowTargetFingerData != null) { this.UpdateFinger(this.m_NowTargetFingerData); } else { this.UpdateHandSign(); } } private void UpdateHandSign() { if (this.controller == null || !this.controller.HandEnable) { return; } AVRControllerButtons vrcontrollerButtons = this.controller.VRControllerButtons; if (vrcontrollerButtons != null) { if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH) { if (vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.REST) || vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.XA) || vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.YB)) { this.FingerRateTarget(HandSignShortcut.Finger.Thumb, 1f); } else { this.FingerRateTarget(HandSignShortcut.Finger.Thumb, 0f); } if (vrcontrollerButtons.GetPress(AVRControllerButtons.BTN.TRIGGER)) { this.FingerRateTarget(HandSignShortcut.Finger.Index, 1f); } else if (vrcontrollerButtons.GetTouch(AVRControllerButtons.TOUCH.TRIGGER)) { this.FingerRateTarget(HandSignShortcut.Finger.Index, 0.5f); } else { this.FingerRateTarget(HandSignShortcut.Finger.Index, 0f); } if (vrcontrollerButtons.GetPress(AVRControllerButtons.BTN.GRIP)) { this.FingerRateTarget(HandSignShortcut.Finger.Middle, 1f); this.FingerRateTarget(HandSignShortcut.Finger.Ring, 1f); this.FingerRateTarget(HandSignShortcut.Finger.Little, 1f); } else { this.FingerRateTarget(HandSignShortcut.Finger.Middle, 0f); this.FingerRateTarget(HandSignShortcut.Finger.Ring, 0f); this.FingerRateTarget(HandSignShortcut.Finger.Little, 0f); } } else if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.VIVE) { this.FingerRateTarget(HandSignShortcut.Finger.Thumb, vrcontrollerButtons.GetTriggerRate()); this.FingerRateTarget(HandSignShortcut.Finger.Index, vrcontrollerButtons.GetTriggerRate()); this.FingerRateTarget(HandSignShortcut.Finger.Middle, vrcontrollerButtons.GetTriggerRate()); this.FingerRateTarget(HandSignShortcut.Finger.Ring, vrcontrollerButtons.GetTriggerRate()); this.FingerRateTarget(HandSignShortcut.Finger.Little, vrcontrollerButtons.GetTriggerRate()); } } for (int i = 0; i < 5; i++) { this.FingerRateUpdate((HandSignShortcut.Finger)i, this.m_fTargetRate[i]); } } private void FingerRateTarget(HandSignShortcut.Finger f_eFinger, float f_fRate) { this.m_fTargetRate[(int)f_eFinger] = f_fRate; } private void FingerRateUpdate(HandSignShortcut.Finger f_eFinger, float f_fRate) { int num = (int)(f_eFinger * HandSignShortcut.Finger.Ring); for (int i = num; i < num + 3; i++) { if (this.IsLeftHand) { this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, Quaternion.Lerp(HandSignShortcut.m_aryHandRot[0, i], HandSignShortcut.m_aryHandRot[1, i], f_fRate), 0.25f); } else { this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, Quaternion.Lerp(HandSignShortcut.m_aryHandRot[2, i], HandSignShortcut.m_aryHandRot[3, i], f_fRate), 0.25f); } } } private void UpdateFinger(HandSignShortcut.MaidFingerData data) { Quaternion[] array = (!this.IsLeftHand) ? data.rightFingerData : data.leftFingerData; for (int i = 0; i < this.m_TransformFingerArray.Length; i++) { this.m_TransformFingerArray[i].localRotation = Quaternion.Lerp(this.m_TransformFingerArray[i].localRotation, array[i], 0.25f); } } private Maid GetMaid() { CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; return characterMgr.GetMaid(0); } private void OnApplicationQuit() { this.m_IsQuitting = true; } private void OnDestroy() { if (this.m_IsQuitting) { return; } if (this.circleList != null && this.circleList.gameObject != null) { UnityEngine.Object.Destroy(this.circleList.gameObject); Debug.Log("[HandSignShortcut] コントローラについているUIを破棄しました"); } } // Note: this type is marked as 'beforefieldinit'. static HandSignShortcut() { Quaternion[,] array = new Quaternion[4, 15]; array[0, 0] = new Quaternion(1.379457E-08f, -1.907173E-10f, -0.1001217f, 0.9949752f); array[0, 1] = new Quaternion(-3.348364E-08f, -2.288052E-09f, -0.05697599f, 0.9983756f); array[0, 2] = new Quaternion(0.4853954f, -0.1902075f, 0.1155978f, 0.8454878f); array[0, 3] = new Quaternion(-2.555888E-09f, 1.190041E-09f, -0.08838178f, 0.9960867f); array[0, 4] = new Quaternion(-3.708266E-09f, -4.232382E-11f, -0.1423017f, 0.9898233f); array[0, 5] = new Quaternion(0.005196964f, -0.009313619f, -0.07643344f, 0.9970177f); array[0, 6] = new Quaternion(1.469708E-09f, -2.337872E-09f, -0.08838177f, 0.9960867f); array[0, 7] = new Quaternion(-4.677417E-09f, -1.311283E-08f, -0.1086997f, 0.9940746f); array[0, 8] = new Quaternion(-0.001879324f, -0.005337666f, -0.0991221f, 0.9950592f); array[0, 9] = new Quaternion(-8.490085E-09f, -1.805363E-09f, -0.0796621f, 0.9968219f); array[0, 10] = new Quaternion(2.300491E-09f, 3.334659E-09f, -0.1239805f, 0.9922847f); array[0, 11] = new Quaternion(-0.006921342f, 0.001893361f, -0.09829046f, 0.9951319f); array[0, 12] = new Quaternion(-5.701029E-09f, -1.521331E-09f, -0.05449884f, 0.9985139f); array[0, 13] = new Quaternion(3.803335E-09f, -5.725684E-09f, -0.1423017f, 0.9898233f); array[0, 14] = new Quaternion(-0.01357147f, 0.02850812f, -0.08513741f, 0.9958689f); array[1, 0] = new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f); array[1, 1] = new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f); array[1, 2] = new Quaternion(0.7708589f, -0.2672266f, 0.03713043f, 0.577051f); array[1, 3] = new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f); array[1, 4] = new Quaternion(-5.034789E-09f, -5.799267E-09f, -0.8191521f, 0.5735765f); array[1, 5] = new Quaternion(0.0478053f, -0.01974053f, -0.5880075f, 0.8072003f); array[1, 6] = new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f); array[1, 7] = new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f); array[1, 8] = new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f); array[1, 9] = new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f); array[1, 10] = new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f); array[1, 11] = new Quaternion(-0.04368013f, 0.007996441f, -0.6048046f, 0.7951349f); array[1, 12] = new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008097f, 0.8655574f); array[1, 13] = new Quaternion(4.887594E-09f, -3.295959E-08f, -0.8191521f, 0.5735765f); array[1, 14] = new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987924f); array[2, 0] = new Quaternion(-1.299039E-08f, 7.939377E-10f, -0.08632442f, 0.9962671f); array[2, 1] = new Quaternion(-1.412307E-08f, -4.882294E-09f, -0.05340298f, 0.9985731f); array[2, 2] = new Quaternion(-0.4710969f, 0.1764064f, 0.1206711f, 0.8557962f); array[2, 3] = new Quaternion(-1.785701E-09f, -1.246846E-08f, -0.06366991f, 0.9979711f); array[2, 4] = new Quaternion(-5.778726E-11f, -1.242248E-08f, -0.1014653f, 0.9948391f); array[2, 5] = new Quaternion(-0.002611603f, 0.001185287f, -0.04763259f, 0.9988608f); array[2, 6] = new Quaternion(1.790176E-09f, -1.245129E-08f, -0.0636699f, 0.9979711f); array[2, 7] = new Quaternion(5.652268E-09f, 1.780454E-09f, -0.06771687f, 0.9977046f); array[2, 8] = new Quaternion(0.001466242f, 0.004677885f, -0.07036161f, 0.9975095f); array[2, 9] = new Quaternion(7.64029E-09f, 7.058498E-09f, -0.05493468f, 0.99849f); array[2, 10] = new Quaternion(-2.104634E-09f, -7.598384E-09f, -0.08305829f, 0.9965447f); array[2, 11] = new Quaternion(0.004817214f, 0.003811401f, -0.0695642f, 0.9975586f); array[2, 12] = new Quaternion(2.864904E-09f, -1.440215E-08f, -0.02973721f, 0.9995578f); array[2, 13] = new Quaternion(-7.071282E-10f, -5.241497E-09f, -0.1014653f, 0.9948391f); array[2, 14] = new Quaternion(0.00861063f, -0.01516612f, -0.05657673f, 0.998246f); array[3, 0] = new Quaternion(7.66758E-09f, -1.102812E-08f, -0.3665012f, 0.9304176f); array[3, 1] = new Quaternion(-8.709043E-09f, -7.065411E-09f, -0.1618618f, 0.9868135f); array[3, 2] = new Quaternion(-0.7708589f, 0.2672265f, 0.03713048f, 0.577051f); array[3, 3] = new Quaternion(-8.292553E-09f, 7.889813E-10f, -0.5299194f, 0.8480481f); array[3, 4] = new Quaternion(6.103158E-09f, 4.273478E-09f, -0.8191521f, 0.5735765f); array[3, 5] = new Quaternion(-0.0478053f, 0.01974053f, -0.5880075f, 0.8072003f); array[3, 6] = new Quaternion(-1.288366E-08f, 7.501511E-09f, -0.5299194f, 0.8480481f); array[3, 7] = new Quaternion(1.786481E-08f, 1.343313E-08f, -0.7992581f, 0.6009881f); array[3, 8] = new Quaternion(0.009090304f, 0.01649068f, -0.6061373f, 0.7951371f); array[3, 9] = new Quaternion(1.513849E-08f, -3.815058E-09f, -0.5224782f, 0.8526527f); array[3, 10] = new Quaternion(-1.643181E-08f, -2.748009E-09f, -0.8084095f, 0.5886205f); array[3, 11] = new Quaternion(0.04368011f, -0.007996418f, -0.6048046f, 0.7951349f); array[3, 12] = new Quaternion(1.196498E-08f, -9.074872E-09f, -0.5008097f, 0.8655574f); array[3, 13] = new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.8191521f, 0.5735765f); array[3, 14] = new Quaternion(0.09800829f, -0.0545494f, -0.5910579f, 0.7987924f); HandSignShortcut.m_aryHandRot = array; } [SerializeField] private CircleListSelectUI m_CircleList; private static HandSignShortcut.Serializer m_Config = new HandSignShortcut.Serializer(); private static bool m_IsLoadedDefault = false; private Transform[] m_TransformFingerArray; private static readonly string[] strHandBoneNameL = new string[] { "Bip01 L Finger02", "Bip01 L Finger01", "Bip01 L Finger0", "Bip01 L Finger12", "Bip01 L Finger11", "Bip01 L Finger1", "Bip01 L Finger22", "Bip01 L Finger21", "Bip01 L Finger2", "Bip01 L Finger32", "Bip01 L Finger31", "Bip01 L Finger3", "Bip01 L Finger42", "Bip01 L Finger41", "Bip01 L Finger4" }; private static readonly string[] strHandBoneNameR = new string[] { "Bip01 R Finger02", "Bip01 R Finger01", "Bip01 R Finger0", "Bip01 R Finger12", "Bip01 R Finger11", "Bip01 R Finger1", "Bip01 R Finger22", "Bip01 R Finger21", "Bip01 R Finger2", "Bip01 R Finger32", "Bip01 R Finger31", "Bip01 R Finger3", "Bip01 R Finger42", "Bip01 R Finger41", "Bip01 R Finger4" }; private static readonly Quaternion[,] m_aryHandRot; private bool m_IsLeftHand; private AVRController m_Controller; private float[] m_fTargetRate = new float[5]; private HandSignShortcut.MaidFingerData m_NowTargetFingerData; private bool m_IsQuitting; [Serializable] public class Serializer : ISerializationCallbackReceiver { public void OnBeforeSerialize() { this.m_nVersion = 1570; } public void OnAfterDeserialize() { } public bool Write() { string contents = JsonUtility.ToJson(this, true); string path = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "MaidFingerDataList.json"); try { File.WriteAllText(path, contents); } catch { Debug.LogError("MaidFingerDataList.json の書き込みに失敗。"); return false; } return true; } public HandSignShortcut.Serializer ReadAndSet() { string path = Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "MaidFingerDataList.json"); if (!File.Exists(path)) { this.CreateDefaultData(); this.Write(); } string json; try { json = File.ReadAllText(path); } catch { Debug.LogError("MaidFingerDataList.json の読込に失敗。"); return this; } return JsonUtility.FromJson(json); } private void CreateDefaultData() { this.maidFingerDataList = new List(); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("パー", new Quaternion[] { new Quaternion(1.467912E-08f, -6.667659E-09f, -0.04146498f, 0.99914f), new Quaternion(-1.327911E-08f, 7.618504E-09f, -0.006113322f, 0.9999813f), new Quaternion(0.3676831f, -0.3100421f, 0.1039245f, 0.8705646f), new Quaternion(-1.67299E-09f, 3.947202E-09f, -0.01237995f, 0.9999234f), new Quaternion(-1.825179E-09f, 3.798766E-09f, -0.01925841f, 0.9998146f), new Quaternion(0.0009547397f, -0.1243148f, 0.01200425f, 0.9921698f), new Quaternion(2.058673E-10f, -3.274742E-10f, -0.01237995f, 0.9999234f), new Quaternion(-3.4198E-09f, -1.477873E-08f, 0.01461135f, 0.9998932f), new Quaternion(-0.0006127622f, -0.003308513f, -0.01102171f, 0.9999336f), new Quaternion(-7.097293E-09f, -1.542719E-08f, -0.003629622f, 0.9999934f), new Quaternion(1.494679E-09f, -1.210031E-08f, -0.0007735032f, 0.9999997f), new Quaternion(-0.0008713655f, 0.08438367f, -0.010264f, 0.9963801f), new Quaternion(-1.4273E-09f, -7.799848E-09f, 0.02158942f, 0.9997669f), new Quaternion(2.313607E-09f, -7.748858E-10f, -0.01925842f, 0.9998146f), new Quaternion(-0.002091327f, 0.2073798f, 0.002760789f, 0.9782544f) }, new Quaternion[] { new Quaternion(-1.467912E-08f, 6.667659E-09f, -0.04146498f, 0.99914f), new Quaternion(1.327911E-08f, -7.618504E-09f, -0.006113322f, 0.9999813f), new Quaternion(-0.3676831f, 0.3100421f, 0.1039245f, 0.8705646f), new Quaternion(1.67299E-09f, -3.947202E-09f, -0.01237995f, 0.9999234f), new Quaternion(1.825179E-09f, -3.798766E-09f, -0.01925841f, 0.9998146f), new Quaternion(-0.0009547397f, 0.1243148f, 0.01200425f, 0.9921698f), new Quaternion(-2.058673E-10f, 3.274742E-10f, -0.01237995f, 0.9999234f), new Quaternion(3.4198E-09f, 1.477873E-08f, 0.01461135f, 0.9998932f), new Quaternion(0.0006127622f, 0.003308513f, -0.01102171f, 0.9999336f), new Quaternion(7.097293E-09f, 1.542719E-08f, -0.003629622f, 0.9999934f), new Quaternion(-1.494679E-09f, 1.210031E-08f, -0.0007735032f, 0.9999997f), new Quaternion(0.0008713655f, -0.08438367f, -0.010264f, 0.9963801f), new Quaternion(1.4273E-09f, 7.799848E-09f, 0.02158942f, 0.9997669f), new Quaternion(-2.313607E-09f, 7.748858E-10f, -0.01925842f, 0.9998146f), new Quaternion(0.002091327f, -0.2073798f, 0.002760789f, 0.9782544f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("チョキ", new Quaternion[] { new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f), new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(0.7708589f, -0.2672266f, 0.03713044f, 0.577051f), new Quaternion(-1.692222E-09f, 3.961451E-09f, -0.008243912f, 0.999966f), new Quaternion(-1.793476E-09f, 3.862969E-09f, -0.01279752f, 0.9999181f), new Quaternion(0.0005797216f, -0.1249451f, 0.01676745f, 0.9920218f), new Quaternion(1.370887E-10f, -2.180677E-10f, -0.008243906f, 0.999966f), new Quaternion(-3.352409E-09f, -1.485988E-08f, 0.02107204f, 0.999778f), new Quaternion(-0.0005442168f, -0.003198181f, -0.006260789f, 0.9999751f), new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f) }, new Quaternion[] { new Quaternion(-6.932151E-09f, 2.730647E-09f, -0.3665012f, 0.9304176f), new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(-0.7708589f, 0.2672266f, 0.03713044f, 0.577051f), new Quaternion(1.692222E-09f, -3.961451E-09f, -0.008243912f, 0.999966f), new Quaternion(1.793476E-09f, -3.862969E-09f, -0.01279752f, 0.9999181f), new Quaternion(-0.0005797216f, 0.1249451f, 0.01676745f, 0.9920218f), new Quaternion(-1.370887E-10f, 2.180677E-10f, -0.008243906f, 0.999966f), new Quaternion(3.352409E-09f, 1.485988E-08f, 0.02107204f, 0.999778f), new Quaternion(0.0005442168f, 0.003198181f, -0.006260789f, 0.9999751f), new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("グー", new Quaternion[] { new Quaternion(6.932151E-09f, -2.730646E-09f, -0.3665012f, 0.9304176f), new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(0.7708589f, -0.2672266f, 0.03713043f, 0.577051f), new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f) }, new Quaternion[] { new Quaternion(-6.932151E-09f, 2.730646E-09f, -0.3665012f, 0.9304176f), new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(-0.7708589f, 0.2672266f, 0.03713043f, 0.577051f), new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("指差し", new Quaternion[] { new Quaternion(6.932151E-09f, -2.730647E-09f, -0.3665012f, 0.9304176f), new Quaternion(-1.952852E-08f, -2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(0.7708589f, -0.2672266f, 0.03713044f, 0.577051f), new Quaternion(-1.730466E-09f, 3.989648E-09f, 1.928734E-09f, 1f), new Quaternion(-1.730466E-09f, 3.989648E-09f, 1.928734E-09f, 1f), new Quaternion(-0.0001667258f, -0.1261909f, 0.02624661f, 0.9916587f), new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(1.204624E-08f, 8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(-0.04368013f, 0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(-0.09800828f, 0.05454942f, -0.591058f, 0.7987923f) }, new Quaternion[] { new Quaternion(-6.932151E-09f, 2.730647E-09f, -0.3665012f, 0.9304176f), new Quaternion(1.952852E-08f, 2.699741E-08f, -0.1618618f, 0.9868135f), new Quaternion(-0.7708589f, 0.2672266f, 0.03713044f, 0.577051f), new Quaternion(1.730466E-09f, -3.989648E-09f, 1.928734E-09f, 1f), new Quaternion(1.730466E-09f, -3.989648E-09f, 1.928734E-09f, 1f), new Quaternion(0.0001667258f, 0.1261909f, 0.02624661f, 0.9916587f), new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(-1.204624E-08f, -8.771128E-09f, -0.8084095f, 0.5886205f), new Quaternion(0.04368013f, -0.00799644f, -0.6048046f, 0.7951349f), new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(0.09800828f, -0.05454942f, -0.591058f, 0.7987923f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("サムズアップ", new Quaternion[] { new Quaternion(1.472499E-08f, -1.164853E-08f, -0.0242227f, 0.9997066f), new Quaternion(2.864741E-09f, 1.253174E-08f, 0.02121386f, 0.999775f), new Quaternion(0.3078066f, -0.4021123f, 0.08737727f, 0.8578613f), new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f), new Quaternion(-0.04368013f, 0.007996442f, -0.6048046f, 0.7951349f), new Quaternion(-3.325827E-08f, 2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(4.887593E-09f, -3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(-0.09800828f, 0.05454941f, -0.591058f, 0.7987923f) }, new Quaternion[] { new Quaternion(-1.472499E-08f, 1.164853E-08f, -0.0242227f, 0.9997066f), new Quaternion(-2.864741E-09f, -1.253174E-08f, 0.02121386f, 0.999775f), new Quaternion(-0.3078066f, 0.4021123f, 0.08737727f, 0.8578613f), new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(-1.204624E-08f, -8.771129E-09f, -0.8084095f, 0.5886205f), new Quaternion(0.04368013f, -0.007996442f, -0.6048046f, 0.7951349f), new Quaternion(3.325827E-08f, -2.027481E-09f, -0.5008098f, 0.8655574f), new Quaternion(-4.887593E-09f, 3.295959E-08f, -0.819152f, 0.5735765f), new Quaternion(0.09800828f, -0.05454941f, -0.591058f, 0.7987923f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("電話サイン", new Quaternion[] { new Quaternion(1.479486E-08f, -8.781127E-09f, -0.02975121f, 0.9995574f), new Quaternion(-6.50015E-09f, 1.013705E-08f, 0.007386392f, 0.9999728f), new Quaternion(0.3369619f, -0.3488706f, 0.09791746f, 0.8689983f), new Quaternion(9.870518E-10f, 1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(-5.034789E-09f, -5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(0.04780529f, -0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(8.812074E-09f, -1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(-1.043265E-08f, 1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(-0.009090314f, -0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(-2.784401E-08f, 1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(1.204624E-08f, 8.771129E-09f, -0.8084095f, 0.5886205f), new Quaternion(-0.04368013f, 0.007996442f, -0.6048046f, 0.7951349f), new Quaternion(-8.023863E-10f, -9.682119E-09f, 0.03396483f, 0.999423f), new Quaternion(1.91605E-09f, -7.848716E-18f, -3.011494E-09f, 1f), new Quaternion(-0.0007191578f, 0.2631239f, 0.01688699f, 0.964614f) }, new Quaternion[] { new Quaternion(-1.479486E-08f, 8.781127E-09f, -0.02975121f, 0.9995574f), new Quaternion(6.50015E-09f, -1.013705E-08f, 0.007386392f, 0.9999728f), new Quaternion(-0.3369619f, 0.3488706f, 0.09791746f, 0.8689983f), new Quaternion(-9.870518E-10f, -1.579613E-09f, -0.5299194f, 0.8480481f), new Quaternion(5.034789E-09f, 5.799266E-09f, -0.819152f, 0.5735765f), new Quaternion(-0.04780529f, 0.01974053f, -0.5880075f, 0.8072002f), new Quaternion(-8.812074E-09f, 1.401741E-08f, -0.5299194f, 0.8480481f), new Quaternion(1.043265E-08f, -1.477225E-09f, -0.7992581f, 0.6009881f), new Quaternion(0.009090314f, 0.01649067f, -0.6061373f, 0.7951371f), new Quaternion(2.784401E-08f, -1.160059E-08f, -0.5224781f, 0.8526527f), new Quaternion(-1.204624E-08f, -8.771129E-09f, -0.8084095f, 0.5886205f), new Quaternion(0.04368013f, -0.007996442f, -0.6048046f, 0.7951349f), new Quaternion(8.023863E-10f, 9.682119E-09f, 0.03396483f, 0.999423f), new Quaternion(-1.91605E-09f, 7.848716E-18f, -3.011494E-09f, 1f), new Quaternion(0.0007191578f, -0.2631239f, 0.01688699f, 0.964614f) })); this.maidFingerDataList.Add(new HandSignShortcut.MaidFingerData("狐コンコン", new Quaternion[] { new Quaternion(0f, 0f, 0f, 1f), new Quaternion(-1.192093E-07f, 1.788139E-07f, -0.1335995f, 0.9910354f), new Quaternion(0.8534603f, -0.2756786f, -0.1541951f, 0.4145248f), new Quaternion(-1.490116E-09f, 4.470349E-09f, 2.048909E-09f, 1f), new Quaternion(-1.490116E-09f, 4.470349E-09f, 2.048909E-09f, 1f), new Quaternion(0.0003543059f, -0.1458506f, 0.02624475f, 0.9889584f), new Quaternion(1.291415E-08f, 1.295253E-07f, 0.01154917f, 0.9999333f), new Quaternion(1.487787E-07f, -4.237517E-08f, -0.5324296f, 0.8464743f), new Quaternion(-0.01350924f, -0.01311721f, -0.3475225f, 0.9374825f), new Quaternion(7.117304E-07f, -7.226793E-07f, -0.00915247f, 0.9999582f), new Quaternion(2.980232E-08f, 1.061708E-06f, -0.4032317f, 0.9150979f), new Quaternion(-0.1480011f, 0.04210641f, -0.4022999f, 0.9024841f), new Quaternion(-7.434641E-10f, -8.971124E-09f, 0.03396483f, 0.999423f), new Quaternion(2.048909E-09f, -8.673617E-18f, -3.166497E-09f, 1f), new Quaternion(-0.0003274615f, 0.2406898f, 0.01689912f, 0.9704549f) }, new Quaternion[] { new Quaternion(0f, 0f, 0f, 1f), new Quaternion(1.192093E-07f, -1.788139E-07f, -0.1335995f, 0.9910354f), new Quaternion(-0.8534603f, 0.2756786f, -0.1541951f, 0.4145248f), new Quaternion(1.490116E-09f, -4.470349E-09f, 2.048909E-09f, 1f), new Quaternion(1.490116E-09f, -4.470349E-09f, 2.048909E-09f, 1f), new Quaternion(-0.0003543059f, 0.1458506f, 0.02624475f, 0.9889584f), new Quaternion(-1.291415E-08f, -1.295253E-07f, 0.01154917f, 0.9999333f), new Quaternion(-1.487787E-07f, 4.237517E-08f, -0.5324296f, 0.8464743f), new Quaternion(0.01350924f, 0.01311721f, -0.3475225f, 0.9374825f), new Quaternion(-7.117304E-07f, 7.226793E-07f, -0.00915247f, 0.9999582f), new Quaternion(-2.980232E-08f, -1.061708E-06f, -0.4032317f, 0.9150979f), new Quaternion(0.1480011f, -0.04210641f, -0.4022999f, 0.9024841f), new Quaternion(7.434641E-10f, 8.971124E-09f, 0.03396483f, 0.999423f), new Quaternion(-2.048909E-09f, 8.673617E-18f, -3.166497E-09f, 1f), new Quaternion(0.0003274615f, -0.2406898f, 0.01689912f, 0.9704549f) })); } public List maidFingerDataList { get { return this.MaidFingerDataList; } set { this.MaidFingerDataList = value; } } private const string CONF_NAME = "MaidFingerDataList.json"; [SerializeField] private int m_nVersion = 1570; [SerializeField] private List MaidFingerDataList = new List(); } [Serializable] public class MaidFingerData { public MaidFingerData(string name, Quaternion[] leftFingerData, Quaternion[] rightFingerData) { if (leftFingerData.Length != 15) { string message = "[HandSignShortcut.MaidFingerData] 項目「" + name + "」の左手指データ数が不正です"; Debug.LogError(message); NDebug.Assert(message, false); } if (rightFingerData.Length != 15) { string message2 = "[HandSignShortcut.MaidFingerData] 項目「" + name + "」の右手指データ数が不正です"; Debug.LogError(message2); NDebug.Assert(message2, false); } this.name = name; this.leftFingerData = leftFingerData; this.rightFingerData = rightFingerData; } public MaidFingerData() { } public string name { get { return this.m_Name; } set { this.m_Name = value; } } public Quaternion[] leftFingerData { get { return this.m_LeftFingerRotArray; } set { this.m_LeftFingerRotArray = value; } } public Quaternion[] rightFingerData { get { return this.m_RightFingerRotArray; } set { this.m_RightFingerRotArray = value; } } public void GetMaidFingerData(Maid maid) { this.leftFingerData = new Quaternion[HandSignShortcut.strHandBoneNameL.Length]; this.rightFingerData = new Quaternion[HandSignShortcut.strHandBoneNameR.Length]; Transform t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true); string[] array = HandSignShortcut.strHandBoneNameL; for (int i = 0; i < array.Length; i++) { this.leftFingerData[i] = CMT.SearchObjName(t, array[i], true).localRotation; } t = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true); array = HandSignShortcut.strHandBoneNameR; for (int j = 0; j < array.Length; j++) { this.rightFingerData[j] = CMT.SearchObjName(t, array[j], true).localRotation; } } public void ApplyMaidFingerData(Maid maid) { Transform transform = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 L Hand", true); string[] array = HandSignShortcut.strHandBoneNameL; for (int i = 0; i < array.Length; i++) { CMT.SearchObjName(maid.body0.m_Bones.transform, array[i], true).localRotation = this.leftFingerData[i]; } transform = CMT.SearchObjName(maid.body0.m_Bones.transform, "Bip01 R Hand", true); array = HandSignShortcut.strHandBoneNameR; for (int j = 0; j < array.Length; j++) { CMT.SearchObjName(maid.body0.m_Bones.transform, array[j], true).localRotation = this.rightFingerData[j]; } } public static HandSignShortcut.MaidFingerData Get(string name) { HandSignShortcut.MaidFingerData.CreateDataDic(); HandSignShortcut.MaidFingerData result; HandSignShortcut.MaidFingerData.m_DataDic.TryGetValue(name, out result); return result; } public static void Add(HandSignShortcut.MaidFingerData data) { HandSignShortcut.MaidFingerData.CreateDataDic(); if (data == null) { Debug.Log("[HandSignShortcut.MaidFingerData] 登録するデータが null でした"); return; } if (HandSignShortcut.MaidFingerData.m_DataDic.ContainsKey(data.name)) { Debug.Log("[HandSignShortcut.MaidFingerData] 既に「" + data.name + "」が登録されています"); return; } HandSignShortcut.MaidFingerData.m_DataDic.Add(data.name, data); HandSignShortcut.config.maidFingerDataList.Add(data); } private static void CreateDataDic() { if (HandSignShortcut.MaidFingerData.m_DataDic != null) { return; } HandSignShortcut.MaidFingerData.m_DataDic = new Dictionary(); foreach (HandSignShortcut.MaidFingerData maidFingerData in HandSignShortcut.config.maidFingerDataList) { HandSignShortcut.MaidFingerData.m_DataDic.Add(maidFingerData.name, maidFingerData); } } [SerializeField] private string m_Name; [SerializeField] private Quaternion[] m_LeftFingerRotArray; [SerializeField] private Quaternion[] m_RightFingerRotArray; private static Dictionary m_DataDic; } private class ItemData : MonoBehaviour { public HandSignShortcut.MaidFingerData data { get { return this.m_Data; } set { this.m_Data = value; this.UpdateText(); } } public Text text { get; set; } private Localize localize { get; set; } public void SetLocalizeTerm(string key) { Localize localize2; if (this.localize == null) { Localize localize = this.text.gameObject.AddComponent(); this.localize = localize; localize2 = localize; } else { localize2 = this.localize; } Utility.SetLocalizeTerm(localize2, key, false); } private void UpdateText() { if (this.text == null) { return; } if (this.m_Data == null) { this.text.text = "自由モード"; this.SetLocalizeTerm("VAS/自由モード"); } else { this.text.text = this.m_Data.name; this.SetLocalizeTerm("VAS/" + this.m_Data.name); } } private HandSignShortcut.MaidFingerData m_Data; } private enum Finger { Thumb, Index, Middle, Ring, Little, Max } }