GUIElement.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.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. public void SetLayoutOptions(params GUIOption[] options)
  38. {
  39. Internal_SetLayoutOptions(mCachedPtr, options);
  40. }
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern void Internal_SetParent(IntPtr nativeInstance, GUILayout parent);
  43. [MethodImpl(MethodImplOptions.InternalCall)]
  44. private static extern void Internal_SetLayoutOptions(IntPtr nativeInstance, GUIOption[] options);
  45. [MethodImpl(MethodImplOptions.InternalCall)]
  46. private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
  47. [MethodImpl(MethodImplOptions.InternalCall)]
  48. private static extern void Internal_Destroy(IntPtr nativeInstance);
  49. }
  50. }