public void Add(Health health) { HealthDisplay display = Instantiate(displayPrefab, displaysHead); displays.Add(display); display.SetUp(health); display.SetNewData(health); health.onUpdated += OnHealthUpdate; health.onDead += OnDead; LayoutRebuilder.MarkLayoutForRebuild(displaysHead.GetComponent <RectTransform>()); }
private void OnHealthUpdate(Health obj) { HealthDisplay display = displays.Find(o => o.IsOwner(obj)); display.SetNewData(obj); }