using UnityEngine;
public class BCE : MonoBehaviour
{
public Sprite poppedSprite;
public float destroyDelay = 1f;
private bool isPopped = false;
private void OnMouseDown()
{
// Change the sprite to the "popped" sprite
gameObject.GetComponent().sprite = poppedSprite;
// Set the flag indicating that the bubble has been popped
isPopped = true;
// Destroy the GameObject after a short delay
Destroy(this.gameObject, 0.1f);
}
}
Пузырь должен изменить его спрайт и уничтожить (через 0,1 секунды)
Я хотел, чтобы пузырь взорвался, когда его щелкнули, но он каким -то образом не работает < /p> [code]using UnityEngine;
public class BCE : MonoBehaviour { public Sprite poppedSprite; public float destroyDelay = 1f;
private bool isPopped = false;
private void OnMouseDown() { // Change the sprite to the "popped" sprite gameObject.GetComponent().sprite = poppedSprite; // Set the flag indicating that the bubble has been popped isPopped = true; // Destroy the GameObject after a short delay Destroy(this.gameObject, 0.1f); } } [/code] Пузырь должен изменить его спрайт и уничтожить (через 0,1 секунды)