mirror of
https://github.com/DerTyp7/traffic-unity.git
synced 2025-10-29 04:42:09 +01:00
30 lines
676 B
C#
30 lines
676 B
C#
using UnityEngine;
|
|
|
|
public class NodePlacer : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private GameObject nodeObject;
|
|
|
|
[SerializeField]
|
|
private TrafficNode prevPlacedNode;
|
|
|
|
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.B))
|
|
{
|
|
Vector3 newPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
|
newPosition.z = 0;
|
|
TrafficNode newNode = Instantiate(nodeObject, newPosition, Quaternion.identity).GetComponent<TrafficNode>();
|
|
|
|
if (prevPlacedNode != null)
|
|
{
|
|
prevPlacedNode.AddNextNode(newNode);
|
|
|
|
}
|
|
prevPlacedNode = newNode;
|
|
|
|
}
|
|
}
|
|
}
|