Added examples for BuiltIn ParticleSystem
Added examples & templates for VFX Graph
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace DefaultNamespace
|
||||
{
|
||||
[RequireComponent(typeof(ParticleSystem))]
|
||||
public class PlayParticleSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private InputActionReference _playAction;
|
||||
[SerializeField] private InputActionReference _emitAction;
|
||||
[SerializeField] private InputActionReference _particleAction;
|
||||
|
||||
|
||||
private ParticleSystem _particleSystem;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_particleSystem = GetComponent<ParticleSystem>();
|
||||
ParticleSystem.MainModule main = _particleSystem.main;
|
||||
main.maxParticles = 10000;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_playAction.action.triggered)
|
||||
_particleSystem.Play();
|
||||
|
||||
if (_emitAction.action.triggered)
|
||||
_particleSystem.Emit(100);
|
||||
|
||||
if (_particleAction.action.triggered)
|
||||
{
|
||||
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[_particleSystem.main.maxParticles];
|
||||
_particleSystem.GetParticles(particles);
|
||||
for (int i = 0; i < particles.Length; i++)
|
||||
{
|
||||
particles[i].position += Vector3.up;
|
||||
}
|
||||
_particleSystem.SetParticles(particles, particles.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// triggered when the inspector changed
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
// triggered by inspector reset
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user