FunctionOpenView.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 _effectObj;
  12. private GoWrapper _wrapper;
  13. public override void Dispose()
  14. {
  15. base.Dispose();
  16. }
  17. protected override void OnInit()
  18. {
  19. base.OnInit();
  20. packageName = UI_FunctionOpenUI.PACKAGE_NAME;
  21. _ui = UI_FunctionOpenUI.Create();
  22. this.viewCom = _ui.target;
  23. isfullScreen = true;
  24. this.viewCom.Center();
  25. this.modal = true;
  26. this.clickBlankToClose = false;
  27. }
  28. protected override void OnShown()
  29. {
  30. base.OnShown();
  31. List<string> funList = (viewData as object) as List<string>;
  32. AddFunDatas(funList);
  33. UpdateFunIcon();
  34. }
  35. private void AddFunDatas(List<string> itemList)
  36. {
  37. for (int i = 0; i < itemList.Count; i++)
  38. {
  39. if (_funList.IndexOf(itemList[i]) < 0)
  40. {
  41. _funList.Add(itemList[i]);
  42. }
  43. }
  44. }
  45. private void UpdateFunIcon()
  46. {
  47. if (_funList.Count == 0)
  48. {
  49. this.Hide();
  50. return;
  51. }
  52. string resPath = ResPathUtil.GetViewEffectPath("ui_xjs", "ui_xjs");
  53. SceneController.AddObjectToView(_effectObj, _wrapper, _ui.m_holder, resPath, out _effectObj, out _wrapper);
  54. FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(_funList[0]);
  55. _ui.m_ComFunctionOpen.m_txtName.text = cfg.name;
  56. _ui.m_ComFunctionOpen.m_logIcon.url = ResPathUtil.GetCommonGameResPath(cfg.res);
  57. _funList.RemoveAt(0);
  58. _ui.m_t0.Play(UpdateFunIcon);
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. }
  64. }
  65. }