BaseWitWindow.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. using Meta.WitAi.Data.Configuration;
  9. using UnityEditor;
  10. using UnityEngine;
  11. namespace Meta.WitAi.Windows
  12. {
  13. public abstract class BaseWitWindow : EditorWindow
  14. {
  15. // Scroll offset
  16. private Vector2 ScrollOffset;
  17. // Override values
  18. protected abstract GUIContent Title { get; }
  19. protected virtual Texture2D HeaderIcon => WitTexts.HeaderIcon;
  20. protected virtual string HeaderUrl => WitTexts.WitUrl;
  21. protected virtual string DocsUrl => WitTexts.Texts.WitDocsUrl;
  22. // Window open
  23. protected virtual void OnEnable()
  24. {
  25. titleContent = Title;
  26. WitConfigurationUtility.ReloadConfigurationData();
  27. }
  28. // Window close
  29. protected virtual void OnDisable()
  30. {
  31. ScrollOffset = Vector2.zero;
  32. }
  33. // Handle Layout
  34. protected virtual void OnGUI()
  35. {
  36. Vector2 size;
  37. WitEditorUI.LayoutWindow(Title.text, HeaderIcon, HeaderUrl, DocsUrl, LayoutContent, ref ScrollOffset, out size);
  38. }
  39. // Draw content of window
  40. protected abstract void LayoutContent();
  41. }
  42. }