I’ve done a basic ParticleSystem
tutorial on YT, wich plaus well in the editor. But for some reason I can’t get to start the animation from my Script.
This might come from Visual Studio that crushes the imports and stuff, but here’s my code:
using UnityEngine;
using TMPro;
namespace Namespace.Scoreboards
{
public class ScoreboardEntryUI : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI entryNameText = null;
[SerializeField] private TextMeshProUGUI entryScoreText = null;
private ParticleSystem particleEffect;
public void Initialize(ScoreboardEntryData scoreboardEntryData)
{
entryNameText.text = scoreboardEntryData.entryName;
entryScoreText.text = scoreboardEntryData.entryScore.ToString();
particleEffect = GetComponent<ParticleSystem>();
particleEffect.Play();
}
}
}
This script is attached to a Game prefab, which has the so-called Particle System
s.
I get the error in console:
Assets\Scripts\ScoreboardEntryUI.cs(19,28): error CS1061: ‘ParticleSystem’ does not contain a definition for ‘Play’ and no accessible extension method ‘Play’ accepting a first argument of type ‘ParticleSystem’ could be found (are you missing a using directive or an assembly reference?)
I have no idea how the compiler can not get the Play()
method from ParticleSystem
.
Am I missing something ?
Thanks !
The file and the class name must be changed.
– Matronna