mirror of
https://github.com/noakdsv/AtomCraft-2.28.git
synced 2024-10-23 02:34:20 +02:00
c30f28b574
New Repo changes
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ButtonSphereInstantiation : MonoBehaviour
|
|
{
|
|
public GameObject spherePrefab; // Reference to the prefab of the sphere
|
|
public string particle;
|
|
private ButtonManager buttonManager;
|
|
|
|
public Transform positionToInstantiate;
|
|
|
|
void Start()
|
|
{
|
|
buttonManager = GameObject.Find("ButtonManager").GetComponent<ButtonManager>();
|
|
}
|
|
|
|
public void OnButtonPress()
|
|
{
|
|
PressButton();
|
|
}
|
|
|
|
public void PressButton()
|
|
{
|
|
// Check if the prefab is assigned
|
|
if (spherePrefab != null && buttonManager.isEnableSpawn())
|
|
{
|
|
if (particle == "Proton")
|
|
{
|
|
// Instantiate the sphere at the position of the button with no rotation
|
|
Instantiate(spherePrefab, positionToInstantiate.position, Quaternion.identity);
|
|
}
|
|
else if (particle == "Neutron")
|
|
{
|
|
// Instantiate the sphere at the position of the button with no rotation
|
|
Instantiate(spherePrefab, positionToInstantiate.position, Quaternion.identity);
|
|
}
|
|
else if (particle == "Electron")
|
|
{
|
|
// Instantiate the sphere at the position of the button with no rotation
|
|
Instantiate(spherePrefab, positionToInstantiate.position, Quaternion.identity);
|
|
}
|
|
buttonManager.setEnableSpawn(false);
|
|
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Sphere prefab is not assigned!");
|
|
}
|
|
}
|
|
}
|