Files
7d2dXG/Mods/0A-KFCommonUtilityLib/KFAttached/Render/MagnifyScopeTargetRef.cs
Nathaniel Cosford 062dfab2cd Patched
2025-05-30 01:04:40 +09:30

39 lines
984 B
C#

using System.Collections.Generic;
using UnityEngine;
namespace KFCommonUtilityLib.KFAttached.Render
{
[AddComponentMenu("")]
internal class MagnifyScopeTargetRef : MonoBehaviour
{
private HashSet<MagnifyScope> targets = new HashSet<MagnifyScope>();
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
foreach (var target in targets)
{
target.RenderImageCallback(source, destination);
}
Graphics.Blit(source, destination);
}
internal void AddTarget(MagnifyScope target)
{
if (targets.Count == 0)
{
enabled = true;
}
targets.Add(target);
}
internal void RemoveTarget(MagnifyScope target)
{
targets.Remove(target);
if(targets.Count == 0 )
{
enabled = false;
}
}
}
}