void OnGUI() { if (WMSK.instance == null) { DestroyImmediate(this); EditorGUIUtility.ExitGUI(); return; } EditorGUILayout.HelpBox("This tool will import the heightmap and combined texture of an existing terrain.", MessageType.Info); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Terrain", GUILayout.Width(120)); terrain = (Terrain)EditorGUILayout.ObjectField(terrain, typeof(Terrain), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Resolution", GUILayout.Width(120)); resolution = (TerrainResolution)EditorGUILayout.EnumPopup(resolution); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Rotate 180°", GUILayout.Width(120)); rotate180 = EditorGUILayout.Toggle(rotate180); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("This operation can take some time. Please wait until it finishes.", MessageType.Warning); if (terrain == null) { GUI.enabled = false; } if (GUILayout.Button("Start")) { ImportTerrain(); } GUI.enabled = true; if (GUILayout.Button("Cancel")) { Close(); } }
private static int TerrainResolutionToSize(TerrainResolution res) { switch (res) { case TerrainResolution.Resolution_9: return(9); case TerrainResolution.Resolution_17: return(17); case TerrainResolution.Resolution_33: return(33); case TerrainResolution.Resolution_65: return(65); case TerrainResolution.Resolution_129: return(129); default: throw new ArgumentOutOfRangeException(); } }
private void Update() { if (!autoUpdate) { return; } var dirty = false; if (Input.GetKeyDown(KeyCode.T)) { dirty = true; } // Check dirty if (scale != cachedScale) { cachedScale = scale; dirty = true; } if (meshResolution != cachedMeshResolution) { cachedMeshResolution = meshResolution; dirty = true; } if (weightings != null && cachedWeightings != null && weightings.Length == cachedWeightings.Length) { for (var i = 0; i < weightings.Length; i++) { if (!weightings[i].Equals(cachedWeightings[i])) { dirty = true; cachedWeightings = (Weighting[])weightings.Clone(); break; } } } else { dirty = true; cachedWeightings = (Weighting[])weightings.Clone(); } if (posX != cachedPosX) { dirty = true; cachedPosX = posX; } if (posY != cachedPosY) { dirty = true; cachedPosY = posY; } if (dirty) { UpdateMesh(); } }