public void ToggleVisualization() { if (GameObject.FindObjectOfType <Terrain>() == null) { m_selectedMode = VISUALIZERMODE.None; m_Settings.ModeWarning = true; return; } if (m_Terrains == null || GameObject.FindObjectsOfType <Terrain>().Length != m_Terrains.Count || m_Terrains[0] == null) { m_Terrains.Clear(); m_Terrains.AddRange(ToolboxHelper.GetAllTerrainsInScene()); m_Settings.TerrainMaxHeight = m_Terrains[0].terrainData.size.y; } switch (m_selectedMode) { case VISUALIZERMODE.AltitudeHeatmap: RevertMaterial(); RefreshTerrainInScene(); UpdateHeatmapSettings(); break; case VISUALIZERMODE.None: RevertMaterial(); break; } m_ModeWarning = false; m_previousMode = m_selectedMode; }
void RefreshTerrainInScene() { m_Terrains.Clear(); m_Terrains.AddRange(ToolboxHelper.GetAllTerrainsInScene()); if (m_Terrains.Count == 0) { m_ModeWarning = true; return; } m_TerrainMaxHeight = m_Terrains.Max(t => t.terrainData.size.y); m_TerrainMaterials.Clear(); foreach (Terrain terrain in m_Terrains) { m_TerrainMaterials.Add(terrain.materialTemplate); } m_ModeWarning = false; }