/*--------------------------------------------------------------------------------------------*/ private HoverItemHighlightState FindNearestItemToCursor(CursorType pCursorType, out HoverItemHighlightState.Highlight? pNearestHigh) { float minDist = float.MaxValue; HoverItemHighlightState nearestItem = null; pNearestHigh = null; for ( int i = 0 ; i < vHighStates.Count ; i++ ) { HoverItemHighlightState item = vHighStates[i]; if ( !item.gameObject.activeInHierarchy || item.IsHighlightPrevented ) { continue; } HoverItemHighlightState.Highlight? high = item.GetHighlight(pCursorType); if ( high == null || high.Value.Distance >= minDist ) { continue; } minDist = high.Value.Distance; nearestItem = item; pNearestHigh = high; } return nearestItem; }
/*--------------------------------------------------------------------------------------------*/ public override void OnInspectorGUI() { vTarget = (HoverItemHighlightState)target; DrawDefaultInspector(); DrawHighlightInfo(); }
/*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateSliderSettings( HoverItem pHoverItem, HoverItemHighlightState pHighState) { HoverItemDataSlider data = (HoverItemDataSlider)pHoverItem.Data; HoverItemHighlightState.Highlight? high = pHighState.NearestHighlight; float highProg = pHighState.MaxHighlightProgress; bool isNearest = pHighState.IsNearestAcrossAllItemsForAnyCursor; SliderRenderer.HighlightProgress = highProg; SliderRenderer.ShowEdge = isNearest; if ( high == null || highProg <= 0 || !isNearest ) { data.HoverValue = null; SliderRenderer.JumpValue = -1; return; } float value = SliderRenderer.GetValueViaNearestWorldPosition(high.Value.NearestWorldPos); data.HoverValue = value; float snapValue = (float)data.SnappedHoverValue; //float easePower = (1-high.Value.Progress)*5+1; //gets "snappier" as you pull away float showValue = DisplayUtil.GetEasedValue(data.Snaps, value, snapValue, 3); SliderRenderer.JumpValue = showValue; if ( data.IsStickySelected ) { data.Value = value; SliderRenderer.HandleValue = showValue; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateButtonSettings(HoverItemHighlightState pHighState) { ButtonRenderer.HighlightProgress = pHighState.MaxHighlightProgress; ButtonRenderer.ShowEdge = pHighState.IsNearestAcrossAllItemsForAnyCursor; }
/*--------------------------------------------------------------------------------------------*/ private void UpdateRendererIndicator(HoverRenderer pRenderer, HoverItemHighlightState pHighState, HoverItemSelectionState pSelState) { HoverIndicator rendInd = pRenderer.GetIndicator(); rendInd.Controllers.Set(HoverIndicator.HighlightProgressName, this); rendInd.Controllers.Set(HoverIndicator.SelectionProgressName, this); rendInd.HighlightProgress = pHighState.MaxHighlightProgress; rendInd.SelectionProgress = pSelState.SelectionProgress; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateButtonSettings(HoverItemHighlightState pHighState) { ButtonRenderer.Fill.Controllers.Set(HoverFillButton.ShowEdgeName, this); ButtonRenderer.Fill.ShowEdge = pHighState.IsNearestAcrossAllItemsForAnyCursor; }
/*--------------------------------------------------------------------------------------------*/ private void UpdateHighState(HoverItemHighlightState pHighState, bool pPreventHighlight) { pHighState.PreventHighlightViaDisplay(PreventKey, pPreventHighlight); }