You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-15 20:50:08 +00:00
feat: add particle attractor component
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Coffee.UIExtensions
|
||||
internal static class UIParticleUpdater
|
||||
{
|
||||
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
||||
static readonly List<UIParticleAttractor> s_ActiveAttractors = new List<UIParticleAttractor>();
|
||||
static readonly HashSet<int> s_UpdatedGroupIds = new HashSet<int>();
|
||||
private static int frameCount = 0;
|
||||
|
||||
@@ -29,6 +30,18 @@ namespace Coffee.UIExtensions
|
||||
s_ActiveParticles.Remove(particle);
|
||||
}
|
||||
|
||||
public static void Register(UIParticleAttractor attractor)
|
||||
{
|
||||
if (!attractor) return;
|
||||
s_ActiveAttractors.Add(attractor);
|
||||
}
|
||||
|
||||
public static void Unregister(UIParticleAttractor attractor)
|
||||
{
|
||||
if (!attractor) return;
|
||||
s_ActiveAttractors.Remove(attractor);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
#endif
|
||||
@@ -74,6 +87,12 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
|
||||
s_UpdatedGroupIds.Clear();
|
||||
|
||||
// Attract
|
||||
for(var i = 0;i< s_ActiveAttractors.Count;i++)
|
||||
{
|
||||
s_ActiveAttractors[i].Attract();
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetGroupedRenderers(int groupId, int index, List<UIParticleRenderer> results)
|
||||
|
||||
Reference in New Issue
Block a user