From 7591bfb642a0fb2fc93fc25768e8e5fe055039ea Mon Sep 17 00:00:00 2001 From: Dan Birman Date: Sun, 10 Sep 2023 11:18:04 -0700 Subject: [PATCH] feat: adding the ability to clear primitives --- API/oursin/renderer.py | 7 ++++++- UnityClient/Assets/Scripts/Client.cs | 3 +++ .../Assets/Scripts/Managers/PrimitiveMeshManager.cs | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/API/oursin/renderer.py b/API/oursin/renderer.py index 99dec083..a068bbeb 100644 --- a/API/oursin/renderer.py +++ b/API/oursin/renderer.py @@ -76,4 +76,9 @@ def clear_volumes(): def clear_texts(): """Clear all text """ - client.sio.emit('Clear', 'texts') \ No newline at end of file + client.sio.emit('Clear', 'texts') + +def clear_primitives(): + """Clear all primitives + """ + client.sio.emit('Clear','primitives') \ No newline at end of file diff --git a/UnityClient/Assets/Scripts/Client.cs b/UnityClient/Assets/Scripts/Client.cs index a2136445..1db9911c 100644 --- a/UnityClient/Assets/Scripts/Client.cs +++ b/UnityClient/Assets/Scripts/Client.cs @@ -226,6 +226,9 @@ private void Clear(string val) case "texts": _textManager.Clear(); break; + case "primitives": + _primitiveMeshManager.Clear(); + break; } } diff --git a/UnityClient/Assets/Scripts/Managers/PrimitiveMeshManager.cs b/UnityClient/Assets/Scripts/Managers/PrimitiveMeshManager.cs index 184ac030..ad70c232 100644 --- a/UnityClient/Assets/Scripts/Managers/PrimitiveMeshManager.cs +++ b/UnityClient/Assets/Scripts/Managers/PrimitiveMeshManager.cs @@ -43,6 +43,15 @@ private void Awake() } } + public void Clear() + { + foreach (var kvp in _primMeshRenderers) + { + Destroy(kvp.Value.gameObject); + } + _primMeshRenderers.Clear(); + } + public void DeleteMesh(List meshes) { foreach (string mesh in meshes)