fix: the ParticleSystem's localPosition drifts at certain scales due to floating-point precision issues
close #299, close #312pull/318/head
parent
19989cf18c
commit
e924eb4596
|
@ -632,6 +632,8 @@ namespace Coffee.UIExtensions
|
||||||
// get world position.
|
// get world position.
|
||||||
var isLocalSpace = _particleSystem.IsLocalSpace();
|
var isLocalSpace = _particleSystem.IsLocalSpace();
|
||||||
var psTransform = _particleSystem.transform;
|
var psTransform = _particleSystem.transform;
|
||||||
|
var originLocalPosition = psTransform.localPosition;
|
||||||
|
var originLocalRotation = psTransform.localRotation;
|
||||||
var originWorldPosition = psTransform.position;
|
var originWorldPosition = psTransform.position;
|
||||||
var originWorldRotation = psTransform.rotation;
|
var originWorldRotation = psTransform.rotation;
|
||||||
var emission = _particleSystem.emission;
|
var emission = _particleSystem.emission;
|
||||||
|
@ -654,7 +656,8 @@ namespace Coffee.UIExtensions
|
||||||
: originWorldPosition.GetScaled(scale.Inverse());
|
: originWorldPosition.GetScaled(scale.Inverse());
|
||||||
psTransform.SetPositionAndRotation(scaledPos, originWorldRotation);
|
psTransform.SetPositionAndRotation(scaledPos, originWorldRotation);
|
||||||
_particleSystem.Simulate(deltaTime, false, false, false);
|
_particleSystem.Simulate(deltaTime, false, false, false);
|
||||||
psTransform.SetPositionAndRotation(originWorldPosition, originWorldRotation);
|
psTransform.localPosition = originLocalPosition;
|
||||||
|
psTransform.localRotation = originLocalRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
|
Loading…
Reference in New Issue