void Mask() { var styles = m_Styles; var maskingColor = styles?.maskingColor ?? Color.magenta * new Color(1f, 1f, 1f, 0.8f); var highlightColor = styles?.highlightColor ?? Color.cyan * new Color(1f, 1f, 1f, 0.8f); var blockedInteractionColor = styles?.blockedInteractionColor ?? new Color(1, 1, 1, 0.5f); var highlightThickness = styles?.highlightThickness ?? 3f; var unmaskedViews = new UnmaskedView.MaskData(); unmaskedViews.AddParentFullyUnmasked(this); var highlightedViews = new UnmaskedView.MaskData(); MaskingManager.Mask( unmaskedViews, maskingColor, highlightedViews, highlightColor, blockedInteractionColor, highlightThickness ); MaskingEnabled = true; }
void ApplyMaskingSettings(bool applyMask) { // TODO IsParentNull() probably not needed anymore as TutorialWindow is always parented in the current design & layout. if (!applyMask || !maskingEnabled || currentTutorial == null || currentTutorial.currentPage == null || IsParentNull() || TutorialManager.IsLoadingLayout) { MaskingManager.Unmask(); InternalEditorUtility.RepaintAllViews(); return; } MaskingSettings maskingSettings = currentTutorial.currentPage.currentMaskingSettings; try { if (maskingSettings == null || !maskingSettings.enabled) { MaskingManager.Unmask(); } else { bool foundAncestorProperty; var unmaskedViews = UnmaskedView.GetViewsAndRects(maskingSettings.unmaskedViews, out foundAncestorProperty); if (foundAncestorProperty) { // Keep updating mask when target property is not unfolded QueueMaskUpdate(); } if (currentTutorial.currentPageIndex <= m_FarthestPageCompleted) { unmaskedViews = new UnmaskedView.MaskData(); } UnmaskedView.MaskData highlightedViews; // if the current page contains no instructions, assume unmasked views should be highlighted because they are called out in narrative text if (unmaskedViews.Count > 0 && !currentTutorial.currentPage.paragraphs.Any(p => p.type == ParagraphType.Instruction)) { highlightedViews = (UnmaskedView.MaskData)unmaskedViews.Clone(); } else if (canMoveToNextPage) // otherwise, if the current page is completed, highlight this window { highlightedViews = new UnmaskedView.MaskData(); highlightedViews.AddParentFullyUnmasked(this); } else // otherwise, highlight manually specified control rects if there are any { var unmaskedControls = new List <GUIControlSelector>(); var unmaskedViewsWithControlsSpecified = maskingSettings.unmaskedViews.Where(v => v.GetUnmaskedControls(unmaskedControls) > 0).ToArray(); // if there are no manually specified control rects, highlight all unmasked views highlightedViews = UnmaskedView.GetViewsAndRects( unmaskedViewsWithControlsSpecified.Length == 0 ? maskingSettings.unmaskedViews : unmaskedViewsWithControlsSpecified ); } // ensure tutorial window's HostView and tooltips are not masked unmaskedViews.AddParentFullyUnmasked(this); unmaskedViews.AddTooltipViews(); // tooltip views should not be highlighted highlightedViews.RemoveTooltipViews(); MaskingManager.Mask( unmaskedViews, styles == null ? Color.magenta * new Color(1f, 1f, 1f, 0.8f) : styles.MaskingColor, highlightedViews, styles == null ? Color.cyan * new Color(1f, 1f, 1f, 0.8f) : styles.HighlightColor, styles == null ? new Color(1, 1, 1, 0.5f) : styles.BlockedInteractionColor, styles == null ? 3f : styles.HighlightThickness ); } } catch (ArgumentException e) { if (s_AuthoringMode) { Debug.LogException(e, currentTutorial.currentPage); } else { Console.WriteLine(StackTraceUtility.ExtractStringFromException(e)); } MaskingManager.Unmask(); } finally { InternalEditorUtility.RepaintAllViews(); } }