using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CreatMap : MonoBehaviour
{
public int x;
public int y;
void Start()
{
Texture2D texture = new Texture2D(x, y);
VertexHelper vh = new VertexHelper();
for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
float h = Mathf.PerlinNoise(i * 0.05f, j * 0.05f);
Color color = Color.Lerp(Color.blue, Color.green, h);
float uvx = (float)j / (x - 1);
float uvy = (float)j / (y - 1);
texture.SetPixel(i, j, color);
vh.AddVert(new Vector3(i, h * 15, j), color, new Vector2(uvx, uvy));
if (i != x - 1 && j != y - 1)
{
vh.AddTriangle(i * y + j, i * y + j + 1, (i + 1) * y + j + 1);
vh.AddTriangle(i * y + j, (
08-18
575
575
12-07
6176
6176
06-03
294
294
12-30
4330
4330

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



