FunctionOpenView.cs 2.3 KB

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