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 virtual void SetParent(GUILayout layout)
  11. {
  12. if (parent != null)
  13. parent.RemoveInternal(this);
  14. parent = layout;
  15. }
  16. internal virtual bool IsStatic()
  17. {
  18. return false;
  19. }
  20. public virtual void Destroy()
  21. {
  22. SetParent(null);
  23. Internal_Destroy(mCachedPtr);
  24. isDestroyed = true;
  25. }
  26. public bool IsDestroyed()
  27. {
  28. return isDestroyed;
  29. }
  30. public void SetVisible(bool visible)
  31. {
  32. Internal_SetVisible(mCachedPtr, visible);
  33. }
  34. public void SetLayoutOptions(params GUIOption[] options)
  35. {
  36. Internal_SetLayoutOptions(mCachedPtr, options);
  37. }
  38. [MethodImpl(MethodImplOptions.InternalCall)]
  39. private static extern void Internal_SetLayoutOptions(IntPtr nativeInstance, GUIOption[] options);
  40. [MethodImpl(MethodImplOptions.InternalCall)]
  41. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. private static extern void Internal_Destroy(IntPtr nativeInstance);
  44. }
  45. }