public void Init(Entity owner, Canvas parentCanvas, float fromHPRatio, float toHPRatio) { if (owner == null) { Log.Error("Owner is invalid."); return; } m_ParentCanvas = parentCanvas; ReferenceCollector.gameObject.SetActive(true); ReferenceCollector.StopAllCoroutines(); m_CachedCanvasGroup.alpha = 1f; //检查所属实体 if (m_Owner != owner || m_OwnerId != owner.Id) { m_HPBar.value = fromHPRatio; m_Owner = owner; m_OwnerId = owner.Id; } Refresh(); //刷新 ReferenceCollector.StartCoroutine(HPBarCo(toHPRatio, AnimationSeconds, KeepSeconds, FadeOutSeconds)); }
public void Reset() { ReferenceCollector.StopAllCoroutines(); //停止所有协程 m_CachedCanvasGroup.alpha = 1f; m_HPBar.value = 1f; m_Owner = null; ReferenceCollector.gameObject.SetActive(false); }