From 97c017998ac092bc0c34aa852e52782a18e49a76 Mon Sep 17 00:00:00 2001 From: JR-Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:42:06 +0100 Subject: [PATCH] Fixed bug with object selection in speckle playground that caused an exception to be thrown on send --- Assets/Extra/Selectable.cs | 2 + Assets/Extra/SelectionManager.cs | 7 +- Assets/InteractionLogic.cs | 5 +- .../Editor/StreamManagerEditor.cs | 12 +- Assets/Speckle Connector/Receiver.cs | 2 +- .../Speckle Connector/RecursiveConverter.cs | 4 +- Assets/Speckle Connector/StreamManager.cs | 1 + Packages/manifest.json | 6 +- Packages/packages-lock.json | 18 +- ProjectSettings/ProjectVersion.txt | 4 +- ProjectSettings/SceneTemplateSettings.json | 167 ++++++++++++++++++ 11 files changed, 204 insertions(+), 24 deletions(-) create mode 100644 ProjectSettings/SceneTemplateSettings.json diff --git a/Assets/Extra/Selectable.cs b/Assets/Extra/Selectable.cs index 116395e..33f9d86 100644 --- a/Assets/Extra/Selectable.cs +++ b/Assets/Extra/Selectable.cs @@ -4,6 +4,7 @@ using UnityEngine; //Thanks to : https://sharpcoderblog.com/blog/unity-3d-rts-style-unit-selection +[AddComponentMenu("Speckle/Playground/Selectable"), DisallowMultipleComponent] public class Selectable : MonoBehaviour { @@ -43,6 +44,7 @@ public class Selectable : MonoBehaviour if (SelectionManager.selectables.Contains(this)) { SelectionManager.selectables.Remove(this); + SelectionManager.selectedObjects.Remove(this); } } } \ No newline at end of file diff --git a/Assets/Extra/SelectionManager.cs b/Assets/Extra/SelectionManager.cs index e3340c9..41c0c70 100644 --- a/Assets/Extra/SelectionManager.cs +++ b/Assets/Extra/SelectionManager.cs @@ -4,6 +4,7 @@ using UnityEngine; using UnityEngine.EventSystems; //Thanks to : https://sharpcoderblog.com/blog/unity-3d-rts-style-unit-selection +[AddComponentMenu("Speckle/Playground/Selection Manager"), DisallowMultipleComponent] public class SelectionManager : MonoBehaviour { public Texture topLeftBorder; @@ -32,7 +33,7 @@ public class SelectionManager : MonoBehaviour Vector3 mousePosition1; public static List selectables = new List(); - public static List selectedObjects = new List(); + public static List selectedObjects = new List(); // Update is called once per frame void Update() @@ -66,7 +67,7 @@ public class SelectionManager : MonoBehaviour Bounds viewportBounds = GetViewportBounds(camera, mousePosition1, Input.mousePosition); if (viewportBounds.Contains(camera.WorldToViewportPoint(selectables[i].transform.position))) { - selectedObjects.Add(i); + selectedObjects.Add(selectables[i]); } } } @@ -86,7 +87,7 @@ public class SelectionManager : MonoBehaviour Camera camera = Camera.main; for (int i = 0; i < selectedObjects.Count; i++) { - DrawSelectionIndicator(camera, selectables[selectedObjects[i]].GetObjectBounds()); + DrawSelectionIndicator(camera, selectedObjects[i].GetObjectBounds()); } } } diff --git a/Assets/InteractionLogic.cs b/Assets/InteractionLogic.cs index 266059c..87a517e 100644 --- a/Assets/InteractionLogic.cs +++ b/Assets/InteractionLogic.cs @@ -106,7 +106,6 @@ namespace Speckle.ConnectorUnity InitRemove(); var sender = gameObject.AddComponent(); - //sender.Stream = stream; var btn = gameObject.transform.Find("Btn").GetComponentInChildren