123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using Kasizuki;
- using UnityEngine;
- using wf;
- public class VRFaceShortcutConfig : MonoBehaviour
- {
- public void CacheItemTemplate<T>(string path) where T : VRFaceShortcutConfig.Item
- {
- Transform childObject = VRFaceShortcutConfig.GetChildObject<Transform>(this.m_Grid.gameObject, path);
- T t = childObject.gameObject.AddComponent<T>();
- Type typeFromHandle = typeof(T);
- this.m_ItemTemplateList.Add(typeFromHandle, t);
- childObject.gameObject.SetActive(false);
- }
- public T CreateItem<T>(string itemLabel) where T : VRFaceShortcutConfig.Item
- {
- if (this.m_ItemDic.ContainsKey(itemLabel))
- {
- string message = "[VRFaceShortcutConfig] 既に「" + itemLabel + "」という項目が存在しています";
- Debug.LogError(message);
- NDebug.Assert(message, false);
- }
- VRFaceShortcutConfig.Item item;
- if (!this.m_ItemTemplateList.TryGetValue(typeof(T), out item))
- {
- string message2 = "[VRFaceShortcutConfig] " + typeof(T).ToString() + "型のUI項目はキャッシュされていません";
- Debug.LogError(message2);
- NDebug.Assert(message2, false);
- }
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(item.gameObject);
- gameObject.transform.SetParent(this.m_Grid.transform, false);
- T component = gameObject.GetComponent<T>();
- component.gameObject.SetActive(true);
- component.label.text = itemLabel;
- this.m_ItemDic.Add(itemLabel, component);
- return component;
- }
- private void Awake()
- {
- this.CacheItemTemplate<VRFaceShortcutConfig.ItemSlider>("temp slider");
- this.CacheItemTemplate<VRFaceShortcutConfig.ItemSelectButton>("temp select");
- this.CacheItemTemplate<VRFaceShortcutConfig.ParentMultiButton>("temp multi select");
- this.CreateDefaultItems();
- this.CreateViveItems();
- NGUIWindow fadeWindowThis = this.m_FadeWindowThis;
- fadeWindowThis.OnClose = (Action)Delegate.Combine(fadeWindowThis.OnClose, new Action(delegate()
- {
- ControllerShortcutSettingData.config.Write();
- }));
- }
- private void CreateDefaultItems()
- {
- OVRLipSync.VariableData variable = GameMain.Instance.LipSyncMgr.Variable;
- VRFaceShortcutConfig.ItemSlider itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("リップシンク:マイク感度");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/リップシンク:マイク感度");
- itemSlider.min = 0f;
- itemSlider.max = 10f;
- itemSlider.Set(variable.MicSensitivity);
- itemSlider.onValueChanged = delegate(float value)
- {
- GameMain.Instance.LipSyncMgr.Variable.MicSensitivity = value;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("リップシンク:自分の声の大きさ");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/リップシンク:自分の声の大きさ");
- itemSlider.min = 0f;
- itemSlider.max = 10f;
- itemSlider.Set(variable.MicVolume);
- itemSlider.onValueChanged = delegate(float value)
- {
- GameMain.Instance.LipSyncMgr.Variable.MicVolume = value;
- };
- VRFaceShortcutConfig.ItemSelectButton itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("リップシンク:ミュートにする");
- Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/リップシンク:ミュートにする");
- itemSelectButton.textLeft.text = "ON";
- itemSelectButton.textRight.text = "OFF";
- itemSelectButton.Set(variable.Mute);
- itemSelectButton.onClickIsLeft = delegate(bool isLeft)
- {
- variable.Mute = isLeft;
- };
- itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("手元ショートカット:表情の変化");
- Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/手元ショートカット:表情の変化");
- itemSelectButton.textLeft.text = "即座に変更する";
- Utility.SetLocalizeTerm(itemSelectButton.localizeLeft, "VAS/即座に変更する");
- itemSelectButton.textRight.text = "選択して決定する";
- Utility.SetLocalizeTerm(itemSelectButton.localizeRight, "VAS/選択して決定する");
- itemSelectButton.Set(ControllerShortcutSettingData.config.isDirectMode);
- itemSelectButton.onClickIsLeft = delegate(bool isLeft)
- {
- ControllerShortcutSettingData.config.isDirectMode = isLeft;
- };
- itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("手元ショートカット:手元のUI");
- Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/手元ショートカット:手元のUI");
- itemSelectButton.textLeft.text = "常に表示する";
- Utility.SetLocalizeTerm(itemSelectButton.localizeLeft, "VAS/常に表示する");
- itemSelectButton.textRight.text = "決定時に隠す";
- Utility.SetLocalizeTerm(itemSelectButton.localizeRight, "VAS/決定時に隠す");
- itemSelectButton.Set(ControllerShortcutSettingData.config.isEveryShowMode);
- itemSelectButton.onClickIsLeft = delegate(bool isLeft)
- {
- ControllerShortcutSettingData.config.isEveryShowMode = isLeft;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体向きの頭への追従");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体向きの頭への追従");
- itemSlider.min = 0f;
- itemSlider.max = 1f;
- itemSlider.Set(ControllerShortcutSettingData.config.maintainPelvisPosition);
- itemSlider.onValueChanged = delegate(float value)
- {
- ControllerShortcutSettingData.config.maintainPelvisPosition = value;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体位置の頭への追従");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体位置の頭への追従");
- itemSlider.min = 0f;
- itemSlider.max = 1f;
- itemSlider.Set(ControllerShortcutSettingData.config.bodyPosStiffness);
- itemSlider.onValueChanged = delegate(float value)
- {
- ControllerShortcutSettingData.config.bodyPosStiffness = value;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体回転の頭への追従");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体回転の頭への追従");
- itemSlider.min = 0f;
- itemSlider.max = 1f;
- itemSlider.Set(ControllerShortcutSettingData.config.bodyRotStiffness);
- itemSlider.onValueChanged = delegate(float value)
- {
- ControllerShortcutSettingData.config.bodyRotStiffness = value;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("胸部回転の頭への追従");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/胸部回転の頭への追従");
- itemSlider.min = 0f;
- itemSlider.max = 1f;
- itemSlider.Set(ControllerShortcutSettingData.config.chestRotationWeight);
- itemSlider.onValueChanged = delegate(float value)
- {
- ControllerShortcutSettingData.config.chestRotationWeight = value;
- };
- itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("カメラの画角");
- Utility.SetLocalizeTerm(itemSlider.localize, "VAS/カメラの画角");
- itemSlider.min = 0f;
- itemSlider.max = 1f;
- itemSlider.Set(ControllerShortcutSettingData.config.selfCameraFOV);
- itemSlider.onValueChanged = delegate(float value)
- {
- ControllerShortcutSettingData.config.selfCameraFOV = value;
- };
- VRFaceShortcutConfig.ParentMultiButton parentMultiButton = this.CreateItem<VRFaceShortcutConfig.ParentMultiButton>("手のスカートへの当たり判定\n※VR CONFIGより優先されます。");
- Utility.SetLocalizeTerm(parentMultiButton.localize, "VAS/手のスカートへの当たり判定");
- parentMultiButton.textRight.text = "OFF";
- parentMultiButton.textLeft.text = "常時ON";
- Utility.SetLocalizeTerm(parentMultiButton.localizeLeft, "VAS/常時ON");
- parentMultiButton.textCenter.text = "握時ON";
- Utility.SetLocalizeTerm(parentMultiButton.localizeCenter, "VAS/握時ON");
- if (GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF)
- {
- parentMultiButton.Set(0);
- }
- else if (GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.ON)
- {
- parentMultiButton.Set(1);
- }
- else
- {
- parentMultiButton.Set(2);
- }
- parentMultiButton.onClick = delegate(int index)
- {
- CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT ovrHandHitToSkirtVAS;
- if (index == 0)
- {
- ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF;
- }
- else if (index == 1)
- {
- ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.ON;
- }
- else
- {
- ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.GRAB;
- }
- GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS = ovrHandHitToSkirtVAS;
- };
- }
- private void CreateViveItems()
- {
- if (GameMain.Instance.VRDeviceTypeID != GameMain.VRDeviceType.VIVE)
- {
- return;
- }
- VRFaceShortcutConfig.ItemSelectButton itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("一番上にあるトラッカーを\n頭トラッキングに利用");
- Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/一番上にあるトラッカーを頭トラッキングに利用");
- itemSelectButton.textLeft.text = "ON";
- itemSelectButton.textRight.text = "OFF";
- itemSelectButton.Set(ControllerShortcutSettingData.config.use1TrackerForHead);
- itemSelectButton.onClickIsLeft = delegate(bool isLeft)
- {
- ControllerShortcutSettingData.config.use1TrackerForHead = isLeft;
- this.SetActiveItem("2つめと3つめのトラッカーを\n足トラッキングに利用", isLeft, false);
- this.SetActiveItem("1つめと2つめのトラッカーを\n足トラッキングに利用", !isLeft, false);
- };
- }
- private void SetActiveItem(string itemKey, bool isActive, bool isEnableError = true)
- {
- VRFaceShortcutConfig.Item item;
- if (!this.m_ItemDic.TryGetValue(itemKey, out item))
- {
- if (isEnableError)
- {
- string message = "[VRFaceShortcutConfig] コンフィグ項目に「" + itemKey + "」は存在しません";
- Debug.LogError(message);
- NDebug.Assert(message, false);
- }
- return;
- }
- if (item.gameObject.activeSelf != isActive)
- {
- item.gameObject.SetActive(isActive);
- Utility.SetLocalizeTerm(item.localize, "VAS/" + itemKey);
- this.m_IsUpdateReposition = true;
- }
- }
- private void LateUpdate()
- {
- if (this.m_IsUpdateReposition)
- {
- this.m_IsUpdateReposition = false;
- this.m_Grid.Reposition();
- this.m_ScrollView.UpdatePosition();
- }
- }
- private static T GetChildObject<T>(GameObject gameObject, string path)
- {
- GameObject childObject = UTY.GetChildObject(gameObject, path, false);
- if (childObject == null)
- {
- string message = string.Concat(new string[]
- {
- "[VRFaceShortcutConfig] ",
- gameObject.name,
- "/",
- path,
- "が見つかりませんでした"
- });
- NDebug.Assert(message, false);
- Debug.LogError(message);
- }
- T component = childObject.GetComponent<T>();
- if (component == null)
- {
- string message2 = string.Concat(new object[]
- {
- "[VRFaceShortcutConfig] ",
- gameObject.name,
- "/",
- path,
- "に、\n",
- typeof(T),
- "のコンポーネントがありませんでした"
- });
- NDebug.Assert(message2, false);
- Debug.LogError(message2);
- }
- return component;
- }
- [SerializeField]
- [Range(0.001f, 1f)]
- private float m_FadeSpeed = 0.25f;
- [SerializeField]
- private NGUIWindow m_FadeWindowThis;
- [SerializeField]
- private UIScrollView m_ScrollView;
- [SerializeField]
- private UIGrid m_Grid;
- private Dictionary<Type, VRFaceShortcutConfig.Item> m_ItemTemplateList = new Dictionary<Type, VRFaceShortcutConfig.Item>();
- private Dictionary<string, VRFaceShortcutConfig.Item> m_ItemDic = new Dictionary<string, VRFaceShortcutConfig.Item>();
- private bool m_IsUpdateReposition;
- public abstract class Item : MonoBehaviour
- {
- public UILabel label
- {
- get
- {
- return this.m_Label;
- }
- set
- {
- this.m_Label = value;
- }
- }
- public Localize localize { get; private set; }
- protected virtual void Awake()
- {
- this.m_Label = VRFaceShortcutConfig.GetChildObject<UILabel>(base.gameObject, "name");
- this.localize = this.m_Label.gameObject.AddComponent<Localize>();
- }
- public abstract void Set(object value);
- private UILabel m_Label;
- }
- public class ItemSlider : VRFaceShortcutConfig.Item
- {
- public UISlider slider
- {
- get
- {
- return this.m_Slider;
- }
- private set
- {
- this.m_Slider = value;
- }
- }
- public float normalizedValue
- {
- get
- {
- return this.slider.value;
- }
- set
- {
- this.slider.value = value;
- }
- }
- public float min
- {
- get
- {
- return this.m_Min;
- }
- set
- {
- this.m_Min = value;
- }
- }
- public float max
- {
- get
- {
- return this.m_Max;
- }
- set
- {
- this.m_Max = value;
- }
- }
- public float value
- {
- get
- {
- return Mathf.Lerp(this.min, this.max, this.normalizedValue);
- }
- set
- {
- this.normalizedValue = Mathf.InverseLerp(this.min, this.max, value);
- }
- }
- public Action<float> onValueChanged { get; set; }
- public Action onDragFinished { get; set; }
- protected override void Awake()
- {
- base.Awake();
- this.slider = VRFaceShortcutConfig.GetChildObject<UISlider>(base.gameObject, "slider");
- EventDelegate.Add(this.slider.onChange, delegate()
- {
- if (this.onValueChanged != null)
- {
- this.onValueChanged(this.value);
- }
- });
- UISlider slider = this.slider;
- slider.onDragFinished = (UIProgressBar.OnDragFinished)Delegate.Combine(slider.onDragFinished, new UIProgressBar.OnDragFinished(delegate()
- {
- if (this.onDragFinished != null)
- {
- this.onDragFinished();
- }
- }));
- }
- public override void Set(object value)
- {
- this.value = (float)value;
- }
- private UISlider m_Slider;
- private float m_Min;
- private float m_Max = 1f;
- }
- public class ItemSelectButton : VRFaceShortcutConfig.Item
- {
- public UIButton buttonRight
- {
- get
- {
- return this.m_ButtonRight;
- }
- private set
- {
- this.m_ButtonRight = value;
- }
- }
- public UIButton buttonLeft
- {
- get
- {
- return this.m_ButtonLeft;
- }
- private set
- {
- this.m_ButtonLeft = value;
- }
- }
- public UILabel textRight
- {
- get
- {
- return this.m_TextRight;
- }
- private set
- {
- this.m_TextRight = value;
- }
- }
- public UILabel textLeft
- {
- get
- {
- return this.m_TextLeft;
- }
- private set
- {
- this.m_TextLeft = value;
- }
- }
- public Localize localizeRight { get; private set; }
- public Localize localizeLeft { get; private set; }
- public Action<bool> onClickIsLeft { get; set; }
- protected override void Awake()
- {
- base.Awake();
- this.buttonRight = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button right");
- this.buttonLeft = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button left");
- this.textRight = this.buttonRight.GetComponentInChildren<UILabel>();
- this.textLeft = this.buttonLeft.GetComponentInChildren<UILabel>();
- this.localizeRight = this.textRight.gameObject.AddComponent<Localize>();
- this.localizeLeft = this.textLeft.gameObject.AddComponent<Localize>();
- EventDelegate.Add(this.buttonRight.onClick, delegate()
- {
- if (this.onClickIsLeft != null)
- {
- this.onClickIsLeft(false);
- }
- this.OnClickButton(false);
- });
- EventDelegate.Add(this.buttonLeft.onClick, delegate()
- {
- if (this.onClickIsLeft != null)
- {
- this.onClickIsLeft(true);
- }
- this.OnClickButton(true);
- });
- }
- private void OnClickButton(bool isLeft)
- {
- this.buttonLeft.defaultColor = ((!isLeft) ? VRFaceShortcutConfig.ItemSelectButton.ButtonDefaultColor : VRFaceShortcutConfig.ItemSelectButton.ButtonClickedColor);
- this.buttonRight.defaultColor = (isLeft ? VRFaceShortcutConfig.ItemSelectButton.ButtonDefaultColor : VRFaceShortcutConfig.ItemSelectButton.ButtonClickedColor);
- }
- public void Emulate(bool isLeft)
- {
- UIButton uibutton = (!isLeft) ? this.buttonRight : this.buttonLeft;
- EventDelegate.Execute(uibutton.onClick);
- }
- public override void Set(object value)
- {
- this.Emulate((bool)value);
- }
- private static Color ButtonDefaultColor = new Color(1f, 1f, 1f, 0.5f);
- private static Color ButtonClickedColor = Color.white;
- private UIButton m_ButtonRight;
- private UIButton m_ButtonLeft;
- private UILabel m_TextRight;
- private UILabel m_TextLeft;
- }
- private class ParentMultiButton : VRFaceShortcutConfig.Item
- {
- public UIButton buttonRight
- {
- get
- {
- return this.m_ButtonRight;
- }
- private set
- {
- this.m_ButtonRight = value;
- }
- }
- public UIButton buttonLeft
- {
- get
- {
- return this.m_ButtonLeft;
- }
- private set
- {
- this.m_ButtonLeft = value;
- }
- }
- public UIButton buttonCenter
- {
- get
- {
- return this.m_ButtonCenter;
- }
- private set
- {
- this.m_ButtonCenter = value;
- }
- }
- public UILabel textRight
- {
- get
- {
- return this.m_TextRight;
- }
- private set
- {
- this.m_TextRight = value;
- }
- }
- public UILabel textLeft
- {
- get
- {
- return this.m_TextLeft;
- }
- private set
- {
- this.m_TextLeft = value;
- }
- }
- public UILabel textCenter
- {
- get
- {
- return this.m_TextCenter;
- }
- private set
- {
- this.m_TextCenter = value;
- }
- }
- public Localize localizeRight { get; private set; }
- public Localize localizeLeft { get; private set; }
- public Localize localizeCenter { get; private set; }
- public Action<int> onClick { get; set; }
- protected override void Awake()
- {
- base.Awake();
- this.buttonRight = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button right");
- this.buttonLeft = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button left");
- this.buttonCenter = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button center");
- this.textRight = this.buttonRight.GetComponentInChildren<UILabel>();
- this.textLeft = this.buttonLeft.GetComponentInChildren<UILabel>();
- this.textCenter = this.buttonCenter.GetComponentInChildren<UILabel>();
- this.localizeRight = this.textRight.gameObject.AddComponent<Localize>();
- this.localizeLeft = this.textLeft.gameObject.AddComponent<Localize>();
- this.localizeCenter = this.textCenter.gameObject.AddComponent<Localize>();
- EventDelegate.Add(this.buttonRight.onClick, delegate()
- {
- if (this.onClick != null)
- {
- this.onClick(0);
- }
- this.OnClickButton(0);
- });
- EventDelegate.Add(this.buttonLeft.onClick, delegate()
- {
- if (this.onClick != null)
- {
- this.onClick(1);
- }
- this.OnClickButton(1);
- });
- EventDelegate.Add(this.buttonCenter.onClick, delegate()
- {
- if (this.onClick != null)
- {
- this.onClick(2);
- }
- this.OnClickButton(2);
- });
- }
- private void OnClickButton(int index)
- {
- this.buttonRight.defaultColor = ((index != 0) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
- this.buttonLeft.defaultColor = ((index != 1) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
- this.buttonCenter.defaultColor = ((index != 2) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
- }
- public void Emulate(int index)
- {
- UIButton uibutton;
- if (index == 0)
- {
- uibutton = this.buttonRight;
- }
- else if (index == 1)
- {
- uibutton = this.buttonLeft;
- }
- else
- {
- uibutton = this.buttonCenter;
- }
- EventDelegate.Execute(uibutton.onClick);
- }
- public override void Set(object value)
- {
- this.Emulate((int)value);
- }
- private static Color ButtonDefaultColor = new Color(1f, 1f, 1f, 0.5f);
- private static Color ButtonClickedColor = Color.white;
- private UIButton m_ButtonRight;
- private UIButton m_ButtonLeft;
- private UIButton m_ButtonCenter;
- private UILabel m_TextRight;
- private UILabel m_TextLeft;
- private UILabel m_TextCenter;
- }
- }
|