using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class OtherCommandShortcut : MonoBehaviour { 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("初期化:様々なショートカットを行う手元UI"); this.controller = ((!isLeftHand) ? GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller : GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller); this.InitCircleUI(); } 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.m_ItemList = new List>>(); this.m_ItemList.Add(new KeyValuePair>("撮影", delegate(OtherCommandShortcut.ItemData itemData) { GameMain.Instance.OvrIK.SelfShotCam(); })); this.m_ItemList.Add(new KeyValuePair>((!GameMain.Instance.OvrIK.EyeToCam) ? "カメラ視線OFF" : "カメラ視線ON", delegate(OtherCommandShortcut.ItemData itemData) { GameMain.Instance.OvrIK.EyeToCam = !GameMain.Instance.OvrIK.EyeToCam; if (GameMain.Instance.OvrIK.EyeToCam) { itemData.text.text = "カメラ視線ON"; } else { itemData.text.text = "カメラ視線OFF"; } })); this.CreateItemList(); 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) ? "右" : "左"); } private void CreateItemList() { CircleCommandUI circleCommandUI = this.circleList.circleCommandUI; circleCommandUI.Show(this.m_ItemList.Count, delegate(int index, Transform trans) { Text componentInChildren = trans.GetComponentInChildren(); trans.localScale = Vector3.one * 0.5f; OtherCommandShortcut.ItemData itemData = trans.gameObject.AddComponent(); itemData.text = componentInChildren; KeyValuePair> keyValuePair = this.m_ItemList[index]; itemData.text.text = keyValuePair.Key; itemData.onDecide = keyValuePair.Value; }); } 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(); } 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); } OtherCommandShortcut.ItemData component = selectItem.GetComponent(); if (component != null && component.onDecide != null) { component.onDecide(component); } } 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("[OtherCommandShortcut] コントローラについているUIを破棄しました"); } } [SerializeField] private CircleListSelectUI m_CircleList; private bool m_IsLeftHand; private AVRController m_Controller; private List>> m_ItemList; private bool m_IsQuitting; private class ItemData : MonoBehaviour { public Action onDecide { get; set; } public Text text { get; set; } } }