/// <summary> /// 指定された地点に瞬間的なパーティクルを再生する /// </summary> public void PlayOneShot(string name, Vector3 position, Quaternion rotation) { MomentParticle particle = GetMomentParticle(name); if (particle == null) { return; } particle.transform.SetPositionAndRotation(position, rotation); particle.Play(); }
/// <summary> /// 指定された地点に瞬間的なパーティクルを再生する /// </summary> public void PlayOneShot(string name, Vector3 position, Quaternion rotation, Transform parent) { MomentParticle particle = GetMomentParticle(name); if (particle == null) { return; } particle.transform.SetPositionAndRotation(position, rotation); particle.transform.SetParent(parent); particle.Play(); KKUtilities.Delay(0.1f, () => particle.transform.SetParent(transform), this); }
/// <summary> /// 指定された地点に瞬間的なパーティクルを再生する /// </summary> public void PlayOneShot(string name, Vector3 position, Quaternion rotation, Color color, Transform parent) { MomentParticle particle = GetMomentParticle(name); if (particle == null) { return; } particle.transform.SetPositionAndRotation(position, rotation); particle.transform.SetParent(parent); var main = particle.ParticleSystem.main; var defaultColor = main.startColor; main.startColor = color; particle.Play(); main.startColor = defaultColor; KKUtilities.Delay(main.duration, () => particle.transform.SetParent(transform), this); }
MomentParticle GetMomentParticle(string name) { MomentParticle particle; if (momentParticleDictionary.TryGetValue(name, out particle)) { return(particle); } MomentParticle particlePrefab = MyAssetStore.Instance.GetAsset <MomentParticle>(name, "Particles/"); if (particlePrefab == null) { return(null); } particle = Instantiate(particlePrefab, transform); momentParticleDictionary.Add(name, particle); return(particle); }