GUIButton.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public sealed class GUIButton : ScriptObject
  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. {
  15. Internal_CreateInstance(this, parentLayout, content, style, options);
  16. }
  17. public void SetContent(GUIContent content)
  18. {
  19. Internal_SetContent(mCachedPtr, content);
  20. }
  21. private void DoOnClick()
  22. {
  23. if (OnClick != null)
  24. OnClick();
  25. }
  26. private void DoOnHover()
  27. {
  28. if (OnHover != null)
  29. OnHover();
  30. }
  31. private void DoOnOut()
  32. {
  33. if (OnOut != null)
  34. OnOut();
  35. }
  36. [MethodImpl(MethodImplOptions.InternalCall)]
  37. private static extern void Internal_CreateInstance(GUIButton instance, GUILayout layout, GUIContent content, GUIElementStyle style, GUIOption[] options);
  38. [MethodImpl(MethodImplOptions.InternalCall)]
  39. private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
  40. }
  41. }