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(text); if (gameObject == null) { NDebug.Assert("[PhotoFaceDataShortcutParent] " + text + "\nプレハブが見つかりません", false); } GameObject gameObject2 = UnityEngine.Object.Instantiate(gameObject); this.handUI = gameObject2.GetComponent(); 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(); 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; }