-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVoxelRendererEditor.cs
29 lines (27 loc) · 1.06 KB
/
VoxelRendererEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(VoxelRenderer))]
public class VoxelRendererEditor : Editor
{
static Vector3 randPosMin, randPosMax;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
VoxelRenderer voxelRenderer = (VoxelRenderer)target;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Random Perlin Position", EditorStyles.boldLabel);
randPosMin = EditorGUILayout.Vector3Field("Random Position Min", randPosMin);
randPosMax = EditorGUILayout.Vector3Field("Random Position Max", randPosMax);
if (GUILayout.Button("Randomize Perlin Position"))
{
voxelRenderer.perlinPosition = new Vector3(
Random.Range(randPosMin.x, randPosMax.x),
Random.Range(randPosMin.y, randPosMax.y),
Random.Range(randPosMin.z, randPosMax.z)
);
voxelRenderer.GenerateMap(voxelRenderer.perlinPosition);
}
}
}