12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- using Utilities = KairoEngine.Utility.Utilities;
- using KairoEngine.GameTools.InteractionTools;
- using KairoEngine.UI;
- using Sirenix.OdinInspector;
- namespace KairoEngine.TerrainEngine
- {
- public class VoxelTerrainEditor : MonoBehaviour
- {
- public enum Tool
- {
- None,
- Add,
- Remove,
- Level
- }
- public ChunkTerrainGenerator chunkTerrainGenerator;
- public LayerMask layerMask;
- public int radius = 3;
- public Tool currentTool = Tool.None;
- public uint code = 0;
- private void Update()
- {
- if(currentTool == Tool.None) return;
- if(MouseInputUIBlocker.BlockedByUI) return;
- Vector3 pos = Utilities.GetMouseWorldPosition(layerMask);
- switch (currentTool)
- {
- case Tool.Add:
- if(Input.GetMouseButtonDown(0)) chunkTerrainGenerator.ChangeVoxels(pos, code, ChunkTerrainGenerator.VoxelOperation.Add, radius);
- break;
- case Tool.Remove:
- if(Input.GetMouseButtonDown(0)) chunkTerrainGenerator.ChangeVoxels(pos, code, ChunkTerrainGenerator.VoxelOperation.Remove, radius);
- break;
- case Tool.Level:
- if(Input.GetMouseButtonDown(0)) chunkTerrainGenerator.ChangeVoxels(pos, code, ChunkTerrainGenerator.VoxelOperation.Level, radius);
- break;
- default:
- break;
- }
- }
- }
- }
|