Fix UIParticleSystem does not correspond to runtime lengthScale change

release^2
eldar.zakaryaev 2023-07-05 11:24:50 +03:00
parent 2a925fcf65
commit 11de683781
1 changed files with 2 additions and 4 deletions

View File

@ -29,7 +29,6 @@ namespace UnityEngine.UI.Extensions
private Vector2 textureSheetAnimationFrameSize; private Vector2 textureSheetAnimationFrameSize;
private ParticleSystemRenderer pRenderer; private ParticleSystemRenderer pRenderer;
private bool isInitialised = false; private bool isInitialised = false;
private float _lengthScale;
private Material currentMaterial; private Material currentMaterial;
@ -96,7 +95,6 @@ namespace UnityEngine.UI.Extensions
if (pRenderer != null) if (pRenderer != null)
pRenderer.enabled = false; pRenderer.enabled = false;
_lengthScale = pRenderer.lengthScale;
if (material == null) if (material == null)
{ {
var foundShader = ShaderLibrary.GetShaderInstance("UI Extensions/Particles/Additive"); var foundShader = ShaderLibrary.GetShaderInstance("UI Extensions/Particles/Additive");
@ -285,8 +283,8 @@ namespace UnityEngine.UI.Extensions
float rotation = -particle.rotation * Mathf.Deg2Rad; float rotation = -particle.rotation * Mathf.Deg2Rad;
var lengthScale = _lengthScale; var lengthScale = pRenderer.lengthScale;
if (_useLengthScale) // this flag is mostly to secure old behaviour, it probably can be replaced with _lengthScale != 1 if (_useLengthScale)
{ {
// rotate towards velocity // rotate towards velocity
var normalizedVelocity = particle.velocity.normalized; var normalizedVelocity = particle.velocity.normalized;