Singularity/Library/PackageCache/com.unity.2d.animation@7.0.10/Editor/SkinningModule/MeshPreviewTool/MeshPreviewBehaviour.cs
2024-05-06 11:45:45 -07:00

74 lines
1.9 KiB
C#

using System;
using UnityEngine;
namespace UnityEditor.U2D.Animation
{
internal class DefaultPreviewBehaviour : IMeshPreviewBehaviour
{
public float GetWeightMapOpacity(SpriteCache sprite)
{
return 0f;
}
public bool DrawWireframe(SpriteCache sprite)
{
return false;
}
public bool Overlay(SpriteCache sprite)
{
return false;
}
public bool OverlayWireframe(SpriteCache sprite)
{
return sprite.IsVisible() && sprite.skinningCache.selectedSprite == sprite;
}
}
internal class MeshPreviewBehaviour : IMeshPreviewBehaviour
{
public bool showWeightMap { get; set; }
public bool drawWireframe { get; set; }
public bool overlaySelected { get; set; }
public float GetWeightMapOpacity(SpriteCache sprite)
{
var skinningCache = sprite.skinningCache;
if (showWeightMap)
{
if (skinningCache.selectedSprite == sprite || skinningCache.selectedSprite == null)
return VisibilityToolSettings.meshOpacity;
}
return 0f;
}
public bool DrawWireframe(SpriteCache sprite)
{
var skinningCache = sprite.skinningCache;
if (drawWireframe)
return skinningCache.selectedSprite == null;
return false;
}
public bool Overlay(SpriteCache sprite)
{
var skinningCache = sprite.skinningCache;
if (overlaySelected && skinningCache.selectedSprite == sprite)
return true;
return false;
}
public bool OverlayWireframe(SpriteCache sprite)
{
return sprite.IsVisible() && sprite.skinningCache.selectedSprite == sprite;
}
}
}