10 [Tooltip(
"The room model to use when loading meshes in Unity.")]
13 [Tooltip(
"If greater than or equal to zero, surface objects will claim to be updated at this period. This is useful when working with libraries that respond to updates (such as the SpatialUnderstanding library). If negative, surfaces will not claim to be updated.")]
14 public float SimulatedUpdatePeriodInSeconds = -1;
18 #if UNITY_2017_2_OR_NEWER 19 if (!
UnityEngine.XR.XRDevice.isPresent && Application.isEditor)
21 if (!
UnityEngine.VR.VRDevice.isPresent && Application.isEditor)
27 if (GetMeshFilters().Count > 0)
38 public void Load(GameObject roomModel)
40 if (roomModel == null)
42 Debug.Log(
"No room model specified.");
46 GameObject roomObject = Instantiate(roomModel);
51 MeshFilter[] roomFilters = roomObject.GetComponentsInChildren<MeshFilter>();
53 for (
int iMesh = 0; iMesh < roomFilters.Length; iMesh++)
55 MeshFilter meshFilter = roomFilters[iMesh];
58 mesh: meshFilter.sharedMesh,
59 objectName:
"roomMesh-" + iMesh,
60 parentObject: transform,
64 newSurfaceObject.
Object.transform.localPosition = meshFilter.transform.position;
65 newSurfaceObject.
Object.transform.localRotation = meshFilter.transform.rotation;
67 AddSurfaceObject(newSurfaceObject);
72 Debug.Log(
"Failed to load object " + roomModel.name);
76 if (roomObject != null)
78 DestroyImmediate(roomObject);
83 private float lastUpdateUnscaledTimeInSeconds = 0;
87 if (SimulatedUpdatePeriodInSeconds >= 0)
89 if ((Time.unscaledTime - lastUpdateUnscaledTimeInSeconds) >= SimulatedUpdatePeriodInSeconds)
91 for (
int iSurface = 0; iSurface < SurfaceObjects.Count; iSurface++)
93 UpdateOrAddSurfaceObject(SurfaceObjects[iSurface]);
96 lastUpdateUnscaledTimeInSeconds = Time.unscaledTime;