using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuildingPlacer : MonoBehaviour { public GameObject buildingPrefab; // Start is called before the first frame update void Start() { } private void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3 gridPos = new Vector3(Mathf.RoundToInt(mousePos.x), Mathf.RoundToInt(mousePos.y), 0); GameObject buildPrefab = Instantiate(buildingPrefab, gridPos, Quaternion.identity); buildPrefab.name = $"Building {gridPos}"; } } }