ParticleEffectForUGUI/Demo/UIParticle_Demo.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2018-06-22 18:48:14 +08:00
using UnityEngine;
2018-07-13 12:21:32 +08:00
using UnityEngine.UI;
2018-11-28 19:55:42 +08:00
using System.Collections.Generic;
2018-06-22 18:48:14 +08:00
namespace Coffee.UIExtensions.Demo
{
public class UIParticle_Demo : MonoBehaviour
{
2018-07-13 12:21:32 +08:00
[SerializeField] Sprite m_Sprite;
2018-11-28 13:19:48 +08:00
[SerializeField] ParticleSystem [] m_ParticleSystems;
[SerializeField] Mask [] m_Masks;
2018-11-28 19:55:42 +08:00
[SerializeField] List<Transform> m_ScalingByTransforms;
[SerializeField] List<UIParticle> m_ScalingByUIParticles;
2018-11-28 13:19:48 +08:00
public void SetTimeScale (float scale)
2018-06-22 18:48:14 +08:00
{
Time.timeScale = scale;
}
2018-11-28 13:19:48 +08:00
public void EnableTrailRibbon (bool ribbonMode)
2018-07-13 12:21:32 +08:00
{
2018-11-28 13:19:48 +08:00
foreach (var p in m_ParticleSystems)
2018-07-13 12:21:32 +08:00
{
var trails = p.trails;
trails.mode = ribbonMode ? ParticleSystemTrailMode.Ribbon : ParticleSystemTrailMode.PerParticle;
}
}
2018-11-28 13:19:48 +08:00
public void EnableSprite (bool enabled)
2018-07-13 12:21:32 +08:00
{
2018-11-28 13:19:48 +08:00
foreach (var p in m_ParticleSystems)
2018-07-13 12:21:32 +08:00
{
var tex = p.textureSheetAnimation;
tex.enabled = enabled;
}
}
2018-11-28 13:19:48 +08:00
public void EnableMask (bool enabled)
2018-07-13 12:21:32 +08:00
{
2018-11-28 13:19:48 +08:00
foreach (var m in m_Masks)
2018-07-13 12:21:32 +08:00
{
m.enabled = enabled;
}
}
2018-11-28 13:19:48 +08:00
public void SetScale (float scale)
{
2018-11-28 19:55:42 +08:00
m_ScalingByTransforms.ForEach (x => x.localScale = Vector3.one * (10 * scale));
m_ScalingByUIParticles.ForEach (x => x.scale = scale);
2018-11-28 13:19:48 +08:00
}
2018-06-22 18:48:14 +08:00
}
}