UIManager.UIFormInstanceObject.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework.ObjectPool;
  8. namespace GameFramework.UI
  9. {
  10. internal sealed partial class UIManager : GameFrameworkModule, IUIManager
  11. {
  12. /// <summary>
  13. /// 界面实例对象。
  14. /// </summary>
  15. private sealed class UIFormInstanceObject : ObjectBase
  16. {
  17. private object m_UIFormAsset;
  18. private IUIFormHelper m_UIFormHelper;
  19. public UIFormInstanceObject()
  20. {
  21. m_UIFormAsset = null;
  22. m_UIFormHelper = null;
  23. }
  24. public static UIFormInstanceObject Create(string name, object uiFormAsset, object uiFormInstance, IUIFormHelper uiFormHelper)
  25. {
  26. if (uiFormAsset == null)
  27. {
  28. throw new GameFrameworkException("UI form asset is invalid.");
  29. }
  30. if (uiFormHelper == null)
  31. {
  32. throw new GameFrameworkException("UI form helper is invalid.");
  33. }
  34. UIFormInstanceObject uiFormInstanceObject = ReferencePool.Acquire<UIFormInstanceObject>();
  35. uiFormInstanceObject.Initialize(name, uiFormInstance);
  36. uiFormInstanceObject.m_UIFormAsset = uiFormAsset;
  37. uiFormInstanceObject.m_UIFormHelper = uiFormHelper;
  38. return uiFormInstanceObject;
  39. }
  40. public override void Clear()
  41. {
  42. base.Clear();
  43. m_UIFormAsset = null;
  44. m_UIFormHelper = null;
  45. }
  46. public override void Release(bool isShutdown)
  47. {
  48. m_UIFormHelper.ReleaseUIForm(m_UIFormAsset, Target);
  49. }
  50. }
  51. }
  52. }