Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        PGCTerrain PGCTerrain = (PGCTerrain)target;

        EditorGUILayout.LabelField("Map Options");

        mapsize = EditorGUILayout.IntField("Map Width (2^n)", mapsize);

        if (Mathf.Floor(Mathf.Log(mapsize, 2)) == Mathf.Ceil(Mathf.Log(mapsize, 2)))
        {
            PGCTerrain.mapHeight = mapsize;
            PGCTerrain.mapWidth  = mapsize;
        }
        else
        {
            mapsize = 512;
            PGCTerrain.mapHeight = mapsize;
            PGCTerrain.mapWidth  = mapsize;
        }

        PGCTerrain.mapDepth = EditorGUILayout.IntField("Map Depth", PGCTerrain.mapDepth);

        if (GUILayout.Button("Random Terrain"))
        {
            PGCTerrain.RandomTerrain();
            Debug.Log("Random terrain");
        }

        showPer = EditorGUILayout.Foldout(showPer, "Perlin Noise Options");

        if (showPer)
        {
            PGCTerrain.scale   = EditorGUILayout.Slider("Scale", PGCTerrain.scale, 0.001f, 500);
            PGCTerrain.Offsets = EditorGUILayout.Vector2Field("Offsets", PGCTerrain.Offsets);

            if (GUILayout.Button("Single Perlin"))
            {
                Debug.Log("Single Perlin");
                PGCTerrain.SinglePerlin();
            }

            showMPO = EditorGUILayout.Foldout(showMPO, "Multiple Perlin Options");

            if (showMPO)
            {
                PGCTerrain.seed        = EditorGUILayout.IntField("Map Seed", PGCTerrain.seed);
                PGCTerrain.numOctaves  = EditorGUILayout.IntSlider("Octaves", PGCTerrain.numOctaves, 0, 12);
                PGCTerrain.persistance = EditorGUILayout.Slider("Persistance", PGCTerrain.persistance, 0.0f, 1);
                PGCTerrain.lacunarity  = EditorGUILayout.Slider("Lacunarity", PGCTerrain.lacunarity, 0.0f, 1);
                if (GUILayout.Button("Multiple Perlin"))
                {
                    PGCTerrain.MultiplePerlin();
                }
            }
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        PGCTerrain terrain = (PGCTerrain)target;



        PerlinBool = EditorGUILayout.Foldout(PerlinBool, "Single Perlin");
        if (PerlinBool)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinScaleX, 0, 1, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinScaleY, 0, 1, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinXOffset, 0, 100, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinYOffset, 0, 100, new GUIContent("Y OFfset"));
            if (GUILayout.Button("Perlin"))
            {
                terrain.Perlin();
            }
        }

        MultiPerlinBool = EditorGUILayout.Foldout(MultiPerlinBool, "Mult Perlin");
        if (MultiPerlinBool)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Mulitple Perlin Noise", EditorStyles.boldLabel);
            EditorGUILayout.Slider(perlinScaleX, 0, 1, new GUIContent("X Scale"));
            EditorGUILayout.Slider(perlinScaleY, 0, 1, new GUIContent("Y Scale"));
            EditorGUILayout.IntSlider(perlinXOffset, 0, 100, new GUIContent("X Offset"));
            EditorGUILayout.IntSlider(perlinYOffset, 0, 100, new GUIContent("Y OFfset"));
            EditorGUILayout.IntSlider(Octaves, 1, 10, new GUIContent("Octaves"));
            EditorGUILayout.Slider(Persistance, 0.1f, 10, new GUIContent("Persistance"));
            EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale"));
            GUILayout.Space(20);
            if (GUILayout.Button("Apply Multiple Perlin"))
            {
                terrain.MultiplePerlinTerrain();
            }
        }

        showRandom = EditorGUILayout.Foldout(showRandom, "Random");

        if (showRandom)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(randomHeight);
            if (GUILayout.Button("Random Heights"))
            {
                terrain.RandomTerrain();
            }
        }

        showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi");

        if (showVoronoi)
        {
            EditorGUILayout.Slider(vorMinPeak, 0, 1, new GUIContent("Min Peak"));
            EditorGUILayout.Slider(vorMaxPeak, 0, 1, new GUIContent("Max Peak"));
            EditorGUILayout.Slider(vorFall, 0, 10, new GUIContent("Fall off"));
            EditorGUILayout.Slider(vorDrop, 0, 10, new GUIContent("Drop off"));
            EditorGUILayout.IntSlider(vorPeaks, 1, 10, new GUIContent("voronoi Peaks"));
            EditorGUILayout.PropertyField(voronoiType);

            if (GUILayout.Button("Voronoi"))

            {
                terrain.Voronoi();
            }
        }



        if (GUILayout.Button("Reset Terrain"))
        {
            terrain.ResetTerrain();
        }

        serializedObject.ApplyModifiedProperties();
    }