Example #1
0
        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);
            }
        }
Example #2
0
        /// <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!");
            }
        }
Example #3
0
 /// <summary>
 /// Make a cursor enter the specified group.
 /// </summary>
 /// <param name="group">The group that should be entered</param>
 /// <param name="selectOption">The option within the group to select. If this is null, the first option of the group will be used.</param>
 /// <param name="context">Use this to pass custom data to the cursor</param>
 public virtual void EnterGroup(SelectableGroup group, SelectableOptionBase selectOption = null, object context = null)
 {
 }