internal void UpdateViewTransform(FindInGraphAdapter.FindSearcherItem item)
        {
            if (item == null)
            {
                return;
            }

            GraphElement elt = null;
            Vector3      frameTranslation;
            Vector3      frameScaling;

            if (ModelsToNodeMapping?.TryGetValue(item.Node, out elt) ?? false)
            {
                m_GraphView.ClearSelection();
                m_GraphView.AddToSelection(elt);

                Rect rect = elt.parent.ChangeCoordinatesTo(m_GraphView.contentViewContainer, elt.localBound);
                GraphView.CalculateFrameTransform(
                    rect, m_GraphView.layout, 30, out frameTranslation, out frameScaling
                    );
            }
            else
            {
                Debug.LogError("no ui mapping for " + item.Name);
                GraphView.CalculateFrameTransform(
                    new Rect(item.Node.ParentStackModel?.Position ?? item.Node.Position, Vector2.one),
                    m_GraphView.layout,
                    30,
                    out frameTranslation,
                    out frameScaling
                    );
            }

            m_GraphView.UpdateViewTransform(frameTranslation, frameScaling);
        }
        public void DisplayCompilationErrors(State state)
        {
            VseUtility.RemoveLogEntries();
            if (ModelsToNodeMapping == null)
            {
                UpdateTopology();
            }

            var lastCompilationResult = state.CompilationResultModel.GetLastResult();

            if (lastCompilationResult?.errors == null)
            {
                return;
            }

            foreach (var error in lastCompilationResult.errors)
            {
                if (error.sourceNode != null && !error.sourceNode.Destroyed)
                {
                    var alignment = error.sourceNode is IStackModel
                        ? SpriteAlignment.TopCenter
                        : SpriteAlignment.RightCenter;

                    ModelsToNodeMapping.TryGetValue(error.sourceNode, out var graphElement);
                    if (graphElement != null)
                    {
                        AttachErrorBadge(graphElement, error.description, alignment, m_Store, error.quickFix);
                    }
                }

                var graphAsset     = (GraphAssetModel)m_Store.GetState().CurrentGraphModel?.AssetModel;
                var graphAssetPath = graphAsset ? AssetDatabase.GetAssetPath(graphAsset) : "<unknown>";
                VseUtility.LogSticky(error.isWarning ? LogType.Warning : LogType.Error, LogOption.None, $"{graphAssetPath}: {error.description}", $"{graphAssetPath}@{error.sourceNodeGuid}", graphAsset.GetInstanceID());
            }
        }
Beispiel #3
0
        public void DisplayCompilationErrors(State state)
        {
            VseUtility.RemoveLogEntries();
            if (ModelsToNodeMapping == null)
            {
                UpdateTopology();
            }

            var lastCompilationResult = state.CompilationResultModel.GetLastResult();

            if (lastCompilationResult?.errors == null)
            {
                return;
            }

            foreach (var error in lastCompilationResult.errors)
            {
                if (!(error.sourceNode.Model is INodeModel model))
                {
                    continue;
                }

                var alignment = model is IStackModel
                    ? SpriteAlignment.TopCenter
                    : SpriteAlignment.RightCenter;

                ModelsToNodeMapping.TryGetValue(model, out var graphElement);
                if (graphElement != null)
                {
                    AttachErrorBadge(graphElement, error.description, alignment, m_Store, error.quickFix);
                }

                var graphAssetPath = AssetDatabase.GetAssetPath((GraphAssetModel)m_Store.GetState().CurrentGraphModel.AssetModel);
                VseUtility.LogSticky(LogType.Error, LogOption.None, $"{graphAssetPath}: {error.description}", graphAssetPath, error.sourceNodeId);
            }
        }