Noise Map Generation 프로그래밍
Script > Create > C# Script
Map Display 스크립트 만들기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapDisplay : MonoBehaviour {
public Renderer textureRender;
public void DrawNoiseMap(float[,] noiseMap) {
int width = noiseMap.GetLength (0);
int height = noiseMap.GetLength (1);
Texture2D texture = new Texture2D (width, height);
Color[] colourMap = new Color[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
colourMap [y * width + x] = Color.Lerp (Color.black, Color.white, noiseMap [x, y]);
}
}
texture.SetPixels (colourMap);
texture.Apply ();
textureRender.sharedMaterial.mainTexture = texture;
textureRender.transform.localScale = new Vector3 (width, 1, height);
}
}
아까 만들어 둔 Map Generator에 Map Display Script 적용하기
그러면 아래 사진처럼 2개의 스크립트가 적용되어 있는 것을 볼 수 있다.
GameObject > 3D Object > Plane
오른쪽에 Collider 창은 필요 없으니까 없애기
* 참고
Procedure Landmass Generation (E02 Noise Map)
https://www.youtube.com/watch?v=WP-Bm65Q-1Y&list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3&index=2
'Game AI & Unity > Procedural Landmass Generation' 카테고리의 다른 글
[Unity][Procedural Landmass Generation] 6. MapGenerator Noise Generate button (0) | 2024.03.23 |
---|---|
[Unity][Procedural Landmass Generation] 5. texture (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 3. MapGenerator (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 2. Perlin Noise C# Script (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 1. Perlin Noise (0) | 2024.03.23 |