mirror of
https://github.com/DerTyp7/traffic-unity.git
synced 2025-10-30 05:07:10 +01:00
Add project files.
This commit is contained in:
29
Assets/Scripts/BuildingSystem/NodePlacer.cs
Normal file
29
Assets/Scripts/BuildingSystem/NodePlacer.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/BuildingSystem/NodePlacer.cs.meta
Normal file
11
Assets/Scripts/BuildingSystem/NodePlacer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4da8003edf1936e4b9a1af5a937c1074
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user