BaseTool.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using UnityEditor.U2D.Layout;
  3. using UnityEngine;
  4. namespace UnityEditor.U2D.Animation
  5. {
  6. internal interface ITool {}
  7. internal abstract class BaseTool : SkinningObject, ITool
  8. {
  9. [SerializeField]
  10. private LayoutOverlay m_LayoutOverlay;
  11. internal LayoutOverlay layoutOverlay
  12. {
  13. get
  14. {
  15. return m_LayoutOverlay;
  16. }
  17. }
  18. [SerializeField]
  19. private bool m_IsActive = false;
  20. public bool isActive
  21. {
  22. get { return m_IsActive; }
  23. private set { m_IsActive = value; }
  24. }
  25. public virtual int defaultControlID { get { return 0; } }
  26. public virtual IMeshPreviewBehaviour previewBehaviour
  27. {
  28. get { return null; }
  29. }
  30. internal override void OnDestroy()
  31. {
  32. Deactivate();
  33. }
  34. public void Activate()
  35. {
  36. isActive = true;
  37. OnActivate();
  38. }
  39. public void Deactivate()
  40. {
  41. isActive = false;
  42. OnDeactivate();
  43. }
  44. public void DoGUI()
  45. {
  46. if (isActive)
  47. OnGUI();
  48. }
  49. public virtual void Initialize(LayoutOverlay layout)
  50. {
  51. m_LayoutOverlay = layout;
  52. }
  53. protected virtual void OnActivate() {}
  54. protected virtual void OnDeactivate() {}
  55. protected virtual void OnGUI() {}
  56. }
  57. }