EditorWindow.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. public class EditorWindow : ScriptObject
  7. {
  8. internal int width { get { return Internal_GetWidth(); } }
  9. internal int height { get { return Internal_GetHeight(); } }
  10. protected GUIPanel GUI;
  11. public static EditorWindow OpenWindow<T>() where T : EditorWindow
  12. {
  13. return Internal_CreateOrGetInstance(typeof(T).Namespace, typeof(T).Name);
  14. }
  15. protected EditorWindow()
  16. {
  17. GUI = CreatePanel(0, 0, width, height);
  18. }
  19. protected virtual void WindowResized(int width, int height)
  20. {
  21. GUI.SetArea(0, 0, width, height);
  22. }
  23. internal GUIPanel CreatePanel(int x, int y, int width, int height)
  24. {
  25. GUIPanel newPanel = Internal_CreateGUIPanel(mCachedPtr);
  26. newPanel.SetArea(x, y, width, height);
  27. return newPanel;
  28. }
  29. [MethodImpl(MethodImplOptions.InternalCall)]
  30. private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
  31. [MethodImpl(MethodImplOptions.InternalCall)]
  32. private static extern GUIPanel Internal_CreateGUIPanel(IntPtr nativeInstance);
  33. [MethodImpl(MethodImplOptions.InternalCall)]
  34. private static extern int Internal_GetWidth();
  35. [MethodImpl(MethodImplOptions.InternalCall)]
  36. private static extern int Internal_GetHeight();
  37. }
  38. }