/// <summary> /// Starts spatial mapping, which will scan the room and visualize this until the target time is reached, or it is manually stopped. /// </summary> public static void RunSpatialMapping(bool overrideExisting = false, float timeToScan = 60f) { WorldErrors.Print("WTF"); if (wrapper == null) { wrapper = new GameObject("SpatialWrapper").AddComponent <SpatialWrapper>(); } if (!running) { if (!SpatialInfoReady || overrideExisting) { targetTime = timeToScan; wrapper.StartCoroutine(DoMapping()); WorldErrors.Print("DO MAPPING"); } else { WorldErrors.Print("Eh: " + SpatialInfoReady + "," + overrideExisting); } } else { WorldErrors.Print("Already running"); } }
IEnumerator DoPlacement(int tries) { if (tries > 1) { yield break; } if (spatialMapIfNotAnchored) { SpatialWrapper.RunSpatialMapping(false); while (!SpatialWrapper.SpatialInfoReady) { yield return(null); } Vector3?customHalfDims = null; if (useCustomShape) { customHalfDims = customShape * .5f; } if (!PlacementWrapper.PlaceObject(deferredParent.gameObject, placementType, customHalfDims)) { WorldErrors.Print("Could not place object"); //retry in a little while yield return(new WaitForSeconds(10f)); DoPlacement(tries++); } else { WorldErrors.Print("Placed Object: " + anchorName); foreach (GameObject g in activateWhenPlaced) { g.SetActive(true); } } } yield return(null); }