Example #1
0
        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;
        }
Example #2
0
        private void ApplyMaskingSettings(bool applyMask)
        {
            MaskingManager.Unmask();

            if (!applyMask || !maskingEnabled || m_CurrentTutorial == null || m_CurrentTutorial.currentPage == null || IsParentNull())
            {
                InternalEditorUtility.RepaintAllViews();
                return;
            }

            var maskingSettings = m_CurrentTutorial.currentPage.currentMaskingSettings;

            try
            {
                if (maskingSettings != null && maskingSettings.enabled)
                {
                    var unmaskedViews = UnmaskedView.GetViewsAndRects(maskingSettings.unmaskedViews);

                    if (m_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 && !m_CurrentTutorial.currentPage.paragraphs.Any(p => p.type == ParagraphType.Instruction))
                    {
                        highlightedViews = (UnmaskedView.MaskData)unmaskedViews.Clone();
                    }
                    // otherwise, if the current page is completed, highlight this window
                    else if (canMoveToNextPage)
                    {
                        highlightedViews = new UnmaskedView.MaskData();
                        highlightedViews.AddParent(this);
                    }
                    // otherwise, highlight manually specified control rects if there are any
                    else
                    {
                        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.AddParent(this);
                    unmaskedViews.AddTooltipViews();

                    // tooltip views should not be highlighted
                    highlightedViews.RemoveTooltipViews();

                    MaskingManager.Mask(
                        unmaskedViews,
                        m_Styles == null ? Color.magenta * new Color(1f, 1f, 1f, 0.8f) : m_Styles.maskingColor,
                        highlightedViews,
                        m_Styles == null ? Color.cyan * new Color(1f, 1f, 1f, 0.8f) : m_Styles.highlightColor,
                        m_Styles == null ? 3f : m_Styles.highlightThickness
                        );
                }
            }
            catch (ArgumentException e)
            {
                if (ProjectMode.IsAuthoringMode())
                {
                    Debug.LogException(e, m_CurrentTutorial.currentPage);
                }
                else
                {
                    Console.WriteLine(StackTraceUtility.ExtractStringFromException(e));
                }
            }
            finally
            {
                InternalEditorUtility.RepaintAllViews();
            }
        }
Example #3
0
        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();
            }
        }
Example #4
0
 void Unmask()
 {
     MaskingManager.Unmask();
     MaskingEnabled = false;
 }