瀏覽代碼

Instantiate Lazy in Awake

Nick Steyer 1 年之前
父節點
當前提交
0df528542d
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      Assets/ZED/Examples/Object Detection/Scripts/ZED3DObjectVisualizer.cs

+ 6 - 1
Assets/ZED/Examples/Object Detection/Scripts/ZED3DObjectVisualizer.cs

@@ -24,7 +24,7 @@ public class ZED3DObjectVisualizer : MonoBehaviour
              "If you want to visualize detections from multiple ZEDs at once you will need multiple ZED3DObjectVisualizer commponents in the scene. ")]
     IZEDManager ZedManager => zedManagerLazy.Value;
 
-    readonly Lazy<IZEDManager> zedManagerLazy = new(new LoggingZEDManager(FindObjectOfType<ZEDManager>(), new DetectionFrameLogger()));
+    Lazy<IZEDManager> zedManagerLazy;
 
     /// <summary>
     /// If true, the ZED Object Detection manual will be started as soon as the ZED is initiated.
@@ -141,6 +141,11 @@ public class ZED3DObjectVisualizer : MonoBehaviour
     /// </summary>
     private int nextColorIndex = 0;
 
+    private void Awake()
+    {
+        zedManagerLazy = new(new LoggingZEDManager(FindObjectOfType<ZEDManager>(), new DetectionFrameLogger()));
+    }
+
     // Use this for initialization
     void Start()
     {