GUIButton.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public sealed class GUIButton : GUIElement
  6. {
  7. public delegate void OnClickDelegate();
  8. public delegate void OnHoverDelegate();
  9. public delegate void OnOutDelegate();
  10. public event OnClickDelegate OnClick;
  11. public event OnHoverDelegate OnHover;
  12. public event OnOutDelegate OnOut;
  13. internal GUIButton(GUILayout parentLayout, GUIContent content, GUIElementStyle style, params GUIOption[] options)
  14. :base(parentLayout)
  15. {
  16. Internal_CreateInstance(this, parentLayout, content, style, options);
  17. }
  18. public void SetContent(GUIContent content)
  19. {
  20. Internal_SetContent(mCachedPtr, content);
  21. }
  22. private void DoOnClick()
  23. {
  24. if (OnClick != null)
  25. OnClick();
  26. }
  27. private void DoOnHover()
  28. {
  29. if (OnHover != null)
  30. OnHover();
  31. }
  32. private void DoOnOut()
  33. {
  34. if (OnOut != null)
  35. OnOut();
  36. }
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern void Internal_CreateInstance(GUIButton instance, GUILayout layout, GUIContent content, GUIElementStyle style, GUIOption[] options);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
  41. }
  42. }