123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- using wf;
- 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<GameObject>(text);
- if (gameObject == null)
- {
- NDebug.Assert("[HandSignShortcut] " + text + "\nプレハブが見つかりません", false);
- }
- GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(gameObject);
- this.circleList = gameObject2.GetComponent<CircleListSelectUI>();
- this.m_ItemList = new List<KeyValuePair<string, Action<OtherCommandShortcut.ItemData>>>();
- this.m_ItemList.Add(new KeyValuePair<string, Action<OtherCommandShortcut.ItemData>>("撮影", delegate(OtherCommandShortcut.ItemData itemData)
- {
- GameMain.Instance.OvrIK.SelfShotCam();
- }));
- this.m_ItemList.Add(new KeyValuePair<string, Action<OtherCommandShortcut.ItemData>>((!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";
- }
- itemData.SetLocalizeTerm("VAS/" + itemData.text.text);
- }));
- this.CreateItemList();
- CircleCommandUI circleCommandUI = this.circleList.circleCommandUI;
- circleCommandUI.onSelect.AddListener(new UnityAction<GameObject>(this.OnSelectItem));
- circleCommandUI.onDeselect.AddListener(new UnityAction<GameObject>(this.OnDeselectItem));
- circleCommandUI.onDecide.AddListener(new UnityAction<GameObject>(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>().text = ((!this.IsLeftHand) ? "右" : "左");
- Localize localize = childObject.AddComponent<Localize>();
- if (this.IsLeftHand)
- {
- Utility.SetLocalizeTerm(localize, "System/左", false);
- }
- else
- {
- Utility.SetLocalizeTerm(localize, "System/右", false);
- }
- }
- private void CreateItemList()
- {
- CircleCommandUI circleCommandUI = this.circleList.circleCommandUI;
- circleCommandUI.Show<Transform>(this.m_ItemList.Count, delegate(int index, Transform trans)
- {
- Text componentInChildren = trans.GetComponentInChildren<Text>();
- trans.localScale = Vector3.one * 0.5f;
- OtherCommandShortcut.ItemData itemData = trans.gameObject.AddComponent<OtherCommandShortcut.ItemData>();
- itemData.text = componentInChildren;
- KeyValuePair<string, Action<OtherCommandShortcut.ItemData>> keyValuePair = this.m_ItemList[index];
- itemData.text.text = keyValuePair.Key;
- itemData.onDecide = keyValuePair.Value;
- itemData.SetLocalizeTerm("VAS/" + itemData.text.text);
- });
- }
- private void OnSelectItem(GameObject item)
- {
- if (item == null)
- {
- return;
- }
- Graphic component = item.GetComponent<Graphic>();
- 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<Graphic>();
- 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<OtherCommandShortcut.ItemData>();
- 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<KeyValuePair<string, Action<OtherCommandShortcut.ItemData>>> m_ItemList;
- private bool m_IsQuitting;
- private class ItemData : MonoBehaviour
- {
- public Action<OtherCommandShortcut.ItemData> onDecide { get; set; }
- 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<Localize>();
- this.localize = localize;
- localize2 = localize;
- }
- else
- {
- localize2 = this.localize;
- }
- Utility.SetLocalizeTerm(localize2, key, false);
- }
- }
- }
|