fix: UIParticleAttractor attracts the particles at wrong position when in RelativeMode
close #262pull/289/head
parent
392ab6dd76
commit
68d9925a16
|
@ -186,29 +186,33 @@ namespace Coffee.UIExtensions
|
||||||
var psPos = m_ParticleSystem.transform.position;
|
var psPos = m_ParticleSystem.transform.position;
|
||||||
var attractorPos = transform.position;
|
var attractorPos = transform.position;
|
||||||
var dstPos = attractorPos;
|
var dstPos = attractorPos;
|
||||||
if (m_ParticleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local)
|
var isLocalSpace = m_ParticleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local;
|
||||||
|
|
||||||
|
if (isLocalSpace)
|
||||||
{
|
{
|
||||||
dstPos = m_ParticleSystem.transform.InverseTransformPoint(dstPos);
|
dstPos = m_ParticleSystem.transform.InverseTransformPoint(dstPos);
|
||||||
|
}
|
||||||
|
|
||||||
if (isUI)
|
if (isUI)
|
||||||
{
|
{
|
||||||
dstPos = dstPos.GetScaled(_uiParticle.transform.localScale, _uiParticle.scale3D.Inverse());
|
var inverseScale = _uiParticle.parentScale.Inverse();
|
||||||
}
|
dstPos = dstPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
||||||
}
|
|
||||||
else
|
// Relative mode
|
||||||
|
if (!_uiParticle.absoluteMode)
|
||||||
{
|
{
|
||||||
|
var diff = _uiParticle.transform.position - psPos;
|
||||||
|
diff.Scale(_uiParticle.scale3D - inverseScale);
|
||||||
|
diff.Scale(_uiParticle.scale3D.Inverse());
|
||||||
|
dstPos += diff;
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying && isUI)
|
if (!Application.isPlaying && !isLocalSpace)
|
||||||
{
|
{
|
||||||
var diff = dstPos - psPos;
|
dstPos += psPos - psPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
||||||
diff = diff.GetScaled(_uiParticle.transform.localScale, _uiParticle.scale3D.Inverse());
|
|
||||||
return psPos + diff;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (isUI)
|
|
||||||
{
|
|
||||||
dstPos.Scale(_uiParticle.transform.localScale);
|
|
||||||
dstPos.Scale(_uiParticle.scale3D.Inverse());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dstPos;
|
return dstPos;
|
||||||
|
|
Loading…
Reference in New Issue