Compare commits

..

No commits in common. "90fd22498fb4b81195a13d270a666c736e24f2dd" and "d2b10980e380e1c9afef61dee63ca2b45b5eccf9" have entirely different histories.

2 changed files with 8 additions and 25 deletions

View File

@ -16,9 +16,6 @@ namespace UnityEngine.UI.Extensions
[Tooltip("Enables 3d rotation for the particles")]
public bool use3dRotation = false;
[Tooltip("Enables using Renderer.lengthScale parameter")]
public bool _useLengthScale = false;
private Transform _transform;
private ParticleSystem pSystem;
private ParticleSystem.Particle[] particles;
@ -94,7 +91,7 @@ namespace UnityEngine.UI.Extensions
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
if (pRenderer != null)
pRenderer.enabled = false;
if (material == null)
{
var foundShader = ShaderLibrary.GetShaderInstance("UI Extensions/Particles/Additive");
@ -186,6 +183,8 @@ namespace UnityEngine.UI.Extensions
#else
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
#endif
float rotation = -particle.rotation * Mathf.Deg2Rad;
float rotation90 = rotation + Mathf.PI / 2;
Color32 color = particle.GetCurrentColor(pSystem);
float size = particle.GetCurrentSize(pSystem) * 0.5f;
@ -281,29 +280,13 @@ namespace UnityEngine.UI.Extensions
_quad[3].color = color;
_quad[3].uv0 = temp;
float rotation = -particle.rotation * Mathf.Deg2Rad;
var lengthScale = pRenderer.lengthScale;
if (_useLengthScale)
{
// rotate towards velocity
var normalizedVelocity = particle.velocity.normalized;
rotation = Mathf.Atan2(normalizedVelocity.y, normalizedVelocity.x);
}
else
{
lengthScale = 1f;
}
float rotation90 = rotation + Mathf.PI / 2;
if (rotation == 0)
{
// no rotation
corner1.x = position.x - size;
corner1.y = position.y - size * lengthScale;
corner1.y = position.y - size;
corner2.x = position.x + size;
corner2.y = position.y + size * lengthScale;
corner2.y = position.y + size;
temp.x = corner1.x;
temp.y = corner1.y;
@ -356,7 +339,7 @@ namespace UnityEngine.UI.Extensions
else
{
// apply rotation
Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size * lengthScale;
Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size;
Vector2 up = new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size;
_quad[0].position = position - right - up;

View File

@ -287,7 +287,7 @@ namespace UnityEngine.UI.Extensions
PopulateMesh (vh, m_points);
}
if (m_segments != null && m_segments.Count > 0) {
else if (m_segments != null && m_segments.Count > 0) {
GeneratedUVs ();
vh.Clear ();
@ -480,4 +480,4 @@ namespace UnityEngine.UI.Extensions
}
}
}
}
}