VRFaceShortcutConfig.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using Kasizuki;
  5. using UnityEngine;
  6. using wf;
  7. public class VRFaceShortcutConfig : MonoBehaviour
  8. {
  9. public void CacheItemTemplate<T>(string path) where T : VRFaceShortcutConfig.Item
  10. {
  11. Transform childObject = VRFaceShortcutConfig.GetChildObject<Transform>(this.m_Grid.gameObject, path);
  12. T t = childObject.gameObject.AddComponent<T>();
  13. Type typeFromHandle = typeof(T);
  14. this.m_ItemTemplateList.Add(typeFromHandle, t);
  15. childObject.gameObject.SetActive(false);
  16. }
  17. public T CreateItem<T>(string itemLabel) where T : VRFaceShortcutConfig.Item
  18. {
  19. if (this.m_ItemDic.ContainsKey(itemLabel))
  20. {
  21. string message = "[VRFaceShortcutConfig] 既に「" + itemLabel + "」という項目が存在しています";
  22. Debug.LogError(message);
  23. NDebug.Assert(message, false);
  24. }
  25. VRFaceShortcutConfig.Item item;
  26. if (!this.m_ItemTemplateList.TryGetValue(typeof(T), out item))
  27. {
  28. string message2 = "[VRFaceShortcutConfig] " + typeof(T).ToString() + "型のUI項目はキャッシュされていません";
  29. Debug.LogError(message2);
  30. NDebug.Assert(message2, false);
  31. }
  32. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(item.gameObject);
  33. gameObject.transform.SetParent(this.m_Grid.transform, false);
  34. T component = gameObject.GetComponent<T>();
  35. component.gameObject.SetActive(true);
  36. component.label.text = itemLabel;
  37. this.m_ItemDic.Add(itemLabel, component);
  38. return component;
  39. }
  40. private void Awake()
  41. {
  42. this.CacheItemTemplate<VRFaceShortcutConfig.ItemSlider>("temp slider");
  43. this.CacheItemTemplate<VRFaceShortcutConfig.ItemSelectButton>("temp select");
  44. this.CacheItemTemplate<VRFaceShortcutConfig.ParentMultiButton>("temp multi select");
  45. this.CreateDefaultItems();
  46. this.CreateViveItems();
  47. NGUIWindow fadeWindowThis = this.m_FadeWindowThis;
  48. fadeWindowThis.OnClose = (Action)Delegate.Combine(fadeWindowThis.OnClose, new Action(delegate()
  49. {
  50. ControllerShortcutSettingData.config.Write();
  51. }));
  52. }
  53. private void CreateDefaultItems()
  54. {
  55. OVRLipSync.VariableData variable = GameMain.Instance.LipSyncMgr.Variable;
  56. VRFaceShortcutConfig.ItemSlider itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("リップシンク:マイク感度");
  57. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/リップシンク:マイク感度", false);
  58. itemSlider.min = 0f;
  59. itemSlider.max = 10f;
  60. itemSlider.Set(variable.MicSensitivity);
  61. itemSlider.onValueChanged = delegate(float value)
  62. {
  63. GameMain.Instance.LipSyncMgr.Variable.MicSensitivity = value;
  64. };
  65. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("リップシンク:自分の声の大きさ");
  66. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/リップシンク:自分の声の大きさ", false);
  67. itemSlider.min = 0f;
  68. itemSlider.max = 10f;
  69. itemSlider.Set(variable.MicVolume);
  70. itemSlider.onValueChanged = delegate(float value)
  71. {
  72. GameMain.Instance.LipSyncMgr.Variable.MicVolume = value;
  73. };
  74. VRFaceShortcutConfig.ItemSelectButton itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("リップシンク:ミュートにする");
  75. Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/リップシンク:ミュートにする", false);
  76. itemSelectButton.textLeft.text = "ON";
  77. itemSelectButton.textRight.text = "OFF";
  78. itemSelectButton.Set(variable.Mute);
  79. itemSelectButton.onClickIsLeft = delegate(bool isLeft)
  80. {
  81. variable.Mute = isLeft;
  82. };
  83. itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("手元ショートカット:表情の変化");
  84. Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/手元ショートカット:表情の変化", false);
  85. itemSelectButton.textLeft.text = "即座に変更する";
  86. Utility.SetLocalizeTerm(itemSelectButton.localizeLeft, "VAS/即座に変更する", false);
  87. itemSelectButton.textRight.text = "選択して決定する";
  88. Utility.SetLocalizeTerm(itemSelectButton.localizeRight, "VAS/選択して決定する", false);
  89. itemSelectButton.Set(ControllerShortcutSettingData.config.isDirectMode);
  90. itemSelectButton.onClickIsLeft = delegate(bool isLeft)
  91. {
  92. ControllerShortcutSettingData.config.isDirectMode = isLeft;
  93. };
  94. itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("手元ショートカット:手元のUI");
  95. Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/手元ショートカット:手元のUI", false);
  96. itemSelectButton.textLeft.text = "常に表示する";
  97. Utility.SetLocalizeTerm(itemSelectButton.localizeLeft, "VAS/常に表示する", false);
  98. itemSelectButton.textRight.text = "決定時に隠す";
  99. Utility.SetLocalizeTerm(itemSelectButton.localizeRight, "VAS/決定時に隠す", false);
  100. itemSelectButton.Set(ControllerShortcutSettingData.config.isEveryShowMode);
  101. itemSelectButton.onClickIsLeft = delegate(bool isLeft)
  102. {
  103. ControllerShortcutSettingData.config.isEveryShowMode = isLeft;
  104. };
  105. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体向きの頭への追従");
  106. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体向きの頭への追従", false);
  107. itemSlider.min = 0f;
  108. itemSlider.max = 1f;
  109. itemSlider.Set(ControllerShortcutSettingData.config.maintainPelvisPosition);
  110. itemSlider.onValueChanged = delegate(float value)
  111. {
  112. ControllerShortcutSettingData.config.maintainPelvisPosition = value;
  113. };
  114. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体位置の頭への追従");
  115. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体位置の頭への追従", false);
  116. itemSlider.min = 0f;
  117. itemSlider.max = 1f;
  118. itemSlider.Set(ControllerShortcutSettingData.config.bodyPosStiffness);
  119. itemSlider.onValueChanged = delegate(float value)
  120. {
  121. ControllerShortcutSettingData.config.bodyPosStiffness = value;
  122. };
  123. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("体回転の頭への追従");
  124. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/体回転の頭への追従", false);
  125. itemSlider.min = 0f;
  126. itemSlider.max = 1f;
  127. itemSlider.Set(ControllerShortcutSettingData.config.bodyRotStiffness);
  128. itemSlider.onValueChanged = delegate(float value)
  129. {
  130. ControllerShortcutSettingData.config.bodyRotStiffness = value;
  131. };
  132. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("胸部回転の頭への追従");
  133. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/胸部回転の頭への追従", false);
  134. itemSlider.min = 0f;
  135. itemSlider.max = 1f;
  136. itemSlider.Set(ControllerShortcutSettingData.config.chestRotationWeight);
  137. itemSlider.onValueChanged = delegate(float value)
  138. {
  139. ControllerShortcutSettingData.config.chestRotationWeight = value;
  140. };
  141. itemSlider = this.CreateItem<VRFaceShortcutConfig.ItemSlider>("カメラの画角");
  142. Utility.SetLocalizeTerm(itemSlider.localize, "VAS/カメラの画角", false);
  143. itemSlider.min = 0f;
  144. itemSlider.max = 1f;
  145. itemSlider.Set(ControllerShortcutSettingData.config.selfCameraFOV);
  146. itemSlider.onValueChanged = delegate(float value)
  147. {
  148. ControllerShortcutSettingData.config.selfCameraFOV = value;
  149. };
  150. VRFaceShortcutConfig.ParentMultiButton parentMultiButton = this.CreateItem<VRFaceShortcutConfig.ParentMultiButton>("手のスカートへの当たり判定\n※VR CONFIGより優先されます。");
  151. Utility.SetLocalizeTerm(parentMultiButton.localize, "VAS/手のスカートへの当たり判定", false);
  152. parentMultiButton.textRight.text = "OFF";
  153. parentMultiButton.textLeft.text = "常時ON";
  154. Utility.SetLocalizeTerm(parentMultiButton.localizeLeft, "VAS/常時ON", false);
  155. parentMultiButton.textCenter.text = "握時ON";
  156. Utility.SetLocalizeTerm(parentMultiButton.localizeCenter, "VAS/握時ON", false);
  157. if (GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF)
  158. {
  159. parentMultiButton.Set(0);
  160. }
  161. else if (GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS == CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.ON)
  162. {
  163. parentMultiButton.Set(1);
  164. }
  165. else
  166. {
  167. parentMultiButton.Set(2);
  168. }
  169. parentMultiButton.onClick = delegate(int index)
  170. {
  171. CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT ovrHandHitToSkirtVAS;
  172. if (index == 0)
  173. {
  174. ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.OFF;
  175. }
  176. else if (index == 1)
  177. {
  178. ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.ON;
  179. }
  180. else
  181. {
  182. ovrHandHitToSkirtVAS = CMSystem.SerializeConfig.OVR_HAND_TO_SKIRT.GRAB;
  183. }
  184. GameMain.Instance.CMSystem.SConfig.OvrHandHitToSkirtVAS = ovrHandHitToSkirtVAS;
  185. };
  186. }
  187. private void CreateViveItems()
  188. {
  189. if (GameMain.Instance.VRDeviceTypeID != GameMain.VRDeviceType.VIVE)
  190. {
  191. return;
  192. }
  193. VRFaceShortcutConfig.ItemSelectButton itemSelectButton = this.CreateItem<VRFaceShortcutConfig.ItemSelectButton>("一番上にあるトラッカーを\n頭トラッキングに利用");
  194. Utility.SetLocalizeTerm(itemSelectButton.localize, "VAS/一番上にあるトラッカーを頭トラッキングに利用", false);
  195. itemSelectButton.textLeft.text = "ON";
  196. itemSelectButton.textRight.text = "OFF";
  197. itemSelectButton.Set(ControllerShortcutSettingData.config.use1TrackerForHead);
  198. itemSelectButton.onClickIsLeft = delegate(bool isLeft)
  199. {
  200. ControllerShortcutSettingData.config.use1TrackerForHead = isLeft;
  201. this.SetActiveItem("2つめと3つめのトラッカーを\n足トラッキングに利用", isLeft, false);
  202. this.SetActiveItem("1つめと2つめのトラッカーを\n足トラッキングに利用", !isLeft, false);
  203. };
  204. }
  205. private void SetActiveItem(string itemKey, bool isActive, bool isEnableError = true)
  206. {
  207. VRFaceShortcutConfig.Item item;
  208. if (!this.m_ItemDic.TryGetValue(itemKey, out item))
  209. {
  210. if (isEnableError)
  211. {
  212. string message = "[VRFaceShortcutConfig] コンフィグ項目に「" + itemKey + "」は存在しません";
  213. Debug.LogError(message);
  214. NDebug.Assert(message, false);
  215. }
  216. return;
  217. }
  218. if (item.gameObject.activeSelf != isActive)
  219. {
  220. item.gameObject.SetActive(isActive);
  221. Utility.SetLocalizeTerm(item.localize, "VAS/" + itemKey, false);
  222. this.m_IsUpdateReposition = true;
  223. }
  224. }
  225. private void LateUpdate()
  226. {
  227. if (this.m_IsUpdateReposition)
  228. {
  229. this.m_IsUpdateReposition = false;
  230. this.m_Grid.Reposition();
  231. this.m_ScrollView.UpdatePosition();
  232. }
  233. }
  234. private static T GetChildObject<T>(GameObject gameObject, string path)
  235. {
  236. GameObject childObject = UTY.GetChildObject(gameObject, path, false);
  237. if (childObject == null)
  238. {
  239. string message = string.Concat(new string[]
  240. {
  241. "[VRFaceShortcutConfig] ",
  242. gameObject.name,
  243. "/",
  244. path,
  245. "が見つかりませんでした"
  246. });
  247. NDebug.Assert(message, false);
  248. Debug.LogError(message);
  249. }
  250. T component = childObject.GetComponent<T>();
  251. if (component == null)
  252. {
  253. string message2 = string.Concat(new object[]
  254. {
  255. "[VRFaceShortcutConfig] ",
  256. gameObject.name,
  257. "/",
  258. path,
  259. "に、\n",
  260. typeof(T),
  261. "のコンポーネントがありませんでした"
  262. });
  263. NDebug.Assert(message2, false);
  264. Debug.LogError(message2);
  265. }
  266. return component;
  267. }
  268. [SerializeField]
  269. [Range(0.001f, 1f)]
  270. private float m_FadeSpeed = 0.25f;
  271. [SerializeField]
  272. private NGUIWindow m_FadeWindowThis;
  273. [SerializeField]
  274. private UIScrollView m_ScrollView;
  275. [SerializeField]
  276. private UIGrid m_Grid;
  277. private Dictionary<Type, VRFaceShortcutConfig.Item> m_ItemTemplateList = new Dictionary<Type, VRFaceShortcutConfig.Item>();
  278. private Dictionary<string, VRFaceShortcutConfig.Item> m_ItemDic = new Dictionary<string, VRFaceShortcutConfig.Item>();
  279. private bool m_IsUpdateReposition;
  280. public abstract class Item : MonoBehaviour
  281. {
  282. public UILabel label
  283. {
  284. get
  285. {
  286. return this.m_Label;
  287. }
  288. set
  289. {
  290. this.m_Label = value;
  291. }
  292. }
  293. public Localize localize { get; private set; }
  294. protected virtual void Awake()
  295. {
  296. this.m_Label = VRFaceShortcutConfig.GetChildObject<UILabel>(base.gameObject, "name");
  297. this.localize = this.m_Label.gameObject.AddComponent<Localize>();
  298. }
  299. public abstract void Set(object value);
  300. private UILabel m_Label;
  301. }
  302. public class ItemSlider : VRFaceShortcutConfig.Item
  303. {
  304. public UISlider slider
  305. {
  306. get
  307. {
  308. return this.m_Slider;
  309. }
  310. private set
  311. {
  312. this.m_Slider = value;
  313. }
  314. }
  315. public float normalizedValue
  316. {
  317. get
  318. {
  319. return this.slider.value;
  320. }
  321. set
  322. {
  323. this.slider.value = value;
  324. }
  325. }
  326. public float min
  327. {
  328. get
  329. {
  330. return this.m_Min;
  331. }
  332. set
  333. {
  334. this.m_Min = value;
  335. }
  336. }
  337. public float max
  338. {
  339. get
  340. {
  341. return this.m_Max;
  342. }
  343. set
  344. {
  345. this.m_Max = value;
  346. }
  347. }
  348. public float value
  349. {
  350. get
  351. {
  352. return Mathf.Lerp(this.min, this.max, this.normalizedValue);
  353. }
  354. set
  355. {
  356. this.normalizedValue = Mathf.InverseLerp(this.min, this.max, value);
  357. }
  358. }
  359. public Action<float> onValueChanged { get; set; }
  360. public Action onDragFinished { get; set; }
  361. protected override void Awake()
  362. {
  363. base.Awake();
  364. this.slider = VRFaceShortcutConfig.GetChildObject<UISlider>(base.gameObject, "slider");
  365. EventDelegate.Add(this.slider.onChange, delegate()
  366. {
  367. if (this.onValueChanged != null)
  368. {
  369. this.onValueChanged(this.value);
  370. }
  371. });
  372. UISlider slider = this.slider;
  373. slider.onDragFinished = (UIProgressBar.OnDragFinished)Delegate.Combine(slider.onDragFinished, new UIProgressBar.OnDragFinished(delegate()
  374. {
  375. if (this.onDragFinished != null)
  376. {
  377. this.onDragFinished();
  378. }
  379. }));
  380. }
  381. public override void Set(object value)
  382. {
  383. this.value = (float)value;
  384. }
  385. private UISlider m_Slider;
  386. private float m_Min;
  387. private float m_Max = 1f;
  388. }
  389. public class ItemSelectButton : VRFaceShortcutConfig.Item
  390. {
  391. public UIButton buttonRight
  392. {
  393. get
  394. {
  395. return this.m_ButtonRight;
  396. }
  397. private set
  398. {
  399. this.m_ButtonRight = value;
  400. }
  401. }
  402. public UIButton buttonLeft
  403. {
  404. get
  405. {
  406. return this.m_ButtonLeft;
  407. }
  408. private set
  409. {
  410. this.m_ButtonLeft = value;
  411. }
  412. }
  413. public UILabel textRight
  414. {
  415. get
  416. {
  417. return this.m_TextRight;
  418. }
  419. private set
  420. {
  421. this.m_TextRight = value;
  422. }
  423. }
  424. public UILabel textLeft
  425. {
  426. get
  427. {
  428. return this.m_TextLeft;
  429. }
  430. private set
  431. {
  432. this.m_TextLeft = value;
  433. }
  434. }
  435. public Localize localizeRight { get; private set; }
  436. public Localize localizeLeft { get; private set; }
  437. public Action<bool> onClickIsLeft { get; set; }
  438. protected override void Awake()
  439. {
  440. base.Awake();
  441. this.buttonRight = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button right");
  442. this.buttonLeft = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button left");
  443. this.textRight = this.buttonRight.GetComponentInChildren<UILabel>();
  444. this.textLeft = this.buttonLeft.GetComponentInChildren<UILabel>();
  445. this.localizeRight = this.textRight.gameObject.AddComponent<Localize>();
  446. this.localizeLeft = this.textLeft.gameObject.AddComponent<Localize>();
  447. EventDelegate.Add(this.buttonRight.onClick, delegate()
  448. {
  449. if (this.onClickIsLeft != null)
  450. {
  451. this.onClickIsLeft(false);
  452. }
  453. this.OnClickButton(false);
  454. });
  455. EventDelegate.Add(this.buttonLeft.onClick, delegate()
  456. {
  457. if (this.onClickIsLeft != null)
  458. {
  459. this.onClickIsLeft(true);
  460. }
  461. this.OnClickButton(true);
  462. });
  463. }
  464. private void OnClickButton(bool isLeft)
  465. {
  466. this.buttonLeft.defaultColor = ((!isLeft) ? VRFaceShortcutConfig.ItemSelectButton.ButtonDefaultColor : VRFaceShortcutConfig.ItemSelectButton.ButtonClickedColor);
  467. this.buttonRight.defaultColor = (isLeft ? VRFaceShortcutConfig.ItemSelectButton.ButtonDefaultColor : VRFaceShortcutConfig.ItemSelectButton.ButtonClickedColor);
  468. }
  469. public void Emulate(bool isLeft)
  470. {
  471. UIButton uibutton = (!isLeft) ? this.buttonRight : this.buttonLeft;
  472. EventDelegate.Execute(uibutton.onClick);
  473. }
  474. public override void Set(object value)
  475. {
  476. this.Emulate((bool)value);
  477. }
  478. private static Color ButtonDefaultColor = new Color(1f, 1f, 1f, 0.5f);
  479. private static Color ButtonClickedColor = Color.white;
  480. private UIButton m_ButtonRight;
  481. private UIButton m_ButtonLeft;
  482. private UILabel m_TextRight;
  483. private UILabel m_TextLeft;
  484. }
  485. private class ParentMultiButton : VRFaceShortcutConfig.Item
  486. {
  487. public UIButton buttonRight
  488. {
  489. get
  490. {
  491. return this.m_ButtonRight;
  492. }
  493. private set
  494. {
  495. this.m_ButtonRight = value;
  496. }
  497. }
  498. public UIButton buttonLeft
  499. {
  500. get
  501. {
  502. return this.m_ButtonLeft;
  503. }
  504. private set
  505. {
  506. this.m_ButtonLeft = value;
  507. }
  508. }
  509. public UIButton buttonCenter
  510. {
  511. get
  512. {
  513. return this.m_ButtonCenter;
  514. }
  515. private set
  516. {
  517. this.m_ButtonCenter = value;
  518. }
  519. }
  520. public UILabel textRight
  521. {
  522. get
  523. {
  524. return this.m_TextRight;
  525. }
  526. private set
  527. {
  528. this.m_TextRight = value;
  529. }
  530. }
  531. public UILabel textLeft
  532. {
  533. get
  534. {
  535. return this.m_TextLeft;
  536. }
  537. private set
  538. {
  539. this.m_TextLeft = value;
  540. }
  541. }
  542. public UILabel textCenter
  543. {
  544. get
  545. {
  546. return this.m_TextCenter;
  547. }
  548. private set
  549. {
  550. this.m_TextCenter = value;
  551. }
  552. }
  553. public Localize localizeRight { get; private set; }
  554. public Localize localizeLeft { get; private set; }
  555. public Localize localizeCenter { get; private set; }
  556. public Action<int> onClick { get; set; }
  557. protected override void Awake()
  558. {
  559. base.Awake();
  560. this.buttonRight = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button right");
  561. this.buttonLeft = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button left");
  562. this.buttonCenter = VRFaceShortcutConfig.GetChildObject<UIButton>(base.gameObject, "button center");
  563. this.textRight = this.buttonRight.GetComponentInChildren<UILabel>();
  564. this.textLeft = this.buttonLeft.GetComponentInChildren<UILabel>();
  565. this.textCenter = this.buttonCenter.GetComponentInChildren<UILabel>();
  566. this.localizeRight = this.textRight.gameObject.AddComponent<Localize>();
  567. this.localizeLeft = this.textLeft.gameObject.AddComponent<Localize>();
  568. this.localizeCenter = this.textCenter.gameObject.AddComponent<Localize>();
  569. EventDelegate.Add(this.buttonRight.onClick, delegate()
  570. {
  571. if (this.onClick != null)
  572. {
  573. this.onClick(0);
  574. }
  575. this.OnClickButton(0);
  576. });
  577. EventDelegate.Add(this.buttonLeft.onClick, delegate()
  578. {
  579. if (this.onClick != null)
  580. {
  581. this.onClick(1);
  582. }
  583. this.OnClickButton(1);
  584. });
  585. EventDelegate.Add(this.buttonCenter.onClick, delegate()
  586. {
  587. if (this.onClick != null)
  588. {
  589. this.onClick(2);
  590. }
  591. this.OnClickButton(2);
  592. });
  593. }
  594. private void OnClickButton(int index)
  595. {
  596. this.buttonRight.defaultColor = ((index != 0) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
  597. this.buttonLeft.defaultColor = ((index != 1) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
  598. this.buttonCenter.defaultColor = ((index != 2) ? VRFaceShortcutConfig.ParentMultiButton.ButtonDefaultColor : VRFaceShortcutConfig.ParentMultiButton.ButtonClickedColor);
  599. }
  600. public void Emulate(int index)
  601. {
  602. UIButton uibutton;
  603. if (index == 0)
  604. {
  605. uibutton = this.buttonRight;
  606. }
  607. else if (index == 1)
  608. {
  609. uibutton = this.buttonLeft;
  610. }
  611. else
  612. {
  613. uibutton = this.buttonCenter;
  614. }
  615. EventDelegate.Execute(uibutton.onClick);
  616. }
  617. public override void Set(object value)
  618. {
  619. this.Emulate((int)value);
  620. }
  621. private static Color ButtonDefaultColor = new Color(1f, 1f, 1f, 0.5f);
  622. private static Color ButtonClickedColor = Color.white;
  623. private UIButton m_ButtonRight;
  624. private UIButton m_ButtonLeft;
  625. private UIButton m_ButtonCenter;
  626. private UILabel m_TextRight;
  627. private UILabel m_TextLeft;
  628. private UILabel m_TextCenter;
  629. }
  630. }