Updated UIParticleSystem access to Particles array to ensure it is more stable.
Updated some #if statements to be better future proofed Resolves #360pull/413/head
parent
8a31713e46
commit
c059e2338a
|
@ -43,6 +43,22 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ParticleSystem.Particle[] Particles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (particles == null)
|
||||||
|
{
|
||||||
|
#if UNITY_5_5_OR_NEWER
|
||||||
|
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
||||||
|
#else
|
||||||
|
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return particles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected bool Initialize()
|
protected bool Initialize()
|
||||||
{
|
{
|
||||||
// initialize members
|
// initialize members
|
||||||
|
@ -67,7 +83,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (pSystem.maxParticles > 14000)
|
if (pSystem.maxParticles > 14000)
|
||||||
|
{
|
||||||
pSystem.maxParticles = 14000;
|
pSystem.maxParticles = 14000;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
||||||
|
@ -97,16 +115,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
#else
|
#else
|
||||||
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
particles = null;
|
|
||||||
}
|
}
|
||||||
#if UNITY_5_5_OR_NEWER
|
|
||||||
if (particles == null)
|
|
||||||
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
|
||||||
#else
|
|
||||||
if (particles == null)
|
|
||||||
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
imageUV = new Vector4(0, 0, 1, 1);
|
imageUV = new Vector4(0, 0, 1, 1);
|
||||||
|
|
||||||
|
@ -127,8 +136,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
if (!Initialize())
|
if (!Initialize())
|
||||||
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void OnPopulateMesh(VertexHelper vh)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
|
@ -160,11 +171,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
Vector2 corner1 = Vector2.zero;
|
Vector2 corner1 = Vector2.zero;
|
||||||
Vector2 corner2 = Vector2.zero;
|
Vector2 corner2 = Vector2.zero;
|
||||||
// iterate through current particles
|
// iterate through current particles
|
||||||
int count = pSystem.GetParticles(particles);
|
int count = pSystem.GetParticles(Particles);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
ParticleSystem.Particle particle = particles[i];
|
ParticleSystem.Particle particle = Particles[i];
|
||||||
|
|
||||||
// get particle properties
|
// get particle properties
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
|
@ -223,7 +234,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
|
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
|
||||||
|
|
||||||
int row = textureSheetAnimation.rowIndex;
|
int row = textureSheetAnimation.rowIndex;
|
||||||
#if UNITY_2020 || UNITY_2019
|
#if UNITY_2019_1_OR_NEWER
|
||||||
if (textureSheetAnimation.rowMode == ParticleSystemAnimationRowMode.Random)
|
if (textureSheetAnimation.rowMode == ParticleSystemAnimationRowMode.Random)
|
||||||
#else
|
#else
|
||||||
if (textureSheetAnimation.useRandomRow)
|
if (textureSheetAnimation.useRandomRow)
|
||||||
|
@ -378,8 +389,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == currentMaterial)
|
if (material == currentMaterial) { return; }
|
||||||
return;
|
|
||||||
pSystem = null;
|
pSystem = null;
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue