using UnityEngine; public class PartCounter : MonoBehaviour { public BasePart.PartType m_partType; private TextMesh m_textMesh; private void Awake() { m_textMesh = GetComponent(); EventManager.Connect(ReceivePartCountChangedEvent); } private void OnDestroy() { EventManager.Disconnect(ReceivePartCountChangedEvent); } private void ReceivePartCountChangedEvent(PartCountChanged data) { if (data.partType != m_partType) { return; } m_textMesh.text = data.count.ToString(); if (data.count == 0) { GameObject icon = base.transform.parent.GetComponent().Icon; if ((bool)icon) { icon.renderer.material.color = new Color(0.4f, 0.4f, 0.4f, 0.4f); } } else { GameObject icon2 = base.transform.parent.GetComponent().Icon; if ((bool)icon2) { icon2.renderer.material.color = new Color(1f, 1f, 1f, 1f); } } } }