|
|
|
|
|
|
|
|
|
|
void Update() |
|
|
|
{ |
|
|
|
if (graphObject == null && selectedGuid != null) |
|
|
|
{ |
|
|
|
var guid = selectedGuid; |
|
|
|
selectedGuid = null; |
|
|
|
ChangeSelection(guid); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var materialGraph = graphObject.graph as AbstractMaterialGraph; |
|
|
|
if (materialGraph == null) |
|
|
|
return; |
|
|
|
|
|
|
graphEditorView = new GraphEditorView(materialGraph, asset.name) {persistenceKey = AssetDatabase.AssetPathToGUID(AssetDatabase.GUIDToAssetPath(selectedGuid))}; |
|
|
|
graphEditorView = new GraphEditorView(materialGraph, asset.name) { persistenceKey = AssetDatabase.AssetPathToGUID(AssetDatabase.GUIDToAssetPath(selectedGuid)) }; |
|
|
|
} |
|
|
|
|
|
|
|
graphEditorView.HandleGraphChanges(); |
|
|
|
|
|
|
Mathf.Min(bounds.yMin, center.y), |
|
|
|
Mathf.Max(bounds.xMax, center.x), |
|
|
|
Mathf.Max(bounds.yMax, center.y)); |
|
|
|
|
|
|
|
} |
|
|
|
var middle = bounds.center; |
|
|
|
bounds.center = Vector2.zero; |
|
|
|
|
|
|
var uniqueIncomingEdges = externalOutputSlots.GroupBy( |
|
|
|
edge => edge.outputSlot, |
|
|
|
edge => edge, |
|
|
|
(key, edges) => new {slotRef = key, edges = edges.ToList()}); |
|
|
|
|
|
|
|
(key, edges) => new { slotRef = key, edges = edges.ToList() }); |
|
|
|
|
|
|
|
var externalInputNeedingConnection = new List<KeyValuePair<IEdge, IShaderProperty>>(); |
|
|
|
foreach (var group in uniqueIncomingEdges) |
|
|
|
|
|
|
var uniqueOutgoingEdges = externalInputSlots.GroupBy( |
|
|
|
edge => edge.inputSlot, |
|
|
|
edge => edge, |
|
|
|
(key, edges) => new {slot = key, edges = edges.ToList()}); |
|
|
|
(key, edges) => new { slot = key, edges = edges.ToList() }); |
|
|
|
|
|
|
|
var externalOutputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>(); |
|
|
|
foreach (var group in uniqueOutgoingEdges) |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void ChangeSelection(string newSelectionGuid, Type graphType) |
|
|
|
public void ChangeSelection(string newSelectionGuid) |
|
|
|
{ |
|
|
|
var asset = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(newSelectionGuid)); |
|
|
|
if (asset == null) |
|
|
|
|
|
|
if (selectedGuid == newSelectionGuid) |
|
|
|
return; |
|
|
|
|
|
|
|
var path = AssetDatabase.GetAssetPath(asset); |
|
|
|
var extension = Path.GetExtension(path); |
|
|
|
Type graphType; |
|
|
|
switch (extension) |
|
|
|
{ |
|
|
|
case ".ShaderGraph": |
|
|
|
graphType = typeof(MaterialGraph); |
|
|
|
break; |
|
|
|
case ".LayeredShaderGraph": |
|
|
|
graphType = typeof(LayeredShaderGraph); |
|
|
|
break; |
|
|
|
case ".ShaderSubGraph": |
|
|
|
graphType = typeof(SubGraph); |
|
|
|
break; |
|
|
|
case ".ShaderRemapGraph": |
|
|
|
graphType = typeof(MasterRemapGraph); |
|
|
|
break; |
|
|
|
default: |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var path = AssetDatabase.GetAssetPath(asset); |
|
|
|
var textGraph = File.ReadAllText(path, Encoding.UTF8); |
|
|
|
graphObject = CreateInstance<SerializableGraphObject>(); |
|
|
|
graphObject.hideFlags = HideFlags.HideAndDontSave; |
|
|
|