GUIGameObjectField.cs 1.9 KB

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