Upload from upload_mods.ps1
This commit is contained in:
38
KFAttached/Render/MagnifyScopeTargetRef.cs
Normal file
38
KFAttached/Render/MagnifyScopeTargetRef.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user