예제 #1
0
        /// <summary>
        /// Draws the scene plateaus.
        /// </summary>
        /// <param name="_ground">Ground.</param>
        /// <param name="_player">Player.</param>
        public static void DrawScenePlateaus(GameObject _ground, GameObject _player)
        {
            ICEEditorStyle.Splitter();
            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainPlateaus = (int)ICEEditorLayout.DefaultSlider("Plateaus (max.)", "", TerrainTools.TerrainPlateaus, 1, 0, 500, 50);
            EditorGUI.BeginDisabledGroup(TerrainTools.TerrainPlateaus == 0 || _ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.CreatePlateaus(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_PLATEAUS);

            EditorGUI.BeginDisabledGroup(TerrainTools.TerrainPlateaus == 0);
            EditorGUI.indentLevel++;
            TerrainTools.TerrainPlateausMaxHeight = ICEEditorLayout.DefaultSlider("Max. Height", "", TerrainTools.TerrainPlateausMaxHeight, Init.DECIMAL_PRECISION_INDICATOR, 0, 1, 0.3f);
            TerrainTools.TerrainPlateausMaxRadius = (int)ICEEditorLayout.DefaultSlider("Max. Radius", "", TerrainTools.TerrainPlateausMaxRadius, Init.DECIMAL_PRECISION_INDICATOR, 0, TerrainTools.TerrainSize / 2, 100);
            EditorGUI.indentLevel--;
            EditorGUI.EndDisabledGroup();
        }
예제 #2
0
        /// <summary>
        /// Draws the scene valleys.
        /// </summary>
        /// <param name="_ground">Ground.</param>
        /// <param name="_player">Player.</param>
        public static void DrawSceneValleys(GameObject _ground, GameObject _player)
        {
            ICEEditorStyle.Splitter();
            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainValleys = (int)ICEEditorLayout.DefaultSlider("Valleys (max.)", "", TerrainTools.TerrainValleys, 1, 0, 500, TerrainTools.DefaultTerrainValleys);
            EditorGUI.BeginDisabledGroup(TerrainTools.TerrainHills == 0 || _ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.CreateValleys(_ground.GetComponent <Terrain>().terrainData);
                    TerrainTools.UpdateSplatmap(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_VALLEYS);
            EditorGUI.BeginDisabledGroup(TerrainTools.TerrainHills == 0);
            EditorGUI.indentLevel++;

            int _terrain_height = TerrainTools.GetTerrainHeight(_ground);
            int _terrain_size   = TerrainTools.GetTerrainSize(_ground);

            float _deep   = (int)MathTools.Denormalize(TerrainTools.TerrainValleysMaxDeep, 0, _terrain_height);
            float _radius = (int)MathTools.Denormalize(TerrainTools.TerrainValleysMaxRadius * 2, 0, _terrain_size * 0.5f);

            TerrainTools.TerrainValleysMaxDeep   = ICEEditorLayout.DefaultSlider("Max. Deep (" + _deep + ")", "", TerrainTools.TerrainValleysMaxDeep, Init.DECIMAL_PRECISION_INDICATOR, 0, 1, TerrainTools.DefaultTerrainValleysMaxDeep * TerrainTools.GetSizeMultiplier());
            TerrainTools.TerrainValleysMaxRadius = ICEEditorLayout.DefaultSlider("Max. Radius (" + _radius + ")", "", TerrainTools.TerrainValleysMaxRadius, Init.DECIMAL_PRECISION_INDICATOR, 0, 1, TerrainTools.DefaultTerrainValleysMaxRadius * TerrainTools.GetSizeMultiplier());

            EditorGUI.indentLevel--;
            EditorGUI.EndDisabledGroup();
        }
예제 #3
0
        /// <summary>
        /// Draws the scene trees.
        /// </summary>
        /// <param name="_ground">Ground.</param>
        /// <param name="_player">Player.</param>
        public static void DrawSceneTrees(GameObject _ground, GameObject _player)
        {
            ICEEditorStyle.Splitter();
            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainTreesMax      = (int)ICEEditorLayout.DefaultSlider("Trees", "", TerrainTools.TerrainTreesMax, 1, 0, 10000, TerrainTools.DefaultTerrainTreesMax);
            TerrainTools.TerrainTreesMaxAngle = EditorGUILayout.FloatField(TerrainTools.TerrainTreesMaxAngle, GUILayout.MaxWidth(45));

            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.UpdateTrees(_ground.GetComponent <Terrain>().terrainData);
                }
            }

            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_TREES);
        }
예제 #4
0
        /// <summary>
        /// Draws the scene terrain.
        /// </summary>
        /// <param name="_ground">Ground.</param>
        /// <param name="_player">Player.</param>
        public static void DrawSceneTerrain(GameObject _ground, GameObject _player)
        {
            ICEEditorStyle.Splitter();
            ICEEditorLayout.BeginHorizontal();

            TerrainTools.DesiredTerrainSize = (int)ICEEditorLayout.Slider("Terrain Size", "", TerrainTools.DesiredTerrainSize, 100, 100, 2000);

            TerrainTools.DesiredTerrainResolutionMultiplier = (int)ICEEditorLayout.ButtonOptionMini("1", TerrainTools.DesiredTerrainResolutionMultiplier, 1);
            TerrainTools.DesiredTerrainResolutionMultiplier = (int)ICEEditorLayout.ButtonOptionMini("2", TerrainTools.DesiredTerrainResolutionMultiplier, 2);
            TerrainTools.DesiredTerrainResolutionMultiplier = (int)ICEEditorLayout.ButtonOptionMini("4", TerrainTools.DesiredTerrainResolutionMultiplier, 4);
            TerrainTools.DesiredTerrainResolutionMultiplier = (int)ICEEditorLayout.ButtonOptionMini("8", TerrainTools.DesiredTerrainResolutionMultiplier, 8);

            int _desired_value = TerrainTools.DesiredTerrainSize + TerrainTools.DesiredTerrainResolutionMultiplier;
            int _current_value = TerrainTools.TerrainSize + TerrainTools.TerrainResolutionMultiplier;
            int _default_value = TerrainTools.DefaultTerrainSize + TerrainTools.DefaultTerrainResolutionMultiplier;

            if (_desired_value != _default_value)
            {
                _update_required = true;
            }

            if (ICEEditorLayout.ButtonDefault(_desired_value, _default_value) == _default_value)
            {
                TerrainTools.DesiredTerrainSize = TerrainTools.DefaultTerrainSize;
                TerrainTools.DesiredTerrainResolutionMultiplier = TerrainTools.DefaultTerrainResolutionMultiplier;
            }

            if (ICEEditorLayout.UpdateButton(_desired_value != _current_value))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");

                    if (_update_required)
                    {
                        _update_required = false;
                        GameObject.DestroyImmediate(_ground);

                        _ground = TerrainTools.CreateTerrain();
                        if (_ground != null && _ground.GetComponent <Terrain>() != null)
                        {
                            Vector3 _s = _ground.GetComponent <Terrain>().terrainData.size;
                            _ground.transform.position = new Vector3(_s.x / -2, 0, _s.z / -2);
                        }
                    }
                    else
                    {
                        TerrainTools.UpdateTerrainSize(_ground.GetComponent <Terrain>().terrainData);
                    }

                    UpdateLevel(_player, _ground);
                }
            }

            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_SIZE);

            EditorGUI.indentLevel++;

            ICEEditorLayout.BeginHorizontal();
            TerrainTools.DesiredTerrainHeight = (int)ICEEditorLayout.DefaultSlider("Height", "", TerrainTools.DesiredTerrainHeight, 1, 0, 600, 600);
            EditorGUI.BeginDisabledGroup(_ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.UpdateTerrainSize(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_HEIGHT);

            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainBaseLevel = ICEEditorLayout.DefaultSlider("Base", "", TerrainTools.TerrainBaseLevel, Init.DECIMAL_PRECISION_DISTANCES, -1, 1, 0);
            EditorGUI.BeginDisabledGroup(_ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("RESET", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.Reset(_ground.GetComponent <Terrain>().terrainData);
                }
            }

            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.UpdateTerrainBaseLevel(_ground.GetComponent <Terrain>().terrainData);
                    TerrainTools.UpdateSplatmap(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_BASE);

            ICEEditorStyle.Splitter();
            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainBumpsMax = ICEEditorLayout.DefaultSlider("Bumps", "", TerrainTools.TerrainBumpsMax, Init.DECIMAL_PRECISION, 0, 1, TerrainTools.DefaultTerrainBumpsMax * TerrainTools.GetSizeMultiplier());
            TerrainTools.TerrainBumpsMin = -TerrainTools.TerrainBumpsMax;
            EditorGUI.BeginDisabledGroup(_ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.UpdateTerrainBumps(_ground.GetComponent <Terrain>().terrainData);
                    TerrainTools.UpdateSplatmap(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_BUMPS);

            ICEEditorLayout.BeginHorizontal();
            TerrainTools.TerrainSmoothingLoops = (int)ICEEditorLayout.DefaultSlider("Smoothing", "", TerrainTools.TerrainSmoothingLoops, 1, 0, 8, TerrainTools.DefaultTerrainSmoothingLoops);
            EditorGUI.BeginDisabledGroup(_ground == null || _ground.GetComponent <Terrain>() == null);
            if (ICEEditorLayout.ButtonMiddle("UPDATE", ""))
            {
                if (_ground != null && _ground.GetComponent <Terrain>() != null)
                {
                    Undo.RegisterCompleteObjectUndo(_ground.GetComponent <Terrain>().terrainData, "Wizard Terrain Data");
                    TerrainTools.SmoothTerrain(_ground.GetComponent <Terrain>().terrainData);
                    TerrainTools.UpdateSplatmap(_ground.GetComponent <Terrain>().terrainData);
                    UpdateLevel(_player, _ground);
                }
            }
            EditorGUI.EndDisabledGroup();
            ICEEditorLayout.EndHorizontal(Info.WIZARD_TERRAIN_SMOOTHING);

            EditorGUI.indentLevel--;
        }