2024-03-07 18:41:28 +01:00

43 lines
1.3 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;
public void OnButtonPress()
{
PressButton();
}
public void PressButton()
{
// Check if the prefab is assigned
if (spherePrefab != null)
{
if(particle == "Proton")
{
// Instantiate the sphere at the position of the button with no rotation
Instantiate(spherePrefab, new Vector3(0.5f, 1.3178f, -0.65f), Quaternion.identity);
}
else if(particle == "Neutron")
{
// Instantiate the sphere at the position of the button with no rotation
Instantiate(spherePrefab, new Vector3(0.5f, 1.3167f, -0.794f), Quaternion.identity);
}
else if (particle == "Electron")
{
// Instantiate the sphere at the position of the button with no rotation
Instantiate(spherePrefab, new Vector3(0.5f, 1.342f, -0.91f), Quaternion.identity);
}
}
else
{
Debug.LogError("Sphere prefab is not assigned!");
}
}
}