MeshPreviewBehaviour.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal class DefaultPreviewBehaviour : IMeshPreviewBehaviour
  6. {
  7. public float GetWeightMapOpacity(SpriteCache sprite)
  8. {
  9. return 0f;
  10. }
  11. public bool DrawWireframe(SpriteCache sprite)
  12. {
  13. return false;
  14. }
  15. public bool Overlay(SpriteCache sprite)
  16. {
  17. return false;
  18. }
  19. public bool OverlayWireframe(SpriteCache sprite)
  20. {
  21. return sprite.IsVisible() && sprite.skinningCache.selectedSprite == sprite;
  22. }
  23. }
  24. internal class MeshPreviewBehaviour : IMeshPreviewBehaviour
  25. {
  26. public bool showWeightMap { get; set; }
  27. public bool drawWireframe { get; set; }
  28. public bool overlaySelected { get; set; }
  29. public float GetWeightMapOpacity(SpriteCache sprite)
  30. {
  31. var skinningCache = sprite.skinningCache;
  32. if (showWeightMap)
  33. {
  34. if (skinningCache.selectedSprite == sprite || skinningCache.selectedSprite == null)
  35. return VisibilityToolSettings.meshOpacity;
  36. }
  37. return 0f;
  38. }
  39. public bool DrawWireframe(SpriteCache sprite)
  40. {
  41. var skinningCache = sprite.skinningCache;
  42. if (drawWireframe)
  43. return skinningCache.selectedSprite == null;
  44. return false;
  45. }
  46. public bool Overlay(SpriteCache sprite)
  47. {
  48. var skinningCache = sprite.skinningCache;
  49. if (overlaySelected && skinningCache.selectedSprite == sprite)
  50. return true;
  51. return false;
  52. }
  53. public bool OverlayWireframe(SpriteCache sprite)
  54. {
  55. return sprite.IsVisible() && sprite.skinningCache.selectedSprite == sprite;
  56. }
  57. }
  58. }