Clear Function

- Clear function.
- GUI moved to Camera.
This commit is contained in:
max 2021-03-03 17:50:44 +01:00
parent 4bd5e53592
commit 4489e3311c
2 changed files with 60 additions and 19 deletions

View File

@ -18,6 +18,7 @@ namespace TAO.InteractiveMask
public List<Material> materials = new List<Material>();
private int targetWidth = 0;
public bool debugGui = false;
private void Awake()
{
@ -68,6 +69,30 @@ namespace TAO.InteractiveMask
maskCamera.transform.position = newPos;
}
private void OnGUI()
{
if (debugGui)
{
using (new GUILayout.VerticalScope())
{
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Render"))
{
Render();
}
if (GUILayout.Button("MaskRenderer.Clear"))
{
maskRenderer.Clear();
}
}
}
maskRenderer.GUI();
}
}
public enum Mode
{
EachFrame,

View File

@ -37,6 +37,17 @@ namespace TAO.InteractiveMask
}
}
// Clears the context of the render targets.
public void Clear()
{
Graphics.Blit(target, target, clearBlitMaterial);
foreach (Layer layer in layers)
{
layer.Clear(clearBlitMaterial);
}
}
private void OnValidate()
{
if (clearBlit == null)
@ -61,29 +72,26 @@ namespace TAO.InteractiveMask
}
}
private void OnGUI()
public void GUI()
{
if (debugGui)
using (new GUILayout.HorizontalScope())
{
using (new GUILayout.HorizontalScope())
{
GUITexture(source);
GUITexture(target);
GUITexture(source);
GUITexture(target);
foreach (var l in layers)
foreach (var l in layers)
{
switch (l.type)
{
switch (l.type)
{
case Layer.Type.Clear:
break;
case Layer.Type.Persistent:
{
GUITexture(l.PersistentTarget);
}
break;
default:
break;
}
case Layer.Type.Clear:
break;
case Layer.Type.Persistent:
{
GUITexture(l.PersistentTarget);
}
break;
default:
break;
}
}
}
@ -171,6 +179,14 @@ namespace TAO.InteractiveMask
}
}
public void Clear(Material clearBlit)
{
if (PersistentTarget)
{
Graphics.Blit(PersistentTarget, PersistentTarget, clearBlit);
}
}
public enum Type
{
Clear,