示例#1
0
        /*--------------------------------------------------------------------------------------------*/
        private bool UpdateState()
        {
            HoverItemData       itemData = GetComponent <HoverItem>().Data;
            IItemDataSelectable selData  = (itemData as IItemDataSelectable);

            WasSelectedThisFrame = false;

            if (selData == null)
            {
                return(false);
            }

            ////

            HoverItemHighlightState highState = GetComponent <HoverItemHighlightState>();

            bool canSelect = (
                !highState.IsHighlightPrevented &&
                highState.IsNearestAcrossAllItemsForAnyCursor &&
                selData.AllowSelection
                );

            if (SelectionProgress <= 0 || !canSelect)
            {
                selData.DeselectStickySelections();
            }

            if (!canSelect || highState.MaxHighlightProgress < 1)
            {
                IsSelectionPrevented = false;
                vSelectionStart      = null;
                return(false);
            }

            ////

            if (IsSelectionPrevented)
            {
                vSelectionStart = null;
                return(false);
            }

            if (vSelectionStart == null)
            {
                vSelectionStart = DateTime.UtcNow;
                return(false);
            }

            if (SelectionProgress < 1)
            {
                return(false);
            }

            vSelectionStart        = null;
            IsSelectionPrevented   = true;
            WasSelectedThisFrame   = true;
            vDistanceUponSelection = highState.NearestHighlight.Value.Distance;
            selData.Select();
            return(true);
        }
        /*--------------------------------------------------------------------------------------------*/
        private bool UpdateState()
        {
            HoverItemData       itemData = GetComponent <HoverItem>().Data;
            IItemDataSelectable selData  = (itemData as IItemDataSelectable);

            WasSelectedThisFrame = false;

            if (selData == null || selData.IgnoreSelection)
            {
                return(false);
            }

            ////

            HoverItemHighlightState highState = GetComponent <HoverItemHighlightState>();
            bool hasNearestCursorWithFullHigh = false;

            bool canDeselect = (
                highState.IsHighlightPrevented ||
                !highState.IsNearestAcrossAllItemsForAnyCursor ||
                !selData.IsEnabled
                );

            for (int i = 0; i < highState.Highlights.Count; i++)
            {
                HoverItemHighlightState.Highlight high = highState.Highlights[i];

                if (high.IsNearestAcrossAllItems && high.Progress >= 1)
                {
                    hasNearestCursorWithFullHigh = true;
                    break;
                }
            }

            if (SelectionProgress <= 0 || canDeselect)
            {
                selData.DeselectStickySelections();
            }

            if (canDeselect || !hasNearestCursorWithFullHigh)
            {
                IsSelectionPrevented = false;
                vSelectionStart      = null;
                return(false);
            }

            ////

            if (IsSelectionPrevented)
            {
                vSelectionStart = null;
                return(false);
            }

            if (vSelectionStart == null)
            {
                vSelectionStart = DateTime.UtcNow;
                return(false);
            }

            if (SelectionProgress < 1)
            {
                return(false);
            }

            vSelectionStart        = null;
            IsSelectionPrevented   = true;
            WasSelectedThisFrame   = true;
            vDistanceUponSelection = highState.NearestHighlight.Value.Distance;
            selData.Select();
            return(true);
        }