UnityEditor.TerrainInspector.ShowResolution C# (CSharp) Method

ShowResolution() public method

public ShowResolution ( ) : void
return void
        public void ShowResolution()
        {
            GUILayout.Label("Resolution", EditorStyles.boldLabel, new GUILayoutOption[0]);
            float x = this.m_Terrain.terrainData.size.x;
            float y = this.m_Terrain.terrainData.size.y;
            float z = this.m_Terrain.terrainData.size.z;
            int heightmapResolution = this.m_Terrain.terrainData.heightmapResolution;
            int detailResolution = this.m_Terrain.terrainData.detailResolution;
            int detailResolutionPerPatch = this.m_Terrain.terrainData.detailResolutionPerPatch;
            int alphamapResolution = this.m_Terrain.terrainData.alphamapResolution;
            int baseMapResolution = this.m_Terrain.terrainData.baseMapResolution;
            EditorGUI.BeginChangeCheck();
            x = EditorGUILayout.DelayedFloatField(EditorGUIUtility.TempContent("Terrain Width"), x, new GUILayoutOption[0]);
            if (x <= 0f)
            {
                x = 1f;
            }
            if (x > 100000f)
            {
                x = 100000f;
            }
            z = EditorGUILayout.DelayedFloatField(EditorGUIUtility.TempContent("Terrain Length"), z, new GUILayoutOption[0]);
            if (z <= 0f)
            {
                z = 1f;
            }
            if (z > 100000f)
            {
                z = 100000f;
            }
            y = EditorGUILayout.DelayedFloatField(EditorGUIUtility.TempContent("Terrain Height"), y, new GUILayoutOption[0]);
            if (y <= 0f)
            {
                y = 1f;
            }
            if (y > 10000f)
            {
                y = 10000f;
            }
            heightmapResolution = Mathf.Clamp(EditorGUILayout.DelayedIntField(EditorGUIUtility.TempContent("Heightmap Resolution"), heightmapResolution, new GUILayoutOption[0]), 0x21, 0x1001);
            heightmapResolution = this.m_Terrain.terrainData.GetAdjustedSize(heightmapResolution);
            detailResolution = Mathf.Clamp(EditorGUILayout.DelayedIntField(EditorGUIUtility.TempContent("Detail Resolution"), detailResolution, new GUILayoutOption[0]), 0, 0xfd0);
            detailResolutionPerPatch = Mathf.Clamp(EditorGUILayout.DelayedIntField(EditorGUIUtility.TempContent("Detail Resolution Per Patch"), detailResolutionPerPatch, new GUILayoutOption[0]), 8, 0x80);
            alphamapResolution = Mathf.Clamp(Mathf.ClosestPowerOfTwo(EditorGUILayout.DelayedIntField(EditorGUIUtility.TempContent("Control Texture Resolution"), alphamapResolution, new GUILayoutOption[0])), 0x10, 0x800);
            baseMapResolution = Mathf.Clamp(Mathf.ClosestPowerOfTwo(EditorGUILayout.DelayedIntField(EditorGUIUtility.TempContent("Base Texture Resolution"), baseMapResolution, new GUILayoutOption[0])), 0x10, 0x800);
            if (EditorGUI.EndChangeCheck())
            {
                ArrayList list = new ArrayList {
                    this.m_Terrain.terrainData
                };
                list.AddRange(this.m_Terrain.terrainData.alphamapTextures);
                Undo.RegisterCompleteObjectUndo(list.ToArray(typeof(Object)) as Object[], "Set Resolution");
                if (this.m_Terrain.terrainData.heightmapResolution != heightmapResolution)
                {
                    this.m_Terrain.terrainData.heightmapResolution = heightmapResolution;
                }
                this.m_Terrain.terrainData.size = new Vector3(x, y, z);
                if ((this.m_Terrain.terrainData.detailResolution != detailResolution) || (detailResolutionPerPatch != this.m_Terrain.terrainData.detailResolutionPerPatch))
                {
                    this.ResizeDetailResolution(this.m_Terrain.terrainData, detailResolution, detailResolutionPerPatch);
                }
                if (this.m_Terrain.terrainData.alphamapResolution != alphamapResolution)
                {
                    this.m_Terrain.terrainData.alphamapResolution = alphamapResolution;
                }
                if (this.m_Terrain.terrainData.baseMapResolution != baseMapResolution)
                {
                    this.m_Terrain.terrainData.baseMapResolution = baseMapResolution;
                }
                this.m_Terrain.Flush();
            }
            EditorGUILayout.HelpBox("Please note that modifying the resolution of the heightmap, detail map and control texture will clear their contents, respectively.", MessageType.Warning);
        }