GUIVector2Field.cs 2.2 KB

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