PhotoMotionDataShortcutSetter.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Kasizuki;
  5. using UnityEngine;
  6. public class PhotoMotionDataShortcutSetter : MonoBehaviour
  7. {
  8. public float fadeSpeed
  9. {
  10. get
  11. {
  12. return this.m_FadeSpeed;
  13. }
  14. set
  15. {
  16. this.m_FadeSpeed = Mathf.Clamp(value, 0.001f, 1f);
  17. }
  18. }
  19. private PhotoMotionDataShortcut targetControllerRight
  20. {
  21. get
  22. {
  23. return this.m_TargetControllerRight;
  24. }
  25. }
  26. private PhotoMotionDataShortcut targetControllerLeft
  27. {
  28. get
  29. {
  30. return this.m_TargetControllerLeft;
  31. }
  32. }
  33. private PhotoMotionDataShortcut.ItemData nowSelectItem
  34. {
  35. get
  36. {
  37. return this.m_NowSelectItem;
  38. }
  39. set
  40. {
  41. this.m_NowSelectItem = value;
  42. }
  43. }
  44. private void Start()
  45. {
  46. this.m_FadeWindowShortcutButtonsRight = this.m_ButtonListShortcutRight.GetComponent<NGUIWindow>();
  47. this.m_FadeWindowShortcutButtonsLeft = this.m_ButtonListShortcutLeft.GetComponent<NGUIWindow>();
  48. this.m_FadeWindowMotionDataList = this.m_WindowListMotionData.GetComponent<NGUIWindow>();
  49. this.targetControllerRight.CreateItemList(8);
  50. this.targetControllerLeft.CreateItemList(8);
  51. PhotoMotionData.Create();
  52. List<PhotoMotionData> data2 = PhotoMotionData.data;
  53. ListViewerWindow windowListMotionData = this.m_WindowListMotionData;
  54. windowListMotionData.Show<PhotoMotionData, UIWFTabButton>(data2, delegate(int index, PhotoMotionData data, UIWFTabButton item)
  55. {
  56. UILabel componentInChildren = item.GetComponentInChildren<UILabel>();
  57. componentInChildren.text = data.name;
  58. EventDelegate.Add(item.onClick, delegate()
  59. {
  60. this.OnClickData(data);
  61. });
  62. });
  63. UIWFTabPanel component = windowListMotionData.viewer.parentItemArea.GetComponent<UIWFTabPanel>();
  64. if (component)
  65. {
  66. component.UpdateChildren();
  67. }
  68. this.m_ButtonListShortcutRight.Show<Transform>(this.targetControllerRight.itemDataList.Count, delegate(int index, Transform trans)
  69. {
  70. PhotoMotionDataShortcut.ItemData data = this.targetControllerRight.itemDataList[index];
  71. UILabel componentInChildren = trans.GetComponentInChildren<UILabel>();
  72. UIButton componentInChildren2 = trans.GetComponentInChildren<UIButton>();
  73. componentInChildren.text = data.GetDataName();
  74. EventDelegate.Add(componentInChildren2.onClick, delegate()
  75. {
  76. this.OnClickShortcutButton(data);
  77. });
  78. PhotoMotionDataShortcutSetter.ItemData itemData = trans.gameObject.AddComponent<PhotoMotionDataShortcutSetter.ItemData>();
  79. itemData.label = componentInChildren;
  80. this.m_ItemPairDic.Add(data, itemData);
  81. });
  82. this.m_ButtonListShortcutLeft.Show<Transform>(this.targetControllerLeft.itemDataList.Count, delegate(int index, Transform trans)
  83. {
  84. PhotoMotionDataShortcut.ItemData data = this.targetControllerLeft.itemDataList[index];
  85. UILabel componentInChildren = trans.GetComponentInChildren<UILabel>();
  86. UIButton componentInChildren2 = trans.GetComponentInChildren<UIButton>();
  87. componentInChildren.text = data.GetDataName();
  88. EventDelegate.Add(componentInChildren2.onClick, delegate()
  89. {
  90. this.OnClickShortcutButton(data);
  91. });
  92. PhotoMotionDataShortcutSetter.ItemData itemData = trans.gameObject.AddComponent<PhotoMotionDataShortcutSetter.ItemData>();
  93. itemData.label = componentInChildren;
  94. this.m_ItemPairDic.Add(data, itemData);
  95. });
  96. EventDelegate.Add(this.m_ButtonMotionListOK.onClick, new EventDelegate.Callback(this.OnClickMotionListOK));
  97. }
  98. private void OnClickData(PhotoMotionData data)
  99. {
  100. Debug.Log("モーション:" + data.name);
  101. if (this.nowSelectItem != null)
  102. {
  103. this.nowSelectItem.data = data;
  104. }
  105. PhotoMotionDataShortcutSetter.ItemData itemData;
  106. if (this.m_ItemPairDic != null && this.m_ItemPairDic.TryGetValue(this.nowSelectItem, out itemData))
  107. {
  108. itemData.label.text = this.nowSelectItem.GetDataName();
  109. }
  110. if (this.nowSelectItem != null)
  111. {
  112. if (this.targetControllerRight.itemDataList.Contains(this.nowSelectItem))
  113. {
  114. this.targetControllerRight.Emulate(this.nowSelectItem);
  115. }
  116. else if (this.targetControllerLeft.itemDataList.Contains(this.nowSelectItem))
  117. {
  118. this.targetControllerLeft.Emulate(this.nowSelectItem);
  119. }
  120. else
  121. {
  122. Debug.LogWarning("コントローラに存在しない項目を更新しているかも");
  123. }
  124. }
  125. }
  126. private void OnClickShortcutButton(PhotoMotionDataShortcut.ItemData item)
  127. {
  128. this.nowSelectItem = item;
  129. this.m_FadeWindowShortcutButtonsRight.Close(this.fadeSpeed, null);
  130. this.m_FadeWindowShortcutButtonsLeft.Close(this.fadeSpeed, null);
  131. this.WaitTime(this.fadeSpeed, delegate
  132. {
  133. this.m_FadeWindowMotionDataList.Open(this.fadeSpeed, null);
  134. });
  135. this.m_WindowListMotionData.Reposition();
  136. UIWFTabPanel component = this.m_WindowListMotionData.viewer.parentItemArea.GetComponent<UIWFTabPanel>();
  137. UIWFTabButton selectButtonObject = component.GetSelectButtonObject();
  138. if (selectButtonObject != null)
  139. {
  140. selectButtonObject.SetSelect(false);
  141. }
  142. component.ResetSelect();
  143. component.UpdateChildren();
  144. }
  145. private void OnClickMotionListOK()
  146. {
  147. this.m_FadeWindowMotionDataList.Close(this.fadeSpeed, null);
  148. this.WaitTime(this.fadeSpeed, delegate
  149. {
  150. this.m_FadeWindowShortcutButtonsRight.Open(this.fadeSpeed, null);
  151. this.m_FadeWindowShortcutButtonsLeft.Open(this.fadeSpeed, null);
  152. });
  153. }
  154. private void OnApplicationQuit()
  155. {
  156. this.m_IsQuittingApplication = true;
  157. }
  158. private void OnDisable()
  159. {
  160. if (this.m_IsQuittingApplication)
  161. {
  162. return;
  163. }
  164. Debug.LogWarning("デバッグ:モーション用コントローラ無効化");
  165. this.targetControllerRight.gameObject.SetActive(false);
  166. this.targetControllerLeft.gameObject.SetActive(false);
  167. }
  168. private void OnEnable()
  169. {
  170. Debug.LogWarning("デバッグ:モーション用コントローラ有効化");
  171. this.targetControllerRight.gameObject.SetActive(true);
  172. this.targetControllerLeft.gameObject.SetActive(true);
  173. }
  174. private void WaitTime(float time, Action onFinish)
  175. {
  176. base.StartCoroutine(this.CoWaitTime(time, onFinish));
  177. }
  178. private IEnumerator CoWaitTime(float time, Action onFinish)
  179. {
  180. yield return new WaitForSeconds(time);
  181. if (onFinish != null)
  182. {
  183. onFinish();
  184. }
  185. yield break;
  186. }
  187. [SerializeField]
  188. [Range(0.001f, 1f)]
  189. private float m_FadeSpeed = 0.25f;
  190. [SerializeField]
  191. private PhotoMotionDataShortcut m_TargetControllerRight;
  192. [SerializeField]
  193. private PhotoMotionDataShortcut m_TargetControllerLeft;
  194. [SerializeField]
  195. private CircleCommandUI m_ButtonListShortcutRight;
  196. [SerializeField]
  197. private CircleCommandUI m_ButtonListShortcutLeft;
  198. [SerializeField]
  199. private ListViewerWindow m_WindowListMotionData;
  200. [SerializeField]
  201. private UIButton m_ButtonMotionListOK;
  202. private NGUIWindow m_FadeWindowShortcutButtonsRight;
  203. private NGUIWindow m_FadeWindowShortcutButtonsLeft;
  204. private NGUIWindow m_FadeWindowMotionDataList;
  205. private PhotoMotionDataShortcut.ItemData m_NowSelectItem;
  206. private Dictionary<PhotoMotionDataShortcut.ItemData, PhotoMotionDataShortcutSetter.ItemData> m_ItemPairDic = new Dictionary<PhotoMotionDataShortcut.ItemData, PhotoMotionDataShortcutSetter.ItemData>();
  207. private bool m_IsQuittingApplication;
  208. public class ItemData : MonoBehaviour
  209. {
  210. public UILabel label
  211. {
  212. get
  213. {
  214. return this.m_Label;
  215. }
  216. set
  217. {
  218. this.m_Label = value;
  219. }
  220. }
  221. private UILabel m_Label;
  222. }
  223. }