Assets > Editor폴더 만들기 > C# Script 만들기
MapGeneratorEditor로 이름짓기
현재는 MapGenerator의 생성 지도함수를 호출할 수 있는 방법이 없다
그래서 이것과 관련된 버튼을 생성하는 스크립트를 만들 것이다.
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof (MapGenerator))]
public class MapGeneratorEditor : Editor {
public override void OnInspectorGUI() {
MapGenerator mapGen = (MapGenerator)target;
if (DrawDefaultInspector ()) {
if (mapGen.autoUpdate) {
mapGen.GenerateMap ();
}
}
if (GUILayout.Button ("Generate")) {
mapGen.GenerateMap ();
}
}
}
Map Width, Map Height, Noise Scale 값을 적어준다
이렇게 크기를 지정해주지 않으면, texture가 깨질 수도 있다
Editor 코드 적었을 때, Generate 버튼이 생기는 것도 확인해야한다
Generate 버튼을 누르면, Perlin 지도가 나타난다
Map Height와 Map Width를 100 x 100으로 변경할 수 있다
이렇게 MapGeneration에 대한 옵션을 추가할 수 있으며,
이 옵션 값 중 하나라도 변경되면 맵이 바뀌게 된다.
Auto Update에 클릭하고, Noise Scale을 늘리면 자동으로 업데이트가 되는 것을 볼 수 있다.
* 참고
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] 8. MapGenerator Scripts update (0) | 2024.03.23 |
---|---|
[Unity][Procedural Landmass Generation] 7. Noise Scripts update (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 5. texture (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 4. Map Display (0) | 2024.03.23 |
[Unity][Procedural Landmass Generation] 3. MapGenerator (0) | 2024.03.23 |