using System; using System.Collections.Generic; using System.Linq; using UnityEditor.Graphing; using UnityEngine; using UnityEditor.Experimental.GraphView; using UnityEditor.ShaderGraph.Internal; using UnityEngine.UIElements; namespace UnityEditor.ShaderGraph.Drawing.Views.Blackboard { class BlackboardProvider { readonly GraphData m_Graph; public static readonly Texture2D exposedIcon = Resources.Load("GraphView/Nodes/BlackboardFieldExposed"); readonly Dictionary m_InputRows; readonly SGBlackboardSection m_PropertySection; readonly SGBlackboardSection m_KeywordSection; public const int k_PropertySectionIndex = 0; public const int k_KeywordSectionIndex = 1; const string k_styleName = "Blackboard"; public SGBlackboard blackboard { get; private set; } Label m_PathLabel; TextField m_PathLabelTextField; bool m_EditPathCancelled = false; List m_SelectedNodes = new List(); public string assetName { get { return blackboard.title; } set { blackboard.title = value; } } public BlackboardProvider(GraphData graph, GraphView associatedGraphView) { m_Graph = graph; m_InputRows = new Dictionary(); blackboard = new SGBlackboard(associatedGraphView) { subTitle = FormatPath(graph.path), addItemRequested = AddItemRequested, moveItemRequested = MoveItemRequested }; // These make sure that the drag indicators are disabled whenever a drag action is cancelled without completing a drop blackboard.RegisterCallback(evt => { m_PropertySection.OnDragActionCanceled(); m_KeywordSection.OnDragActionCanceled(); }); blackboard.RegisterCallback(evt => { m_PropertySection.OnDragActionCanceled(); m_KeywordSection.OnDragActionCanceled(); }); m_PathLabel = blackboard.hierarchy.ElementAt(0).Q