|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using UnityEditor.Experimental.UIElements; |
|
|
|
using UnityEditor.Graphing.Util; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Experimental.UIElements; |
|
|
|
|
|
|
} |
|
|
|
bottomContainer.Add(propertiesContainer); |
|
|
|
|
|
|
|
//if (m_Presenter.graph is LayeredShaderGraph)
|
|
|
|
if (m_Graph is LayeredShaderGraph) |
|
|
|
{ |
|
|
|
var layersContainer = new VisualElement {name = "properties"}; |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
foreach (var property in m_Graph.properties) |
|
|
|
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); |
|
|
|
m_Graph.onChange += OnGraphChange; |
|
|
|
|
|
|
|
var layerGraph = m_Graph as LayeredShaderGraph; |
|
|
|
if (layerGraph != null) |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnGraphChange(GraphChange change) |
|
|
|
public void HandleGraphChanges() |
|
|
|
var propertyAdded = change as ShaderPropertyAdded; |
|
|
|
if (propertyAdded != null) |
|
|
|
foreach (var propertyGuid in m_Graph.removedProperties) |
|
|
|
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, propertyAdded.shaderProperty)); |
|
|
|
return; |
|
|
|
var propertyView = m_PropertyItems.OfType<ShaderPropertyView>().FirstOrDefault(v => v.property.guid == propertyGuid);if (propertyView != null) |
|
|
|
m_PropertyItems.Remove(propertyView); |
|
|
|
var propertyRemoved = change as ShaderPropertyRemoved; |
|
|
|
if (propertyRemoved != null) |
|
|
|
{ |
|
|
|
var propertyView = m_PropertyItems.OfType<ShaderPropertyView>().FirstOrDefault(v => v.property.guid == propertyRemoved.guid); |
|
|
|
if (propertyView != null) |
|
|
|
m_PropertyItems.Remove(propertyView); |
|
|
|
return; |
|
|
|
} |
|
|
|
foreach (var property in m_Graph.addedProperties) |
|
|
|
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); |
|
|
|
var layerAdded = change as LayerAdded; |
|
|
|
if (layerAdded != null) |
|
|
|
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer)); |
|
|
|
|
|
|
|
var layerRemoved = change as LayerRemoved; |
|
|
|
if (layerRemoved != null) |
|
|
|
foreach (var id in layerGraph.removedLayers) |
|
|
|
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id); |
|
|
|
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == id); |
|
|
|
|
|
|
|
foreach (var layer in layerGraph.addedLayers) |
|
|
|
m_LayerItems.Add(new ShaderLayerView(layerGraph, layer)); |
|
|
|
var nodeAdded = change as NodeAddedGraphChange; |
|
|
|
if (nodeAdded != null) |
|
|
|
if (masterNode != null) |
|
|
|
var node = nodeAdded.node as MasterNode; |
|
|
|
if (node != null && masterNode == null) |
|
|
|
masterNode = node; |
|
|
|
return; |
|
|
|
if (m_Graph.removedNodes.Contains(masterNode)) |
|
|
|
masterNode = null; |
|
|
|
var nodeRemoved = change as NodeRemovedGraphChange; |
|
|
|
if (nodeRemoved != null) |
|
|
|
if (masterNode == null) |
|
|
|
if (nodeRemoved.node == masterNode) |
|
|
|
masterNode = null; |
|
|
|
return; |
|
|
|
var addedMasterNode = m_Graph.addedNodes.OfType<MasterNode>().FirstOrDefault(); |
|
|
|
if (addedMasterNode != null) |
|
|
|
masterNode = addedMasterNode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|