public static void ShowErrorBadge(
            this IBadgeContainer self,
            VisualElement parent,
            SpriteAlignment alignment,
            string description,
            Store store,
            CompilerQuickFix errorQuickFix
            )
        {
            Assert.IsNotNull(parent);
            Assert.IsTrue(self is VisualElement);

            var target = (VisualElement)self;

            if (self.ErrorBadge?.parent == null)
            {
                var message = description;
                if (errorQuickFix != null)
                {
                    message += $"\r\nQuick fix: {errorQuickFix.description}";
                }

                self.ErrorBadge = IconBadge.CreateError(message);
                parent.Add(self.ErrorBadge);
                self.ErrorBadge.AttachTo(target, alignment);

                target.EnableInClassList(k_HasErrorBadge, true);
                if (errorQuickFix != null)
                {
                    self.ErrorBadge.RegisterCallback <MouseDownEvent>(e => errorQuickFix.quickFix(store));
                }

                return;
            }

            self.ErrorBadge.AttachTo(target, alignment);
        }
コード例 #2
0
 public void AddError(INodeModel model, string error, CompilerQuickFix quickFix = null)
 {
     m_Errors.Add(new CompilerError {
         sourceNode = model, sourceNodeGuid = model.Guid, description = error, quickFix = quickFix
     });
 }
コード例 #3
0
 public void AddWarning(INodeModel model, string warning, CompilerQuickFix quickFix = null)
 {
     m_Errors.Add(new CompilerError {
         sourceNode = model, sourceNodeGuid = model.Guid, description = warning, quickFix = quickFix, isWarning = true
     });
 }
コード例 #4
0
        internal void AttachErrorBadge(VisualElement visualElement, string errorDescription, SpriteAlignment alignment, Store store = null, CompilerQuickFix errorQuickFix = null)
        {
            Assert.IsNotNull(visualElement);
            if (errorQuickFix != null)
            {
                Assert.IsNotNull(store);
            }

            VisualElement parent = visualElement.parent;

            while (parent.GetType().IsSubclassOf(typeof(GraphElement)) && parent.parent != null)
            {
                parent = parent.parent;
            }

            (visualElement as IBadgeContainer)?.ShowErrorBadge(m_IconsParent, alignment, errorDescription, store, errorQuickFix);
        }