2
0

GUIElement.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. namespace BansheeEngine
  5. {
  6. public abstract class GUIElement : ScriptObject
  7. {
  8. protected GUILayout parent;
  9. private bool isDestroyed;
  10. internal void SetParent(GUILayout layout)
  11. {
  12. if (parent != null)
  13. parent.Remove(this);
  14. parent = layout;
  15. if (parent != null)
  16. parent.children.Add(this);
  17. Internal_SetParent(mCachedPtr, layout);
  18. }
  19. internal virtual bool IsStatic()
  20. {
  21. return false;
  22. }
  23. public virtual void Destroy()
  24. {
  25. SetParent(null);
  26. Internal_Destroy(mCachedPtr);
  27. isDestroyed = true;
  28. }
  29. public bool IsDestroyed()
  30. {
  31. return isDestroyed;
  32. }
  33. public void SetVisible(bool visible)
  34. {
  35. Internal_SetVisible(mCachedPtr, visible);
  36. }
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern void Internal_SetParent(IntPtr nativeInstance, GUILayout parent);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern void Internal_Destroy(IntPtr nativeInstance);
  43. }
  44. }