GUIToggleField.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. public sealed class GUIToggleField : GUIElement
  7. {
  8. public delegate void OnChangedDelegate(bool newValue);
  9. public event OnChangedDelegate OnChanged;
  10. public bool Value
  11. {
  12. get
  13. {
  14. bool value;
  15. Internal_GetValue(mCachedPtr, out value);
  16. return value;
  17. }
  18. set { Internal_SetValue(mCachedPtr, value); }
  19. }
  20. public GUIToggleField(GUIContent title, int titleWidth = 100, string style = "", params GUIOption[] options)
  21. {
  22. Internal_CreateInstance(this, title, titleWidth, style, options, true);
  23. }
  24. public GUIToggleField(string style = "", params GUIOption[] options)
  25. {
  26. Internal_CreateInstance(this, null, 0, style, options, false);
  27. }
  28. private void DoOnChanged(bool newValue)
  29. {
  30. if (OnChanged != null)
  31. OnChanged(newValue);
  32. }
  33. [MethodImpl(MethodImplOptions.InternalCall)]
  34. private static extern void Internal_CreateInstance(GUIToggleField instance, GUIContent title, int titleWidth,
  35. string style, GUIOption[] options, bool withTitle);
  36. [MethodImpl(MethodImplOptions.InternalCall)]
  37. private static extern void Internal_GetValue(IntPtr nativeInstance, out bool value);
  38. [MethodImpl(MethodImplOptions.InternalCall)]
  39. private static extern void Internal_SetValue(IntPtr nativeInstance, bool value);
  40. }
  41. }