AssociateBonesScope.cs 843 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal class AssociateBonesScope : IDisposable
  6. {
  7. private bool m_Disposed;
  8. private bool m_AssociateBones;
  9. private SpriteCache m_Sprite;
  10. public AssociateBonesScope(SpriteCache sprite)
  11. {
  12. m_Sprite = sprite;
  13. m_AssociateBones = m_Sprite.AssociatePossibleBones();
  14. }
  15. ~AssociateBonesScope()
  16. {
  17. if (!m_Disposed)
  18. Debug.LogError("Scope was not disposed! You should use the 'using' keyword or manually call Dispose.");
  19. }
  20. public void Dispose()
  21. {
  22. if (m_Disposed)
  23. return;
  24. m_Disposed = true;
  25. if (m_AssociateBones)
  26. m_Sprite.DeassociateUnusedBones();
  27. }
  28. }
  29. }