Skip to content

Instantly share code, notes, and snippets.

@kaiware007
Created October 21, 2018 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiware007/1a1a8235d589fa07ac6ffed1c125d22d to your computer and use it in GitHub Desktop.
Save kaiware007/1a1a8235d589fa07ac6ffed1c125d22d to your computer and use it in GitHub Desktop.
using UnityEngine;
public class SimpleParticlePlayer : MonoBehaviour {
/// <summary>
/// パーティクルシステムへの参照
/// </summary>
[SerializeField]
ParticleSystem particleSystem;
/// <summary>
/// パーティクルを再生するキー
/// </summary>
[SerializeField]
KeyCode playKey = KeyCode.M;
/// <summary>
/// パーティクル再生前に前のパーティクルを消去するか?
/// </summary>
[SerializeField]
bool isPlayWithClear = false;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(playKey))
{
if (isPlayWithClear)
{
particleSystem.Stop();
particleSystem.Clear();
}
particleSystem.Play();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment