public void RegisterObjective(Objective objective) { objective.onUpdateObjective += OnUpdateObjective; // instanciate the Ui element for the new objective GameObject objectiveUIInstance = objective.isOptional ? secondaryObjectivePrefab.getObject(true, objectivePanel.transform) : primaryObjectivePrefab.getObject(true, objectivePanel.transform); if (!objective.isOptional) { objectiveUIInstance.transform.SetSiblingIndex(0); } ObjectiveToast toast = objectiveUIInstance.GetComponent <ObjectiveToast>(); DebugUtility.HandleErrorIfNullGetComponent <ObjectiveToast, ObjectiveHUDManger>(toast, this, objectiveUIInstance.gameObject); // initialize the element and give it the objective description toast.Initialize(objective.title, objective.description, objective.GetUpdatedCounterAmount(), objective.isOptional, objective.delayVisible); m_ObjectivesDictionary.Add(objective, toast); if (showObjectivePanel) { objectivePanel.UpdateTable(toast.gameObject); } }
public void RegisterObjective(Objective objective) { objective.onUpdateObjective += OnUpdateObjective; // instanciate the Ui element for the new objective GameObject objectiveUIInstance = Instantiate(objective.isOptional ? secondaryObjectivePrefab : primaryObjectivePrefab, objectivePanel); if (!objective.isOptional) { objectiveUIInstance.transform.SetSiblingIndex(0); } ObjectiveToast toast = objectiveUIInstance.GetComponent <ObjectiveToast>(); DebugUtility.HandleErrorIfNullGetComponent <ObjectiveToast, ObjectiveHUDManger>(toast, this, objectiveUIInstance.gameObject); // initialize the element and give it the objective description toast.Initialize(objective.title, objective.description, "", objective.isOptional, objective.delayVisible); m_ObjectivesDictionnary.Add(objective, toast); UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(objectivePanel); }