uGUIKaraokeSelect.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. public class uGUIKaraokeSelect : MonoBehaviour
  7. {
  8. private uGUIKaraokeSelect.uGUIItemListViewer UIListViewer
  9. {
  10. get
  11. {
  12. if (!this.m_UIListViewer)
  13. {
  14. this.m_UIListViewer = this.m_UIListViewerObject.GetOrAddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
  15. }
  16. return this.m_UIListViewer;
  17. }
  18. }
  19. private void Start()
  20. {
  21. this.m_UIListViewerObject.gameObject.AddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
  22. this.HideListViewer();
  23. this.SetButtonActive(this.m_ButtonOK, false);
  24. this.SetButtonActive(this.m_ButtonCANCEL, false);
  25. this.SetButtonActive(this.m_ButtonStart, true);
  26. this.SetButtonActive(this.m_ButtonEnd, true);
  27. this.SetButtonInteractable(this.m_ButtonOK, false);
  28. this.SetButtonInteractable(this.m_ButtonCANCEL, false);
  29. this.SetButtonInteractable(this.m_ButtonStart, true);
  30. this.SetButtonInteractable(this.m_ButtonEnd, true);
  31. KaraokeDataManager.MusicData[] musicDataArray = this.GetMusicDataArray();
  32. string arg = string.Empty;
  33. if (musicDataArray.Length > 0)
  34. {
  35. arg = musicDataArray[0].strThumbnailName;
  36. this.m_SelectingMusicDataID = musicDataArray[0].ID;
  37. }
  38. this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", arg));
  39. KaraokeDataManager.BackgroundData backgroundData = this.GetBackgroundData(this.GetNowBackgroundDataIndex());
  40. this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", backgroundData.strThumbnailName));
  41. if (SceneVRCommunication.Instance && !SceneVRCommunication.Instance.KaraokeMode)
  42. {
  43. this.m_ButtonSelectBG.interactable = false;
  44. }
  45. if (this.GetFoodDataArray().Length <= 0)
  46. {
  47. this.m_ButtonSelectFood.interactable = false;
  48. }
  49. }
  50. public void OpenListSelectMusic(bool isOn)
  51. {
  52. this.SetButtonActive(this.m_ButtonOK, true);
  53. this.SetButtonActive(this.m_ButtonCANCEL, true);
  54. this.SetButtonActive(this.m_ButtonStart, false);
  55. this.SetButtonActive(this.m_ButtonEnd, false);
  56. this.SetButtonInteractable(this.m_ButtonOK, true);
  57. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  58. this.ShowListViewer();
  59. KaraokeDataManager.MusicData[] musicArray = this.GetMusicDataArray();
  60. this.m_BeforeSelectedGameObject = null;
  61. this.UIListViewer.Show(musicArray.Length, delegate(int index, GameObject item)
  62. {
  63. Toggle component = item.GetComponent<Toggle>();
  64. uGUIKaraokeSelect.uGUIItemListButton itemNumber = item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>();
  65. itemNumber.number = musicArray[index].ID;
  66. if (this.m_SelectingMusicDataID == itemNumber.number)
  67. {
  68. component.isOn = true;
  69. }
  70. component.image.sprite = this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", musicArray[index].strThumbnailName));
  71. component.onValueChanged.AddListener(delegate(bool value)
  72. {
  73. if (!value)
  74. {
  75. return;
  76. }
  77. int number = itemNumber.number;
  78. if (this.IsAlreadySelected(item))
  79. {
  80. this.ButtonEventSetMusic(number);
  81. }
  82. });
  83. });
  84. this.m_ButtonOK.onClick.RemoveAllListeners();
  85. this.m_ButtonOK.onClick.AddListener(delegate
  86. {
  87. int indexMusic = this.m_SelectingMusicDataID;
  88. if (this.m_BeforeSelectedGameObject)
  89. {
  90. indexMusic = this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  91. }
  92. this.ButtonEventSetMusic(indexMusic);
  93. });
  94. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  95. this.m_ButtonCANCEL.onClick.AddListener(delegate
  96. {
  97. this.SetButtonActive(this.m_ButtonOK, false);
  98. this.SetButtonActive(this.m_ButtonCANCEL, false);
  99. this.SetButtonActive(this.m_ButtonStart, true);
  100. this.SetButtonActive(this.m_ButtonEnd, true);
  101. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  102. this.SetButtonInteractable(this.m_ButtonEnd, true);
  103. this.HideListViewer();
  104. });
  105. }
  106. public void OpenListSelectBG(bool isOn)
  107. {
  108. this.SetButtonActive(this.m_ButtonOK, true);
  109. this.SetButtonActive(this.m_ButtonCANCEL, true);
  110. this.SetButtonActive(this.m_ButtonStart, false);
  111. this.SetButtonActive(this.m_ButtonEnd, false);
  112. this.SetButtonInteractable(this.m_ButtonOK, true);
  113. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  114. this.ShowListViewer();
  115. KaraokeDataManager.BackgroundData[] backgroundArray = this.GetBackgroundDataArray();
  116. this.m_BeforeSelectedGameObject = null;
  117. this.UIListViewer.Show(backgroundArray.Length, delegate(int index, GameObject item)
  118. {
  119. Toggle component = item.GetComponent<Toggle>();
  120. item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
  121. if (this.GetNowSelectingBackgroundDataIndex() == index)
  122. {
  123. component.isOn = true;
  124. }
  125. component.image.sprite = this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", backgroundArray[index].strThumbnailName));
  126. component.onValueChanged.AddListener(delegate(bool value)
  127. {
  128. if (!value)
  129. {
  130. return;
  131. }
  132. this.SetButtonInteractable(this.m_ButtonOK, true);
  133. if (this.IsAlreadySelected(item))
  134. {
  135. this.ButtonEventSetBG(index);
  136. }
  137. });
  138. });
  139. this.m_ButtonOK.onClick.RemoveAllListeners();
  140. this.m_ButtonOK.onClick.AddListener(delegate
  141. {
  142. int indexBG = this.GetNowSelectingBackgroundDataIndex();
  143. if (this.m_BeforeSelectedGameObject)
  144. {
  145. indexBG = this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  146. }
  147. this.ButtonEventSetBG(indexBG);
  148. });
  149. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  150. this.m_ButtonCANCEL.onClick.AddListener(delegate
  151. {
  152. this.SetButtonActive(this.m_ButtonOK, false);
  153. this.SetButtonActive(this.m_ButtonCANCEL, false);
  154. this.SetButtonActive(this.m_ButtonStart, true);
  155. this.SetButtonActive(this.m_ButtonEnd, true);
  156. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  157. this.SetButtonInteractable(this.m_ButtonEnd, true);
  158. this.HideListViewer();
  159. });
  160. }
  161. public void OpenListSelectFood(bool isOn)
  162. {
  163. if (!isOn)
  164. {
  165. return;
  166. }
  167. if (this.IsMaidAddCallFlag())
  168. {
  169. this.OnEventMaidAddCalled();
  170. return;
  171. }
  172. this.SetButtonActive(this.m_ButtonOK, true);
  173. this.SetButtonActive(this.m_ButtonCANCEL, true);
  174. this.SetButtonActive(this.m_ButtonStart, false);
  175. this.SetButtonActive(this.m_ButtonEnd, false);
  176. this.SetButtonInteractable(this.m_ButtonOK, true);
  177. this.SetButtonInteractable(this.m_ButtonCANCEL, true);
  178. this.ShowListViewer();
  179. KaraokeDataManager.FoodData[] foodArray = this.GetFoodDataArray();
  180. this.m_BeforeSelectedGameObject = null;
  181. this.UIListViewer.Show(foodArray.Length, delegate(int index, GameObject item)
  182. {
  183. Toggle component = item.GetComponent<Toggle>();
  184. item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
  185. if (this.m_SelectingFoodDataIndex == index)
  186. {
  187. component.isOn = true;
  188. }
  189. component.image.sprite = this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", foodArray[index].strThumbnailName));
  190. component.onValueChanged.AddListener(delegate(bool value)
  191. {
  192. if (!value)
  193. {
  194. return;
  195. }
  196. this.SetButtonInteractable(this.m_ButtonOK, true);
  197. if (this.IsAlreadySelected(item))
  198. {
  199. this.ButtonEventSetFood(index);
  200. }
  201. });
  202. });
  203. this.m_ButtonOK.onClick.RemoveAllListeners();
  204. this.m_ButtonOK.onClick.AddListener(delegate
  205. {
  206. int indexFood = this.m_SelectingFoodDataIndex;
  207. if (this.m_BeforeSelectedGameObject)
  208. {
  209. indexFood = this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
  210. }
  211. this.ButtonEventSetFood(indexFood);
  212. });
  213. this.m_ButtonCANCEL.onClick.RemoveAllListeners();
  214. this.m_ButtonCANCEL.onClick.AddListener(delegate
  215. {
  216. this.SetButtonActive(this.m_ButtonOK, false);
  217. this.SetButtonActive(this.m_ButtonCANCEL, false);
  218. this.SetButtonActive(this.m_ButtonStart, true);
  219. this.SetButtonActive(this.m_ButtonEnd, true);
  220. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  221. this.SetButtonInteractable(this.m_ButtonEnd, true);
  222. this.HideListViewer();
  223. });
  224. }
  225. private void ButtonEventSetMusic(int indexMusic)
  226. {
  227. this.m_SelectingMusicDataID = indexMusic;
  228. this.SetButtonActive(this.m_ButtonOK, false);
  229. this.SetButtonActive(this.m_ButtonCANCEL, false);
  230. this.SetButtonActive(this.m_ButtonStart, true);
  231. this.SetButtonActive(this.m_ButtonEnd, true);
  232. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  233. this.SetButtonInteractable(this.m_ButtonEnd, true);
  234. this.HideListViewer();
  235. this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetMusicData(indexMusic).strThumbnailName));
  236. }
  237. private void ButtonEventSetBG(int indexBG)
  238. {
  239. this.SetBG(indexBG);
  240. Debug.Log(string.Format("[Karaoke]背景が選択された\n選択した背景インデックス:{0}", indexBG));
  241. this.SetButtonActive(this.m_ButtonOK, false);
  242. this.SetButtonActive(this.m_ButtonCANCEL, false);
  243. this.SetButtonActive(this.m_ButtonStart, true);
  244. this.SetButtonActive(this.m_ButtonEnd, true);
  245. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  246. this.SetButtonInteractable(this.m_ButtonEnd, true);
  247. this.HideListViewer();
  248. this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetBackgroundData(indexBG).strThumbnailName));
  249. }
  250. private void ButtonEventSetFood(int indexFood)
  251. {
  252. this.m_SelectingFoodDataIndex = indexFood;
  253. Debug.Log(string.Format("[Karaoke]飲食物が選択された\n選択した飲食物インデックス:{0}", indexFood));
  254. this.SetButtonActive(this.m_ButtonOK, false);
  255. this.SetButtonActive(this.m_ButtonCANCEL, false);
  256. this.SetButtonActive(this.m_ButtonStart, true);
  257. this.SetButtonActive(this.m_ButtonEnd, true);
  258. this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
  259. this.SetButtonInteractable(this.m_ButtonEnd, true);
  260. this.HideListViewer();
  261. this.StartFood(indexFood);
  262. this.m_ButtonSelectFood.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetFoodData(indexFood).strThumbnailName));
  263. this.UpdateOrderButtonImage();
  264. }
  265. private void ShowListViewer()
  266. {
  267. if (!this.m_ParentUIListViewer.gameObject.activeSelf)
  268. {
  269. UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
  270. component.FadeIn(component.fadeTime, component.isTimeScaling, null);
  271. }
  272. this.UpdateOrderButtonImage();
  273. }
  274. private void HideListViewer()
  275. {
  276. if (this.m_ParentUIListViewer.gameObject.activeSelf)
  277. {
  278. UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
  279. component.FadeOut(component.fadeTime, component.isTimeScaling, delegate
  280. {
  281. this.m_ParentUIListViewer.gameObject.SetActive(false);
  282. });
  283. }
  284. this.UpdateOrderButtonImage();
  285. }
  286. private void UpdateOrderButtonImage()
  287. {
  288. if (this.IsMaidAddCallFlag())
  289. {
  290. this.m_ButtonSelectFood.image.sprite = this.GetResource<Sprite>("SceneVRCommunication/Tablet/Karaoke/Sprite/kp_event");
  291. Debug.Log("[カラオケ]\u3000メイド二人目呼び出しのフラグがtrue");
  292. }
  293. else
  294. {
  295. Debug.Log("[カラオケ]\u3000メイド二人目はまだ呼ばれていない。");
  296. }
  297. }
  298. private bool IsAlreadySelected(GameObject selectableObject)
  299. {
  300. GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
  301. bool result = this.m_BeforeSelectedGameObject == selectableObject;
  302. this.m_BeforeSelectedGameObject = currentSelectedGameObject;
  303. return result;
  304. }
  305. private void SetButtonActive(Button button, bool active)
  306. {
  307. if (button.gameObject.activeSelf != active)
  308. {
  309. button.gameObject.SetActive(active);
  310. }
  311. }
  312. private void SetButtonInteractable(Button button, bool interactable)
  313. {
  314. if (button.interactable != interactable)
  315. {
  316. button.interactable = interactable;
  317. }
  318. }
  319. private bool IsSelectingMusicDataExist()
  320. {
  321. Debug.Log(string.Format("[Karaoke]選択している楽曲インデックス:{0}", this.m_SelectingMusicDataID));
  322. return this.m_Manager.IsExistMusicData(this.m_SelectingMusicDataID);
  323. }
  324. private T GetResource<T>(string path) where T : UnityEngine.Object
  325. {
  326. if (string.IsNullOrEmpty(path))
  327. {
  328. Debug.LogWarning("[Karaoke]リソースのパスが空です");
  329. return (T)((object)null);
  330. }
  331. T t = Resources.Load<T>(path);
  332. if (!t)
  333. {
  334. Debug.LogWarning(string.Format("[Karaoke]リソースの取得に失敗しました\nパス:「{0}」", path));
  335. }
  336. return t;
  337. }
  338. private bool IsMaidAddCallFlag()
  339. {
  340. int tmpGenericFlag = GameMain.Instance.CMSystem.GetTmpGenericFlag("カラオケメイド追加");
  341. return tmpGenericFlag == 1;
  342. }
  343. private void OnEventMaidAddCalled()
  344. {
  345. string file_name = "karaoke_comevent_main.ks";
  346. GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(file_name, string.Empty);
  347. GameMain.Instance.ScriptMgr.adv_kag.Exec();
  348. }
  349. private KaraokeDataManager.MusicData[] GetMusicDataArray()
  350. {
  351. return this.m_Manager.GetMusicDataArray(true);
  352. }
  353. private KaraokeDataManager.FoodData[] GetFoodDataArray()
  354. {
  355. KaraokeDataManager.FoodData[] foodDataArray = this.m_Manager.GetFoodDataArray(true);
  356. List<KaraokeDataManager.FoodData> list = new List<KaraokeDataManager.FoodData>();
  357. foreach (KaraokeDataManager.FoodData foodData in foodDataArray)
  358. {
  359. if (foodData.ID != KaraokeDataManager.FoodData.ID_BUTTON_MAID_ADDITIONAL || KaraokeDataManager.IsEnablePersonalKaraoke003(GameMain.Instance.CharacterMgr.GetMaid(0)))
  360. {
  361. list.Add(foodData);
  362. }
  363. }
  364. return list.ToArray();
  365. }
  366. private KaraokeDataManager.BackgroundData[] GetBackgroundDataArray()
  367. {
  368. return this.m_Manager.GetBackgroundDataArray(true);
  369. }
  370. private KaraokeDataManager.MusicData GetMusicData(int musicID)
  371. {
  372. return this.m_Manager.GetMusicData(musicID);
  373. }
  374. private KaraokeDataManager.FoodData GetFoodData(int foodID)
  375. {
  376. return this.GetFoodDataArray()[foodID];
  377. }
  378. private KaraokeDataManager.BackgroundData GetBackgroundData(int backgroundID)
  379. {
  380. return this.GetBackgroundDataArray()[backgroundID];
  381. }
  382. private int GetNowBackgroundDataIndex()
  383. {
  384. return this.m_Manager.GetNowBGIndex();
  385. }
  386. private int GetNowSelectingBackgroundDataIndex()
  387. {
  388. return this.m_Manager.GetNowSelectingBGIndex();
  389. }
  390. public void StartKaraoke()
  391. {
  392. this.m_Manager.StartKaraoke(this.m_SelectingMusicDataID);
  393. }
  394. public void EndKaraoke()
  395. {
  396. this.m_Manager.ButtonExit();
  397. }
  398. private void StartFood(int index)
  399. {
  400. this.m_Manager.SetFoodData(this.GetFoodDataArray()[index].ID);
  401. }
  402. private void SetBG(int index)
  403. {
  404. this.m_Manager.SetBGIndex(index);
  405. }
  406. [SerializeField]
  407. private KaraokeDataManager m_Manager;
  408. [SerializeField]
  409. private Button m_ButtonOK;
  410. [SerializeField]
  411. private Button m_ButtonCANCEL;
  412. [SerializeField]
  413. private Button m_ButtonStart;
  414. [SerializeField]
  415. private Button m_ButtonEnd;
  416. [SerializeField]
  417. private Toggle m_ButtonSelectMusic;
  418. [SerializeField]
  419. private Toggle m_ButtonSelectBG;
  420. [SerializeField]
  421. private Toggle m_ButtonSelectFood;
  422. [SerializeField]
  423. private RectTransform m_ParentUIListViewer;
  424. [SerializeField]
  425. private RectTransform m_UIListViewerObject;
  426. private uGUIKaraokeSelect.uGUIItemListViewer m_UIListViewer;
  427. [Space(16f)]
  428. [SerializeField]
  429. private RectTransform m_ImageLines;
  430. private GameObject m_BeforeSelectedGameObject;
  431. private int m_SelectingMusicDataID;
  432. private int m_SelectingFoodDataIndex;
  433. private const string ThumbnailPath = "SceneVRCommunication/Tablet/Karaoke/Sprite/";
  434. private class uGUIItemListViewer : MonoBehaviour
  435. {
  436. public GameObject showArea
  437. {
  438. get
  439. {
  440. return this.m_ShowArea;
  441. }
  442. set
  443. {
  444. this.m_ShowArea = value;
  445. }
  446. }
  447. public GameObject tempItem
  448. {
  449. get
  450. {
  451. return this.m_TempItem;
  452. }
  453. set
  454. {
  455. this.m_TempItem = value;
  456. }
  457. }
  458. public List<GameObject> itemList
  459. {
  460. get
  461. {
  462. return this.m_ItemList;
  463. }
  464. }
  465. public void Show(GameObject showArea, int itemCount, GameObject tempItem = null, Action<int, GameObject> eventItemSetting = null)
  466. {
  467. if (showArea)
  468. {
  469. this.m_ShowArea = showArea;
  470. }
  471. else if (!this.m_ShowArea)
  472. {
  473. this.FindShowArea();
  474. }
  475. if (!this.m_ShowArea)
  476. {
  477. return;
  478. }
  479. if (tempItem)
  480. {
  481. this.m_TempItem = tempItem;
  482. }
  483. else if (!this.m_TempItem)
  484. {
  485. this.FindItemTemplate();
  486. }
  487. if (!this.m_ShowArea || !this.m_TempItem)
  488. {
  489. return;
  490. }
  491. if (!this.m_ShowArea.activeSelf)
  492. {
  493. this.m_ShowArea.SetActive(true);
  494. }
  495. if (this.m_TempItem.activeSelf)
  496. {
  497. this.m_TempItem.SetActive(false);
  498. }
  499. this.Clear();
  500. Transform transform = this.m_ShowArea.transform;
  501. for (int i = 0; i < itemCount; i++)
  502. {
  503. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_TempItem);
  504. gameObject.SetActive(true);
  505. gameObject.transform.SetParent(transform, false);
  506. if (eventItemSetting != null)
  507. {
  508. eventItemSetting(i, gameObject);
  509. }
  510. this.m_ItemList.Add(gameObject);
  511. }
  512. }
  513. public void Show(int itemCount, Action<int, GameObject> eventItemSetting = null)
  514. {
  515. this.Show(this.m_ShowArea, itemCount, this.m_TempItem, eventItemSetting);
  516. }
  517. public void Clear()
  518. {
  519. if (!this.m_ShowArea)
  520. {
  521. return;
  522. }
  523. if (this.m_ItemList == null)
  524. {
  525. return;
  526. }
  527. for (int i = 0; i < this.m_ItemList.Count; i++)
  528. {
  529. UnityEngine.Object.Destroy(this.m_ItemList[i]);
  530. }
  531. }
  532. private void FindItemTemplate()
  533. {
  534. if (!this.m_ShowArea)
  535. {
  536. return;
  537. }
  538. if (this.m_ShowArea.transform.childCount <= 0)
  539. {
  540. return;
  541. }
  542. Transform transform = this.FindChildDeep(this.m_ShowArea.transform, "Temp Item", true);
  543. if (!transform)
  544. {
  545. transform = this.m_ShowArea.transform.GetChild(0);
  546. }
  547. this.m_TempItem = transform.gameObject;
  548. }
  549. private void FindShowArea()
  550. {
  551. Transform transform = base.transform.parent;
  552. if (!transform)
  553. {
  554. transform = base.transform;
  555. }
  556. string text = "Content";
  557. Transform transform2 = this.FindChildDeep(transform, text, true);
  558. if (!transform2)
  559. {
  560. Debug.LogError(string.Format("[Karaoke.uGUIItemListViewer]項目を並べるエリアが見つかりませんでした\n検索名:{0}", text));
  561. return;
  562. }
  563. this.m_ShowArea = transform2.gameObject;
  564. }
  565. private Transform FindChildDeep(Component self, string name, bool includeInactive = false)
  566. {
  567. Transform[] componentsInChildren = self.GetComponentsInChildren<Transform>(includeInactive);
  568. for (int i = 0; i < componentsInChildren.Length; i++)
  569. {
  570. if (componentsInChildren[i].name == name)
  571. {
  572. return componentsInChildren[i];
  573. }
  574. }
  575. return null;
  576. }
  577. private GameObject m_ShowArea;
  578. private GameObject m_TempItem;
  579. private List<GameObject> m_ItemList = new List<GameObject>();
  580. }
  581. private class uGUIItemListButton : MonoBehaviour
  582. {
  583. public int number = -1;
  584. }
  585. }