CapersProject/Assets/Plugins/AllIn1SpriteShader/Scripts/TrueShadowCompatibility.cs
2025-02-21 15:31:50 +09:00

39 lines
1007 B
C#

#if LETAI_TRUESHADOW
using LeTai.TrueShadow;
using LeTai.TrueShadow.PluginInterfaces;
using UnityEngine;
namespace AllIn1SpriteShader
{
[ExecuteAlways]
public class TrueShadowCompatibility : MonoBehaviour, ITrueShadowCustomHashProvider
{
[Tooltip("Use with animated effects")]
public bool updateTrueShadowEveryFrame = false;
private TrueShadow shadow;
public void UpdateTrueShadow()
{
if (!shadow) shadow = GetComponent<TrueShadow>();
if (!shadow) return;
UpdateTrueShadow(shadow);
}
public static void UpdateTrueShadow(TrueShadow shadow)
{
shadow.CustomHash = Random.Range(int.MinValue, int.MaxValue);
}
public void Update()
{
bool shouldDirty = updateTrueShadowEveryFrame;
#if UNITY_EDITOR
shouldDirty |= !Application.isPlaying;
#endif
if (shouldDirty)
UpdateTrueShadow();
}
}
}
#endif