123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- using System;
- using UnityEngine;
- public class PhotoFaceDataShortcutParent : MonoBehaviour
- {
- public PhotoFaceDataShortcut handUI { get; private set; }
- private KeyboardShortcutManager keyboardShortcut { get; set; }
- public bool isLeftHand { get; private set; }
- public bool isEnableHandUI
- {
- get
- {
- return this.handUI.gameObject.activeSelf;
- }
- set
- {
- if (this.handUI == null || this.handUI.gameObject == null)
- {
- return;
- }
- if (this.handUI.gameObject.activeSelf != value)
- {
- this.handUI.gameObject.SetActive(value);
- }
- }
- }
- public bool isEnableKeyboardShortcut
- {
- get
- {
- return this.keyboardShortcut.gameObject.activeSelf;
- }
- set
- {
- if (this.keyboardShortcut == null || this.keyboardShortcut.gameObject == null)
- {
- return;
- }
- if (this.keyboardShortcut.gameObject.activeSelf != value)
- {
- this.keyboardShortcut.gameObject.SetActive(value);
- }
- }
- }
- public void Init(bool isLeftHand)
- {
- this.isLeftHand = isLeftHand;
- this.SetupPhotoFaceDataShortcut();
- this.SetupKeyboardShortcutManager();
- }
- private void SetupPhotoFaceDataShortcut()
- {
- string text = "OVR/CircleCommandUI/PhotoFaceDataShortcut(Cotroller)";
- GameObject gameObject = Resources.Load<GameObject>(text);
- if (gameObject == null)
- {
- NDebug.Assert("[PhotoFaceDataShortcutParent] " + text + "\nプレハブが見つかりません", false);
- }
- GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject);
- this.handUI = gameObject2.GetComponent<PhotoFaceDataShortcut>();
- this.handUI.Init(this.isLeftHand);
- this.handUI.CreateItemList(8);
- 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;
- }
- private void SetupKeyboardShortcutManager()
- {
- if (!this.isLeftHand)
- {
- return;
- }
- this.keyboardShortcut = new GameObject("Keyboard Shortcut").AddComponent<KeyboardShortcutManager>();
- this.keyboardShortcut.transform.SetParent(base.transform, false);
- for (int i = 0; i < this.handUI.itemDataList.Count; i++)
- {
- int index = i;
- this.keyboardShortcut.AddKeyData(base.gameObject, KeyCode.Alpha1 + i, delegate
- {
- this.OnKeyDownShortcut(this.handUI, index);
- }, delegate
- {
- this.OnKeyStayShortcut(this.handUI, index);
- }, delegate
- {
- this.OnKeyUpShortcut(this.handUI, index);
- });
- }
- }
- private void OnKeyDownShortcut(PhotoFaceDataShortcut shortcutController, int index)
- {
- if (ControllerShortcutSettingData.config.isDirectMode)
- {
- if (shortcutController.itemDataList.Count <= index)
- {
- return;
- }
- PhotoFaceDataShortcut.ItemData itemData = shortcutController.itemDataList[index];
- if (itemData == null || itemData.data == null)
- {
- return;
- }
- shortcutController.Emulate(itemData);
- }
- }
- private void OnKeyStayShortcut(PhotoFaceDataShortcut shortcutController, int index)
- {
- }
- private void OnKeyUpShortcut(PhotoFaceDataShortcut shortcutController, int index)
- {
- if (!ControllerShortcutSettingData.config.isDirectMode)
- {
- if (shortcutController.itemDataList.Count <= index)
- {
- Debug.LogWarning("[表情ショートカット]コントローラのショートカット範囲外のインデックスが指定された。");
- return;
- }
- PhotoFaceDataShortcut.ItemData itemData = shortcutController.itemDataList[index];
- if (itemData == null || itemData.data == null)
- {
- Debug.Log("[表情ショートカット]コントローラのショートカット対応のキーが押されたが、表情データはnullだった。");
- return;
- }
- shortcutController.Emulate(itemData);
- }
- else
- {
- foreach (PhotoFaceDataShortcut.ItemData itemData2 in shortcutController.itemDataList)
- {
- if (!(itemData2 == null) && itemData2.data != null)
- {
- shortcutController.Emulate(itemData2);
- break;
- }
- }
- }
- }
- private void OnApplicationQuit()
- {
- this.m_IsQuitting = true;
- }
- private void OnDestroy()
- {
- if (this.m_IsQuitting)
- {
- return;
- }
- if (this.handUI != null && this.handUI.gameObject != null)
- {
- UnityEngine.Object.Destroy(this.handUI.gameObject);
- Debug.Log("[PhotoFaceDataShortcutParent] コントローラについているUIを破棄しました");
- }
- if (this.keyboardShortcut != null && this.keyboardShortcut.gameObject != null)
- {
- UnityEngine.Object.Destroy(this.keyboardShortcut.gameObject);
- Debug.Log("[PhotoFaceDataShortcutParent] キーボード入力のショートカット管理クラスを破棄しました");
- }
- }
- private bool m_IsQuitting;
- }
|