|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEditor.Experimental.UIElements.GraphView; |
|
|
|
using UnityEditor.Graphing.Drawing; |
|
|
|
using UnityEngine.Graphing; |
|
|
|
using UnityEngine.MaterialGraph; |
|
|
|
|
|
|
namespace UnityEditor.MaterialGraph.Drawing |
|
|
|
{ |
|
|
|
public class MaterialNodeDrawer : NodeDrawer |
|
|
|
public class MaterialNodeDrawer : Node |
|
|
|
VisualContainer m_ControlsContainer; |
|
|
|
List<GraphControlPresenter> m_CurrentControlPresenter; |
|
|
|
Image m_PreviewImage; |
|
|
|
NodePreviewPresenter m_currentPreviewData; |
|
|
|
bool m_IsScheduled; |
|
|
|
|
|
|
onLeave += UnschedulePolling; |
|
|
|
} |
|
|
|
|
|
|
|
private void CreateContainers() |
|
|
|
void CreateContainers() |
|
|
|
m_ControlsContainer = new VisualContainer |
|
|
|
{ |
|
|
|
name = "controls" |
|
|
|
}; |
|
|
|
leftContainer.Add(m_ControlsContainer); |
|
|
|
m_CurrentControlPresenter = new List<GraphControlPresenter>(); |
|
|
|
|
|
|
|
m_PreviewImage = new Image |
|
|
|
{ |
|
|
|
name = "preview", // for USS&Flexbox
|
|
|
|
|
|
|
leftContainer.Add(m_PreviewImage); |
|
|
|
} |
|
|
|
|
|
|
|
private void SchedulePolling() |
|
|
|
void SchedulePolling() |
|
|
|
{ |
|
|
|
if (panel != null) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void UnschedulePolling() |
|
|
|
void UnschedulePolling() |
|
|
|
{ |
|
|
|
if (m_IsScheduled && panel != null) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void InvalidateUIIfNeedsTime(TimerState timerState) |
|
|
|
void InvalidateUIIfNeedsTime(TimerState timerState) |
|
|
|
{ |
|
|
|
var data = GetPresenter<MaterialNodePresenter>(); |
|
|
|
var childrenNodes = ListPool<INode>.Get(); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UpdateControls(MaterialNodePresenter nodeData) |
|
|
|
{ |
|
|
|
var controlPresenters = nodeData.elements.OfType<GraphControlPresenter>().ToList(); |
|
|
|
|
|
|
|
m_ControlsContainer.ClearChildren(); |
|
|
|
m_CurrentControlPresenter.Clear(); |
|
|
|
|
|
|
|
if (!nodeData.expanded) |
|
|
|
return; |
|
|
|
|
|
|
|
foreach (var controlData in controlPresenters) |
|
|
|
{ |
|
|
|
m_ControlsContainer.AddChild(CreateControl(controlData)); |
|
|
|
m_CurrentControlPresenter.Add(controlData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
IMGUIContainer CreateControl(GraphControlPresenter controlPresenter) |
|
|
|
{ |
|
|
|
return new IMGUIContainer(controlPresenter.OnGUIHandler) |
|
|
|
{ |
|
|
|
name = "element", |
|
|
|
executionContext = controlPresenter.GetInstanceID(), |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ControlsContainer.Clear(); |
|
|
|
m_CurrentControlPresenter.Clear(); |
|
|
|
m_PreviewImage.AddToClassList("inactive"); |
|
|
|
m_currentPreviewData = null; |
|
|
|
UpdatePreviewTexture(m_currentPreviewData); |
|
|
|
|
|
|
UpdateControls(nodeData); |
|
|
|
|
|
|
|
m_currentPreviewData = nodeData.elements.OfType<NodePreviewPresenter>().FirstOrDefault(); |
|
|
|
UpdatePreviewTexture(m_currentPreviewData); |
|
|
|
|
|
|
|
|
|
|
m_PreviewImage.AddToClassList("hidden"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |