public override void Update() { if (gRenderer != null) { gRenderer.enabled = MeshVisualization != GroundMeshVisualization.None; if (gRenderer.enabled) { if (MeshVisualization == GroundMeshVisualization.Debug) { gRenderer.renderState = SpatialMappingRenderer.RenderState.Visualization; } else { gRenderer.renderState = SpatialMappingRenderer.RenderState.Occlusion; } } if (gCollider != null) { if (Check(surfaceParent, gCollider.surfaceParent, gRenderer.surfaceParent, ref lastSurfaceParent)) { surfaceParent = gCollider.surfaceParent = gRenderer.surfaceParent = lastSurfaceParent; } if (Check(updateCountBeforeSpatialMappingCleanup, gCollider.numUpdatesBeforeRemoval, gRenderer.numUpdatesBeforeRemoval, ref lastUpdateCount)) { updateCountBeforeSpatialMappingCleanup = gCollider.numUpdatesBeforeRemoval = gRenderer.numUpdatesBeforeRemoval = lastUpdateCount; } if (Check(secondsBetweenSpatialMappingUpdates, gCollider.secondsBetweenUpdates, gRenderer.secondsBetweenUpdates, ref lastUpdateTime)) { secondsBetweenSpatialMappingUpdates = gCollider.secondsBetweenUpdates = gRenderer.secondsBetweenUpdates = lastUpdateTime; } if (Check(freezeUpdates, gCollider.freezeUpdates, gRenderer.freezeUpdates, ref lastFreezeUpdates)) { freezeUpdates = gCollider.freezeUpdates = gRenderer.freezeUpdates = lastFreezeUpdates; } if (Check(HalfBoxExtents, gCollider.halfBoxExtents, gRenderer.halfBoxExtents, ref lastHalfBox)) { HalfBoxExtents = gCollider.halfBoxExtents = gRenderer.halfBoxExtents = lastHalfBox; } if (Check(LODType, gCollider.lodType, gRenderer.lodType, ref lastLODType)) { LODType = gCollider.lodType = gRenderer.lodType = lastLODType; } if (Check(volumeType, gCollider.volumeType, gRenderer.volumeType, ref lastVolumeType)) { volumeType = gCollider.volumeType = gRenderer.volumeType = lastVolumeType; } } } base.Update(); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField(s_GeneralSettingsLabelContent, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_SurfaceParentProp, s_SurfaceParentLabelContent); EditorGUILayout.PropertyField(m_FreezeUpdatesProp, s_FreezeUpdatesLabelContent); EditorGUILayout.PropertyField(m_SecondsBetweenUpdatesProp, s_TimeBetweenUpdatesLabelContent); if (m_NumUpdatesBeforeRemovalProp.intValue <= 0) { Rect removeImmediatelyRect = EditorGUILayout.GetControlRect(true); EditorGUI.BeginProperty(removeImmediatelyRect, s_RemoveSurfacesLabelContent, m_NumUpdatesBeforeRemovalProp); bool removeImmediately = EditorGUI.Toggle(removeImmediatelyRect, s_RemoveSurfacesLabelContent, m_SMBase.numUpdatesBeforeRemoval <= 0); if (removeImmediately) { m_NumUpdatesBeforeRemovalProp.intValue = 0; } else { m_NumUpdatesBeforeRemovalProp.intValue = 1; } EditorGUI.EndProperty(); } else { EditorGUILayout.PropertyField(m_NumUpdatesBeforeRemovalProp, s_RemovalUpdateCountLabelContent); } EditorGUILayout.PropertyField(m_LodProp, s_LODLabelContent); EditorGUILayout.PropertyField(m_VolumeProp, s_BoundingVolumeLabelContent); SpatialMappingBase.VolumeType volumeType = (SpatialMappingBase.VolumeType)m_VolumeProp.enumValueIndex; if (volumeType == SpatialMappingBase.VolumeType.Sphere) { Rect sphereRadiusRect = EditorGUILayout.GetControlRect(true); EditorGUI.BeginProperty(sphereRadiusRect, s_RadiusInMetersLabelContent, m_SphereRadiusProp); float originalSphereRadiusMeters = m_SphereRadiusProp.floatValue; m_SphereRadiusProp.floatValue = EditorGUI.FloatField(sphereRadiusRect, s_RadiusInMetersLabelContent, m_SphereRadiusProp.floatValue); if (m_SphereRadiusProp.floatValue < Mathf.Epsilon) { m_SphereRadiusProp.floatValue = originalSphereRadiusMeters; } EditorGUI.EndProperty(); } else { EditorGUILayout.PropertyField(m_HalfBoxExtentsProp, s_BoxExtentsInMetersLabelContent); } }
protected override void Awake() { base.Awake(); #if !UNITY_EDITOR if (Windows.Graphics.Holographic.HolographicDisplay.GetDefault()?.IsOpaque == false) { transform.ClearChildren(); } #endif var gr = this.Ensure <SpatialMappingRenderer>(); gr.Value.occlusionMaterial = OcclusionMaterial; gr.Value.visualMaterial = VisualizationMaterial; var gc = this.Ensure <SpatialMappingCollider>(); gCollider = gc; gRenderer = gr; if (gc.IsNew) { gc.Value.enableCollisions = true; gc.Value.layer = GroundLayer; gc.Value.material = Roughness; if (gr.IsNew) { gc.Value.surfaceParent = surfaceParent; gc.Value.freezeUpdates = freezeUpdates; gc.Value.secondsBetweenUpdates = secondsBetweenSpatialMappingUpdates; gc.Value.numUpdatesBeforeRemoval = updateCountBeforeSpatialMappingCleanup; gc.Value.lodType = LODType; gc.Value.volumeType = volumeType; gc.Value.halfBoxExtents = HalfBoxExtents; } else { gc.Value.surfaceParent = gr.Value.surfaceParent; gc.Value.freezeUpdates = gr.Value.freezeUpdates; gc.Value.secondsBetweenUpdates = gr.Value.secondsBetweenUpdates; gc.Value.numUpdatesBeforeRemoval = gr.Value.numUpdatesBeforeRemoval; gc.Value.lodType = gr.Value.lodType; gc.Value.volumeType = gr.Value.volumeType; gc.Value.halfBoxExtents = gr.Value.halfBoxExtents; } } gr.Value.surfaceParent = gc.Value.surfaceParent; gr.Value.freezeUpdates = gc.Value.freezeUpdates; gr.Value.secondsBetweenUpdates = gc.Value.secondsBetweenUpdates; gr.Value.numUpdatesBeforeRemoval = gc.Value.numUpdatesBeforeRemoval; gr.Value.lodType = gc.Value.lodType; gr.Value.volumeType = gc.Value.volumeType; gr.Value.halfBoxExtents = gc.Value.halfBoxExtents; lastSurfaceParent = surfaceParent; lastUpdateCount = updateCountBeforeSpatialMappingCleanup; lastUpdateTime = secondsBetweenSpatialMappingUpdates; lastFreezeUpdates = freezeUpdates; lastHalfBox = HalfBoxExtents; lastLODType = LODType; lastVolumeType = volumeType; }