ParticleEffectForUGUI/Demo/UIParticle_Demo.cs

74 lines
1.6 KiB
C#
Raw Normal View History

2018-06-22 18:48:14 +08:00
using UnityEngine;
2018-12-12 21:29:07 +08:00
using UnityEngine.SceneManagement;
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-12-12 21:29:07 +08:00
foreach (var m in FindObjectsOfType<Mask> ())
{
m.enabled = enabled;
}
}
public void EnableMask2D (bool enabled)
{
foreach (var m in FindObjectsOfType<RectMask2D> ())
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-12-12 21:29:07 +08:00
public void SetUIParticleScale(float scale)
{
foreach(var uip in FindObjectsOfType<UIParticle>())
{
uip.scale = scale;
}
}
public void LoadScene(string name)
{
SceneManager.LoadScene (name);
}
2018-06-22 18:48:14 +08:00
}
}