AdvertisementView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. * Copyright (c) 2018 ~ 2020.10 liangxie
  3. *
  4. * https://qframework.cn
  5. * https://github.com/liangxiegame/QFramework
  6. * https://gitee.com/liangxiegame/QFramework
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. ****************************************************************************/
  26. using System.ComponentModel;
  27. using UnityEditor;
  28. using UnityEngine;
  29. namespace QFramework
  30. {
  31. [DisplayName("技术支持")]
  32. [PackageKitGroup("QFramework")]
  33. [PackageKitRenderOrder(int.MinValue)]
  34. public class AdvertisementView : IPackageKitView
  35. {
  36. private IXMLView mView = null;
  37. public EditorWindow EditorWindow { get; set; }
  38. public void Init()
  39. {
  40. var convertSystem = XMLKit.Get.SystemLayer.Get<IXMLToObjectConvertSystem>();
  41. if (!convertSystem.ContainsModule("EasyIMGUI"))
  42. {
  43. convertSystem.AddModule("EasyIMGUI", new EasyIMGUIXMLModule());
  44. }
  45. var easyIMGUIModule = convertSystem.GetConvertModule("EasyIMGUI");
  46. easyIMGUIModule.RegisterConverter("SupportItem",
  47. new CustomXMLToObjectConverter<AdvertisementItemView>(node =>
  48. new AdvertisementItemView(node.Attributes["Title"].Value, node.Attributes["Link"].Value)));
  49. mView = EasyIMGUI.XMLView();
  50. var supportAsset = Resources.Load<TextAsset>("Support") as TextAsset;
  51. mView.LoadXMLContent(supportAsset.text);
  52. }
  53. public void OnUpdate()
  54. {
  55. }
  56. public void OnGUI()
  57. {
  58. mView.DrawGUI();
  59. }
  60. public void OnWindowGUIEnd()
  61. {
  62. }
  63. public void OnDispose()
  64. {
  65. mView.Dispose();
  66. }
  67. public void OnShow()
  68. {
  69. }
  70. public void OnHide()
  71. {
  72. }
  73. public class LocalText
  74. {
  75. public static string TechSupport
  76. {
  77. get { return Language.IsChinese ? "技术支持" : "Tech Support"; }
  78. }
  79. }
  80. }
  81. }