|
|
|
|
|
|
Image m_Preview; |
|
|
|
|
|
|
|
AbstractMaterialGraph m_Graph; |
|
|
|
PreviewSystem m_PreviewSystem; |
|
|
|
MasterNode m_MasterNode; |
|
|
|
List<INode> m_SelectedNodes; |
|
|
|
|
|
|
|
|
|
|
|
var masterNode = graph.GetNodes<MasterNode>().FirstOrDefault(); |
|
|
|
if (masterNode != null) |
|
|
|
{ |
|
|
|
m_PreviewHandle = previewSystem.GetPreview(masterNode); |
|
|
|
m_PreviewHandle.onPreviewChanged += OnPreviewChanged; |
|
|
|
} |
|
|
|
m_PreviewSystem = previewSystem; |
|
|
|
m_SelectedNodes = new List<INode>(); |
|
|
|
|
|
|
|
AddStyleSheetPath("Styles/MaterialGraph"); |
|
|
|
|
|
|
} |
|
|
|
Add(bottomContainer); |
|
|
|
|
|
|
|
masterNode = graph.GetNodes<MasterNode>().FirstOrDefault(); |
|
|
|
|
|
|
|
foreach (var property in m_Graph.properties) |
|
|
|
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); |
|
|
|
m_Graph.onChange += OnGraphChange; |
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
List<INode> m_SelectedNodes; |
|
|
|
MasterNode masterNode |
|
|
|
{ |
|
|
|
get { return m_MasterNode; } |
|
|
|
set |
|
|
|
{ |
|
|
|
if (value == m_MasterNode) |
|
|
|
return; |
|
|
|
if (m_MasterNode != null) |
|
|
|
m_PreviewHandle.onPreviewChanged -= OnPreviewChanged; |
|
|
|
m_PreviewHandle = null; |
|
|
|
m_MasterNode = value; |
|
|
|
if (m_MasterNode != null) |
|
|
|
{ |
|
|
|
m_PreviewHandle = m_PreviewSystem.GetPreview(m_MasterNode); |
|
|
|
m_PreviewHandle.onPreviewChanged += OnPreviewChanged; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnAddProperty() |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
var propertyAdded = change as ShaderPropertyAdded; |
|
|
|
if (propertyAdded != null) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var propertyRemoved = change as ShaderPropertyRemoved; |
|
|
|
if (propertyRemoved != null) |
|
|
|
|
|
|
m_PropertyItems.Remove(propertyView); |
|
|
|
return; |
|
|
|
if (layerGraph == null) |
|
|
|
if (layerGraph != null) |
|
|
|
{ |
|
|
|
var layerAdded = change as LayerAdded; |
|
|
|
if (layerAdded != null) |
|
|
|
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer)); |
|
|
|
|
|
|
|
var layerRemoved = change as LayerRemoved; |
|
|
|
if (layerRemoved != null) |
|
|
|
{ |
|
|
|
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id); |
|
|
|
if (view != null) |
|
|
|
m_LayerItems.Remove(view); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var nodeAdded = change as NodeAddedGraphChange; |
|
|
|
if (nodeAdded != null) |
|
|
|
{ |
|
|
|
var node = nodeAdded.node as MasterNode; |
|
|
|
if (node != null && masterNode == null) |
|
|
|
masterNode = node; |
|
|
|
} |
|
|
|
var layerAdded = change as LayerAdded; |
|
|
|
if (layerAdded != null) |
|
|
|
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer)); |
|
|
|
|
|
|
|
var layerRemoved = change as LayerRemoved; |
|
|
|
if (layerRemoved != null) |
|
|
|
var nodeRemoved = change as NodeRemovedGraphChange; |
|
|
|
if (nodeRemoved != null) |
|
|
|
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id); |
|
|
|
if (view != null) |
|
|
|
m_LayerItems.Remove(view); |
|
|
|
if (nodeRemoved.node == masterNode) |
|
|
|
masterNode = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|