public void AddHighlight(ControllerHighlight highlight) { highlights.Add(highlight); if (!string.IsNullOrEmpty(highlight.tooltipText) && highlight.tooltipButton != VRTK_ControllerTooltips.TooltipButtons.None) { string tooltip = ""; for (int i = 0; i < highlights.Count; ++i) { if (highlights[i].tooltipButton == highlight.tooltipButton) { if (!string.IsNullOrEmpty(tooltip)) { tooltip += "\n"; } tooltip += highlights[i].tooltipText; } } tooltips.UpdateText(highlight.tooltipButton, tooltip); } if (highlight.highlightElements != null) { for (int i = 0; i < highlight.highlightElements.Length; ++i) { highlighter.HighlightElement(highlight.highlightElements[i], highlight.highlightColor); } } }
public void RemoveHighlight(ControllerHighlight highlight) { int idx = -1; bool[] keepHighlight = highlight.highlightElements != null ? new bool[highlight.highlightElements.Length] : null; string tooltip = ""; for (int i = 0; i < highlights.Count; ++i) { if (highlights[i] == highlight) { idx = i; } else { if (highlights[i].tooltipButton == highlight.tooltipButton) { if (!string.IsNullOrEmpty(tooltip)) { tooltip += "\n"; } tooltip += highlights[i].tooltipText; } if (highlight.highlightElements != null && highlights[i].highlightElements != null) { for (int j = 0; j < highlights[i].highlightElements.Length; ++j) { for (int k = 0; k < highlight.highlightElements.Length; ++k) { if (highlights[i].highlightElements[j] == highlight.highlightElements[k]) { keepHighlight[k] = true; } } //if (highlights[i].highlightElement == highlight.highlightElement) // keepHighlight = true; } } } } if (idx != -1) { tooltips.UpdateText(highlight.tooltipButton, tooltip); if (keepHighlight != null) { for (int i = 0; i < keepHighlight.Length; ++i) { if (!keepHighlight[i]) { highlighter.UnhighlightElement(highlight.highlightElements[i]); } } } highlights.RemoveAt(idx); } }
public NavigableUIList(ITypedDataCursor <UIListState> state, Camera camera, Action <int> selectItem) { _isInteractable = state.To(s => s.IsInteractable); _selectItem = selectItem; _highlightedIndex = state.To(s => s.HighlightedIndex); MouseHighlight.Initialize(state); MouseInteraction.LeftMouseClick(state.To(s => s.Items).Get(), selectItem); _controllerHighlight = ControllerHighlight.CreateControllerIndexUpdater( cursor: state, itemSelector: (items, currentIndex, inputDirection) => { return(ControllerHighlight.MoveControllerIndex(camera.WorldToScreenPoint, items, currentIndex, inputDirection)); }); Highlighter.Initialize(state); }