Skip to content

Commit

Permalink
fix: incorrect rendering of world-space simulated particles while ani…
Browse files Browse the repository at this point in the history
…mating scale

close #285
  • Loading branch information
mob-sakai committed Dec 23, 2023
1 parent 5607dc4 commit ac58475
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Scripts/UIParticleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal class UIParticleRenderer : MaskableGraphic
private Vector3 _prevPsPos;
private Vector3 _prevScale;
private Vector2Int _prevScreenSize;
private float _prevCanvasScale;
private bool _prewarm;
private ParticleSystemRenderer _renderer;

Expand Down Expand Up @@ -246,6 +247,7 @@ public void Set(UIParticle parent, ParticleSystem ps, bool isTrail)
_prevScale = GetWorldScale();
_prevPsPos = _particleSystem.transform.position;
_prevScreenSize = new Vector2Int(Screen.width, Screen.height);
_prevCanvasScale = canvas ? canvas.scaleFactor : 1f;
_delay = true;
_prevParticleCount = 0;

Expand Down Expand Up @@ -534,7 +536,8 @@ private void ResolveResolutionChange(Vector3 psPos, Vector3 scale)
{
var screenSize = new Vector2Int(Screen.width, Screen.height);
var isWorldSpace = _particleSystem.IsWorldSpace();
var resolutionChanged = _prevScreenSize != screenSize || _prevScale != scale;
var canvasScale = _parent.canvas ? _parent.canvas.scaleFactor : 1f;
var resolutionChanged = _prevScreenSize != screenSize || _prevCanvasScale != canvasScale;
if (resolutionChanged && isWorldSpace)
{
// Update particle array size and get particles.
Expand Down Expand Up @@ -563,6 +566,7 @@ private void ResolveResolutionChange(Vector3 psPos, Vector3 scale)
_prevPsPos = psPos;
}

_prevCanvasScale = canvas ? canvas.scaleFactor : 1f;
_prevScreenSize = screenSize;
}

Expand Down

0 comments on commit ac58475

Please sign in to comment.