예제 #1
0
    void generateTextures()
    {
        List <TTexture> Textures = new List <TTexture>();

        for (int i = 0; i < textures.Length; i++)
        {
            Texture2D t    = textures[i];
            TTexture  TTex = new TTexture();
            TTex.texture     = t;
            TTex.tilesize    = new Vector2(16, 16);
            TTex.index       = i;
            TTex.heightCurve = heightCurve;
            TTex.angleCurve  = angleCurve;
            Textures.Add(TTex);
        }
        TerrainTexturing.GenerateTexture(Textures);
    }
예제 #2
0
파일: WorldGen.cs 프로젝트: Mrgove10/coins-
    public void OnGUI()
    {
        genClass.OnGUI();

        useTexturing = EditorGUILayout.BeginToggleGroup("Setup textures", useTexturing);

        if (useTexturing)
        {
            if (GUILayout.Button("Clear all textures"))
            {
                List <TTexture> textures = new List <TTexture>();
                TerrainTexturing.GenerateTexture(textures);
            }

            foreach (var texture in texClass)
            {
                texture.OnGUI();
            }

            if (texClass.Count > 0)
            {
                if (GUILayout.Button("Delete last"))
                {
                    texClass.RemoveAt(texClass.Count - 1);
                }
            }

            if (GUILayout.Button("Add texture"))
            {
                texClass.Add(new wbTexturing());
            }

            if (texClass.Count > 0 && texClass[texClass.Count - 1].texture != null)
            {
                if (GUILayout.Button("Assign new textures"))
                {
                    List <TTexture> textures = new List <TTexture>();
                    for (int i = 0; i < texClass.Count; i++)
                    {
                        TTexture TTex = new TTexture();
                        TTex.texture = texClass[i].texture;
                        //TTex.color = texClass[i].color;
                        TTex.useBump = texClass[i].useBump;
                        if (texClass[i].useBump)
                        {
                            TTex.bumpmap = texClass[i].bumpmap;
                        }
                        else
                        {
                            TTex.bumpmap = texClass[i].emptyBump;
                        }
                        TTex.tilesize    = texClass[i].tilesize;
                        TTex.index       = texClass[i].index;
                        TTex.heightCurve = texClass[i].heightCurve;
                        TTex.angleCurve  = texClass[i].angleCurve;
                        textures.Add(TTex);
                    }
                    TerrainTexturing.GenerateTexture(textures);
                }
            }
        }
        EditorGUILayout.EndToggleGroup();

        useFoliage = EditorGUILayout.BeginToggleGroup("Setup foliage", useFoliage);

        if (useFoliage)
        {
            waterCoast   = EditorGUILayout.FloatField("Tree distance from coast", waterCoast);
            maxSteepness = EditorGUILayout.FloatField("Max hill angle for trees", maxSteepness);

            if (GUILayout.Button("Generate trees"))
            {
                TerrainFoliage.maxSteepness = maxSteepness;
                if (GameObject.Find("Water"))
                {
                    TerrainFoliage.waterLevel = GameObject.Find("Water").transform.position.y + waterCoast;
                }
                else
                {
                    TerrainFoliage.waterLevel = 0.0f;
                }
                TerrainFoliage.GenerateFoliage();
            }

            if (GUILayout.Button("Remove trees"))
            {
                TerrainFoliage.ClearTrees();
            }

            grassDensity = EditorGUILayout.IntField("Grass density", grassDensity);

            if (GUILayout.Button("Generate grass"))
            {
                TerrainFoliage.GenerateGrass();
            }

            if (GUILayout.Button("Remove grass"))
            {
                TerrainFoliage.ClearGrass();
            }
        }

        EditorGUILayout.EndToggleGroup();
    }