using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEditor.Experimental.UIElements.GraphView; using UnityEngine; using UnityEngine.Experimental.UIElements; using Debug = System.Diagnostics.Debug; namespace UnityEditor.ShaderGraph.Drawing { class BlackboardField : GraphElement { private VisualElement m_ContentItem; private Image m_Icon; private Label m_TextLabel; private TextField m_TextField; private Label m_TypeLabel; private bool m_EditTitleCancelled = false; SelectionDropper m_SelectionDropper; public string text { get { return m_TextLabel.text; } set { m_TextLabel.text = value; } } public string typeText { get { return m_TypeLabel.text; } set { m_TypeLabel.text = value; } } public Texture icon { get { return m_Icon.image; } set { m_Icon.image = value; if (value == null) { AddToClassList("noIcon"); m_Icon.visible = false; } else { RemoveFromClassList("noIcon"); m_Icon.visible = true; } } } public BlackboardField() : this(null, "", "") { } static Type s_ContextualMenuManipulator = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).FirstOrDefault(t => t.FullName == "UnityEngine.Experimental.UIElements.ContextualMenuManipulator"); public BlackboardField(Texture icon, string text, string typeText) { var tpl = AssetDatabase.LoadAssetAtPath("Assets/UnityShaderEditor/Editor/Resources/UXML/GraphView/BlackboardField.uxml"); VisualElement mainContainer = tpl.CloneTree(null); mainContainer.AddToClassList("mainContainer"); mainContainer.pickingMode = PickingMode.Ignore; m_ContentItem = mainContainer.Q("contentItem"); m_TextLabel = mainContainer.Q