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>(); public List<Material> materials = new List<Material>();
private int targetWidth = 0; private int targetWidth = 0;
public bool debugGui = false;
private void Awake() private void Awake()
{ {
@ -68,6 +69,30 @@ namespace TAO.InteractiveMask
maskCamera.transform.position = newPos; 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 public enum Mode
{ {
EachFrame, 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() private void OnValidate()
{ {
if (clearBlit == null) if (clearBlit == null)
@ -61,9 +72,7 @@ namespace TAO.InteractiveMask
} }
} }
private void OnGUI() public void GUI()
{
if (debugGui)
{ {
using (new GUILayout.HorizontalScope()) using (new GUILayout.HorizontalScope())
{ {
@ -87,7 +96,6 @@ namespace TAO.InteractiveMask
} }
} }
} }
}
private void GUITexture(Texture texture) private void GUITexture(Texture texture)
{ {
@ -171,6 +179,14 @@ namespace TAO.InteractiveMask
} }
} }
public void Clear(Material clearBlit)
{
if (PersistentTarget)
{
Graphics.Blit(PersistentTarget, PersistentTarget, clearBlit);
}
}
public enum Type public enum Type
{ {
Clear, Clear,