70 lines
1.6 KiB
C#
70 lines
1.6 KiB
C#
using S_SnapTools;
|
|
using UnityEngine;
|
|
|
|
namespace LE_LevelEditor.UI
|
|
{
|
|
public class LE_GUISnapButtonParticleSys : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Material m_openedMaterial;
|
|
|
|
[SerializeField]
|
|
private Material m_closedMaterial;
|
|
|
|
private S_SnapToObject m_parent;
|
|
|
|
private Renderer m_particleSysRenderer;
|
|
|
|
private bool m_isClosed = true;
|
|
|
|
private void Start()
|
|
{
|
|
m_parent = base.transform.GetComponentInParent<S_SnapToObject>();
|
|
if (m_parent == null)
|
|
{
|
|
Debug.LogError("LE_GUISnapButtonParticleSys: could not find S_SnapToObject in parent.");
|
|
Object.Destroy(this);
|
|
return;
|
|
}
|
|
ParticleSystem component = GetComponent<ParticleSystem>();
|
|
if (component == null)
|
|
{
|
|
Debug.LogError("LE_GUISnapButtonParticleSys: could not find ParticleSystem.");
|
|
Object.Destroy(this);
|
|
return;
|
|
}
|
|
m_particleSysRenderer = component.GetComponent<Renderer>();
|
|
if (m_particleSysRenderer == null)
|
|
{
|
|
Debug.LogError("LE_GUISnapButtonParticleSys: could not find Renderer for ParticleSystem.");
|
|
Object.Destroy(this);
|
|
}
|
|
else
|
|
{
|
|
m_particleSysRenderer.sharedMaterial = m_closedMaterial;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (m_parent != null && m_particleSysRenderer != null)
|
|
{
|
|
if (m_isClosed && m_parent.IsPrefabSelectionOpen)
|
|
{
|
|
m_isClosed = false;
|
|
m_particleSysRenderer.sharedMaterial = m_openedMaterial;
|
|
}
|
|
else if (!m_isClosed && !m_parent.IsPrefabSelectionOpen)
|
|
{
|
|
m_isClosed = true;
|
|
m_particleSysRenderer.sharedMaterial = m_closedMaterial;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Object.Destroy(this);
|
|
}
|
|
}
|
|
}
|
|
}
|