FunctionOpenView.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class FunctionOpenView : BaseWindow
  8. {
  9. private UI_FunctionOpenUI _ui;
  10. List<string> _funList = new List<string>();
  11. private GameObject _gameObject;
  12. private GoWrapper _wrapper;
  13. public override void Dispose()
  14. {
  15. SceneController.DestroyObjectFromView(_gameObject);
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. packageName = UI_FunctionOpenUI.PACKAGE_NAME;
  22. _ui = UI_FunctionOpenUI.Create();
  23. this.viewCom = _ui.target;
  24. isfullScreen = true;
  25. this.viewCom.Center();
  26. this.modal = true;
  27. this.clickBlankToClose = false;
  28. }
  29. protected override void OnShown()
  30. {
  31. base.OnShown();
  32. List<string> funList = (viewData as object) as List<string>;
  33. AddFunDatas(funList);
  34. UpdateFunIcon();
  35. }
  36. private void AddFunDatas(List<string> itemList)
  37. {
  38. for (int i = 0; i < itemList.Count; i++)
  39. {
  40. if (_funList.IndexOf(itemList[i]) < 0)
  41. {
  42. _funList.Add(itemList[i]);
  43. }
  44. }
  45. }
  46. private void UpdateFunIcon()
  47. {
  48. if (_funList.Count == 0)
  49. {
  50. this.Hide();
  51. return;
  52. }
  53. string resPath = ResPathUtil.GetViewEffectPath("ui_xjs", "ui_xjs");
  54. SceneController.AddObjectToView(_gameObject, _wrapper, _ui.m_holder, resPath, out _gameObject, out _wrapper);
  55. FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(_funList[0]);
  56. _ui.m_ComFunctionOpen.m_txtName.text = cfg.name;
  57. _ui.m_ComFunctionOpen.m_logIcon.url = ResPathUtil.GetCommonGameResPath(cfg.res);
  58. _funList.RemoveAt(0);
  59. _ui.m_t0.Play(UpdateFunIcon);
  60. }
  61. protected override void OnHide()
  62. {
  63. base.OnHide();
  64. }
  65. }
  66. }