|
|
|
|
|
|
using UnityEditor.Graphing; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Experimental.UIElements; |
|
|
|
using UnityEngine.Experimental.UIElements.StyleSheets; |
|
|
|
const string k_EdgeColorProperty = "edge-color"; |
|
|
|
|
|
|
|
StyleValue<Color> m_EdgeColor; |
|
|
|
|
|
|
|
public Color edgeColor |
|
|
|
{ |
|
|
|
get { return m_EdgeColor.GetSpecifiedValueOrDefault(Color.red); } |
|
|
|
} |
|
|
|
|
|
|
|
VisualElement m_ControlContainer; |
|
|
|
VisualElement m_Container; |
|
|
|
EdgeControl m_EdgeControl; |
|
|
|
m_Slot = slot; |
|
|
|
m_Slot = slot; |
|
|
|
m_ControlContainer = new VisualElement { name = "controlContainer" }; |
|
|
|
Add(m_ControlContainer); |
|
|
|
m_Control = m_Slot.InstantiateControl(); |
|
|
|
if (m_Control != null) |
|
|
|
m_ControlContainer.Add(m_Control); |
|
|
|
else |
|
|
|
m_ControlContainer.visible = false; |
|
|
|
AddToClassList("type" + m_SlotType); |
|
|
|
|
|
|
|
m_Container = new VisualElement { name = "container" }; |
|
|
|
{ |
|
|
|
m_Control = m_Slot.InstantiateControl(); |
|
|
|
if (m_Control != null) |
|
|
|
m_Container.Add(m_Control); |
|
|
|
|
|
|
|
var slotElement = new VisualElement { name = "slot" }; |
|
|
|
{ |
|
|
|
slotElement.Add(new VisualElement { name = "dot" }); |
|
|
|
} |
|
|
|
m_Container.Add(slotElement); |
|
|
|
} |
|
|
|
Add(m_Container); |
|
|
|
|
|
|
|
m_EdgeControl = new EdgeControl |
|
|
|
{ |
|
|
|
@from = new Vector2(212f - 20f, 11.5f), |
|
|
|
to = new Vector2(212f, 11.5f), |
|
|
|
edgeWidth = 2 |
|
|
|
}; |
|
|
|
Add(m_EdgeControl); |
|
|
|
|
|
|
|
m_Container.visible = m_EdgeControl.visible = m_Control != null; |
|
|
|
|
|
|
|
clippingOptions = ClippingOptions.NoClipping; |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnStyleResolved(ICustomStyle styles) |
|
|
|
{ |
|
|
|
base.OnStyleResolved(styles); |
|
|
|
styles.ApplyCustomProperty(k_EdgeColorProperty, ref m_EdgeColor); |
|
|
|
m_EdgeControl.UpdateLayout(); |
|
|
|
m_EdgeControl.edgeColor = edgeColor; |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateSlotType() |
|
|
|
|
|
|
RemoveFromClassList("type" + m_SlotType); |
|
|
|
AddToClassList("type" + m_SlotType); |
|
|
|
m_ControlContainer.Remove(m_Control); |
|
|
|
m_Container.Remove(m_Control); |
|
|
|
m_ControlContainer.visible = true; |
|
|
|
m_ControlContainer.Add(m_Control); |
|
|
|
else |
|
|
|
m_ControlContainer.visible = false; |
|
|
|
m_Container.Insert(0, m_Control); |
|
|
|
|
|
|
|
m_Container.visible = m_EdgeControl.visible = m_Control != null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|