UIButtonKeys.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. [AddComponentMenu("NGUI/Interaction/Button Keys (Legacy)")]
  5. public class UIButtonKeys : UIKeyNavigation
  6. {
  7. protected override void OnEnable()
  8. {
  9. this.Upgrade();
  10. base.OnEnable();
  11. }
  12. public void Upgrade()
  13. {
  14. if (this.onClick == null && this.selectOnClick != null)
  15. {
  16. this.onClick = this.selectOnClick.gameObject;
  17. this.selectOnClick = null;
  18. NGUITools.SetDirty(this);
  19. }
  20. if (this.onLeft == null && this.selectOnLeft != null)
  21. {
  22. this.onLeft = this.selectOnLeft.gameObject;
  23. this.selectOnLeft = null;
  24. NGUITools.SetDirty(this);
  25. }
  26. if (this.onRight == null && this.selectOnRight != null)
  27. {
  28. this.onRight = this.selectOnRight.gameObject;
  29. this.selectOnRight = null;
  30. NGUITools.SetDirty(this);
  31. }
  32. if (this.onUp == null && this.selectOnUp != null)
  33. {
  34. this.onUp = this.selectOnUp.gameObject;
  35. this.selectOnUp = null;
  36. NGUITools.SetDirty(this);
  37. }
  38. if (this.onDown == null && this.selectOnDown != null)
  39. {
  40. this.onDown = this.selectOnDown.gameObject;
  41. this.selectOnDown = null;
  42. NGUITools.SetDirty(this);
  43. }
  44. }
  45. public UIButtonKeys selectOnClick;
  46. public UIButtonKeys selectOnUp;
  47. public UIButtonKeys selectOnDown;
  48. public UIButtonKeys selectOnLeft;
  49. public UIButtonKeys selectOnRight;
  50. }