private void Awake() { if (firstGroup == null) { Debug.LogError("A cursor without a valid first group was activated! Please set a valid first group!"); gameObject.SetActive(false); return; } groupHistory = new Stack <SelectableGroup>(); optionHistory = new Stack <SelectableOptionBase>(); currentGroup = firstGroup; currentlySelectedOption = firstGroup.GetFirstOption(); if (mouseControls) { pointerEventData = new PointerEventData(null); } }
/// <summary> /// Enters the given SelectableGroup. /// </summary> /// <param name="group">The SelectableGroup to enter</param> /// <param name="selectOption">The option to select after entering the group (instead of the group's first option)</param> /// <param name="context">If set to true, the group change won't be recorded in the group history and option history stacks</param> public override void EnterGroup(SelectableGroup group, SelectableOptionBase selectOption = null, object context = null) { if (group != null) { if (context == null || (context is bool && (bool)context == false)) { groupHistory.Push(currentGroup); optionHistory.Push(currentlySelectedOption); } foreach (SelectableOptionBase option in currentGroup.options) { option.GroupLeft(this); } currentGroup = group; foreach (SelectableOptionBase option in group.options) { option.GroupEntered(this); } if (selectOption == null) { SelectOption(group.GetFirstOption()); } else { SelectOption(selectOption); } } else { Debug.LogWarning("A null group was almost entered, which shouldn't happen. Returning to the last one!"); } }