using System; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.UIElements.GraphView; using UnityEngine; using UnityEngine.Experimental.UIElements; using UnityEngine.Experimental.UIElements.StyleEnums; namespace UnityEditor.ShaderGraph.Drawing { class BlackboardSection : GraphElement, IDropTarget { private VisualElement m_DragIndicator; private VisualElement m_MainContainer; private VisualElement m_Header; private Label m_TitleLabel; private VisualElement m_RowsContainer; private int m_InsertIndex; int InsertionIndex(Vector2 pos) { int index = -1; VisualElement owner = contentContainer != null ? contentContainer : this; Vector2 localPos = this.ChangeCoordinatesTo(owner, pos); if (owner.ContainsPoint(localPos)) { index = 0; foreach (VisualElement child in Children()) { Rect rect = child.layout; if (localPos.y > (rect.y + rect.height / 2)) { ++index; } else { break; } } } return index; } VisualElement FindSectionDirectChild(VisualElement element) { VisualElement directChild = element; while ((directChild != null) && (directChild != this)) { if (directChild.parent == this) { return directChild; } directChild = directChild.parent; } return null; } public BlackboardSection() { var tpl = AssetDatabase.LoadAssetAtPath("Assets/UnityShaderEditor/Editor/Resources/UXML/GraphView/BlackboardSection.uxml") as VisualTreeAsset; m_MainContainer = tpl.CloneTree(null); m_MainContainer.AddToClassList("mainContainer"); m_Header = m_MainContainer.Q("sectionHeader"); m_TitleLabel = m_MainContainer.Q