1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-25 17:54:19 +00:00
gravity-fusion/Assets/Components/SpawnOnMouseClick.cs

23 lines
629 B
C#
Raw Normal View History

2019-10-05 09:48:36 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnOnMouseClick : MonoBehaviour
{
[Header("Config")]
public GameObject prefabToSpawn;
public int mouseButton;
protected Vector3 GetWorldMousePosition() {
return Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
void Update()
{
2019-10-05 21:50:43 +00:00
if(Input.GetMouseButton(mouseButton)) {
2019-10-05 09:48:36 +00:00
Vector3 mousePosition = GetWorldMousePosition();
GameObject instance = Instantiate(prefabToSpawn, new Vector3(mousePosition.x, mousePosition.y, 0f), Quaternion.identity);
}
}
}