HandTransitionBehavior.cs 971 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. public abstract class HandTransitionBehavior : MonoBehaviour
  6. {
  7. protected abstract void HandReset();
  8. protected abstract void HandFinish();
  9. protected virtual void Awake()
  10. {
  11. this.iHandModel = base.GetComponent<IHandModel>();
  12. if (this.iHandModel == null)
  13. {
  14. Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject");
  15. return;
  16. }
  17. this.iHandModel.OnBegin += this.HandReset;
  18. this.iHandModel.OnFinish += this.HandFinish;
  19. }
  20. protected virtual void OnDestroy()
  21. {
  22. IHandModel component = base.GetComponent<IHandModel>();
  23. if (component == null)
  24. {
  25. Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject");
  26. return;
  27. }
  28. component.OnBegin -= this.HandReset;
  29. component.OnFinish -= this.HandFinish;
  30. }
  31. protected IHandModel iHandModel;
  32. }
  33. }