private void ResetRevertCallback() { Undo.RecordObject(m_noiseUpdateTarget, "NoiseWindow - Reset or Revert Settings"); if (m_noiseSourceAsset == null) { m_noiseUpdateTarget.Reset(); } else { m_noiseUpdateTarget.Copy(m_noiseSourceAsset); } }
public override void DoGUI(Rect rect) { if (m_noiseSettings == null) { m_noiseSettings = ScriptableObject.CreateInstance <NoiseSettings>(); } GUIContent localLabel = NoiseFilter.localLabel; GUIContent worldLabel = NoiseFilter.worldLabel; GUIContent heightmapLabel = NoiseFilter.heightmapLabel; GUIContent editLabel = NoiseFilter.editLabel; float editWith = GUI.skin.label.CalcSize(editLabel).x + 20f; Rect editRect = new Rect(rect.xMax - editWith, rect.y, editWith, rect.height); Rect labelRect = rect; labelRect.width = GUI.skin.label.CalcSize(coordinateLabel).x; Rect worldRect = labelRect; worldRect.x = labelRect.xMax; worldRect.width = GUI.skin.button.CalcSize(worldLabel).x + 10f; Rect localRect = worldRect; localRect.x = worldRect.xMax; localRect.width = GUI.skin.button.CalcSize(localLabel).x + 10f; Rect heightmapRect = localRect; heightmapRect.x = localRect.xMax + 10f; heightmapRect.width = GUI.skin.button.CalcSize(heightmapLabel).x + 10f; if (editRect.xMin < heightmapRect.xMax + 10f) { worldRect.x -= labelRect.width; localRect.x -= labelRect.width; heightmapRect.x -= labelRect.width; labelRect.width = 0; } editRect.x = Mathf.Max(editRect.x, heightmapRect.xMax + 4f); if (editRect.xMax > rect.xMax) { worldLabel = NoiseFilter.worldShortLabel; localLabel = NoiseFilter.localShortLabel; heightmapLabel = NoiseFilter.heightmapShortLabel; worldRect.width = GUI.skin.label.CalcSize(worldLabel).x + 10f; localRect.width = GUI.skin.label.CalcSize(localLabel).x + 10f; heightmapRect.width = GUI.skin.label.CalcSize(heightmapLabel).x + 10f; localRect.x = worldRect.xMax; heightmapRect.x = localRect.xMax + 10f; editRect.x = rect.xMax - editWith; } editRect.x = Mathf.Max(heightmapRect.xMax + 4f, editRect.x); if (editRect.xMax > rect.xMax) { editLabel = editShortLabel; editRect.width = GUI.skin.label.CalcSize(editLabel).x + 10f; } GUI.Label(labelRect, coordinateLabel); if (TerrainToolGUIHelper.ToggleButton(worldRect, worldLabel, !m_isLocalSpace)) { m_isLocalSpace = false; } if (TerrainToolGUIHelper.ToggleButton(localRect, localLabel, m_isLocalSpace)) { m_isLocalSpace = true; } m_useHeightmap = TerrainToolGUIHelper.ToggleButton(heightmapRect, heightmapLabel, m_useHeightmap); m_noiseSettings.useTextureForPositions = m_useHeightmap; if (GUI.Button(editRect, editLabel)) { NoiseWindow wnd = NoiseWindow.Create(m_noiseSettings, m_noiseSource); wnd.noiseEditorView.onSettingsChanged += (noise) => { m_noiseSettings.Copy(noise); }; wnd.noiseEditorView.onSourceAssetChanged += (noise) => { m_noiseSource = noise; }; wnd.onDisableCallback += () => { m_window = null; }; m_window = wnd; } }