fix to emit
parent
386170cbf6
commit
d9e7eb9732
|
@ -311,6 +311,14 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
}
|
||||
|
||||
internal void UpdateParticleCount()
|
||||
{
|
||||
for (var i = 0; i < m_Renderers.Count; i++)
|
||||
{
|
||||
m_Renderers[i].UpdateParticleCount();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
#if !SERIALIZE_FIELD_MASKABLE
|
||||
|
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
|||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -100
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace Coffee.UIExtensions
|
|||
|
||||
private ParticleSystemRenderer _renderer;
|
||||
private ParticleSystem _particleSystem;
|
||||
internal int _prevParticleCount = 0;
|
||||
//private ParticleSystem _emitter;
|
||||
private UIParticle _parent;
|
||||
private int _index;
|
||||
|
@ -111,6 +112,7 @@ namespace Coffee.UIExtensions
|
|||
_parent = null;
|
||||
_particleSystem = null;
|
||||
_renderer = null;
|
||||
_prevParticleCount = 0;
|
||||
if (0 <= index )
|
||||
{
|
||||
_index = index;
|
||||
|
@ -135,6 +137,7 @@ namespace Coffee.UIExtensions
|
|||
if (_particleSystem.isPlaying)
|
||||
{
|
||||
_particleSystem.Clear();
|
||||
_particleSystem.Pause();
|
||||
}
|
||||
_prewarm = _particleSystem.main.prewarm;
|
||||
|
||||
|
@ -157,6 +160,7 @@ namespace Coffee.UIExtensions
|
|||
_prevPsPos = _particleSystem.transform.position;
|
||||
_prevScreenSize = new Vector2Int(Screen.width, Screen.height);
|
||||
_delay = true;
|
||||
_prevParticleCount = 0;
|
||||
|
||||
canvasRenderer.SetTexture(null);
|
||||
|
||||
|
@ -301,6 +305,12 @@ namespace Coffee.UIExtensions
|
|||
s_Renderers.Clear();
|
||||
}
|
||||
|
||||
internal void UpdateParticleCount()
|
||||
{
|
||||
if (!_particleSystem) return;
|
||||
_prevParticleCount = _particleSystem.particleCount;
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
@ -447,6 +457,22 @@ namespace Coffee.UIExtensions
|
|||
return;
|
||||
}
|
||||
|
||||
// Emitted particles found.
|
||||
if (_prevParticleCount != _particleSystem.particleCount)
|
||||
{
|
||||
var size = _particleSystem.particleCount;
|
||||
var particles = ParticleSystemExtensions.GetParticleArray(size);
|
||||
_particleSystem.GetParticles(particles, size);
|
||||
for (var i = _prevParticleCount; i < size; i++)
|
||||
{
|
||||
var p = particles[i];
|
||||
p.position = p.position.GetScaled(scale.Inverse());
|
||||
particles[i] = p;
|
||||
}
|
||||
|
||||
_particleSystem.SetParticles(particles, size);
|
||||
}
|
||||
|
||||
// get world position.
|
||||
var psTransform = _particleSystem.transform;
|
||||
var originWorldPosition = psTransform.position;
|
||||
|
|
|
@ -93,6 +93,12 @@ namespace Coffee.UIExtensions
|
|||
{
|
||||
s_ActiveAttractors[i].Attract();
|
||||
}
|
||||
|
||||
// UpdateParticleCount.
|
||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||
{
|
||||
s_ActiveParticles[i].UpdateParticleCount();
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetGroupedRenderers(int groupId, int index, List<UIParticleRenderer> results)
|
||||
|
|
Loading…
Reference in New Issue