parent
a499f0c046
commit
a4bcf93022
|
@ -72,22 +72,25 @@ namespace Coffee.UIExtensions
|
|||
}
|
||||
}
|
||||
|
||||
public ParticleSystem particleSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParticleSystem;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ParticleSystem = value;
|
||||
if (!ApplyParticleSystem()) return;
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private UIParticle _uiParticle;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (m_ParticleSystem == null)
|
||||
{
|
||||
Debug.LogError("No particle system attached to particle attractor script", this);
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_uiParticle = m_ParticleSystem.GetComponentInParent<UIParticle>();
|
||||
if (_uiParticle && !_uiParticle.particles.Contains(m_ParticleSystem))
|
||||
{
|
||||
_uiParticle = null;
|
||||
}
|
||||
if (!ApplyParticleSystem()) return;
|
||||
UIParticleUpdater.Register(this);
|
||||
}
|
||||
|
||||
|
@ -200,5 +203,22 @@ namespace Coffee.UIExtensions
|
|||
return Vector3.MoveTowards(current, target, speed);
|
||||
}
|
||||
|
||||
private bool ApplyParticleSystem()
|
||||
{
|
||||
if (m_ParticleSystem == null)
|
||||
{
|
||||
Debug.LogError("No particle system attached to particle attractor script", this);
|
||||
enabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
_uiParticle = m_ParticleSystem.GetComponentInParent<UIParticle>();
|
||||
if (_uiParticle && !_uiParticle.particles.Contains(m_ParticleSystem))
|
||||
{
|
||||
_uiParticle = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue