浏览代码

[shader graph]Renable delete. Fix guids so shaders generate properly.

/main
Tim Cooper 9 年前
当前提交
159a13a8
共有 6 个文件被更改,包括 21 次插入30 次删除
  1. 13
      UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs
  2. 29
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs
  3. 1
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeAnchor.cs
  4. 4
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs
  5. 2
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PixelShaderNode.cs
  6. 2
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PropertyNode.cs

13
UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs


return;
m_Nodes.Remove(node);
RevalidateGraph();
}
public void RemoveNodeNoRevalidate(BaseMaterialNode node)
{
if (!node.canDeleteNode)
return;
m_Nodes.Remove(node);
}
public BaseMaterialNode GetNodeFromGUID(Guid guid)

public IEnumerable<Edge> GetEdges(Slot s)
{
return m_Edges.Where(x =>
(x.outputSlot.nodeGuid == s.nodeGuid && x.outputSlot.slotName == s.name)
|| x.inputSlot.nodeGuid == s.nodeGuid && x.inputSlot.slotName == s.name);
(x.outputSlot.nodeGuid == s.owner.guid && x.outputSlot.slotName == s.name)
|| x.inputSlot.nodeGuid == s.owner.guid && x.inputSlot.slotName == s.name);
}
public Edge Connect(Slot fromSlot, Slot toSlot)

29
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs


public void DeleteElements(List<CanvasElement> elements)
{
// delete selected edges first
/* foreach (var e in elements.Where(x => x is Edge<NodeAnchor>))
foreach (var e in elements.Where(x => x is Edge<NodeAnchor>))
var edge = graph.currentGraph.edges.FirstOrDefault(x => x.fromSlot == localEdge.Left.m_Slot && x.toSlot == localEdge.Right.m_Slot);
var edge = graph.currentGraph.edges.FirstOrDefault(x => graph.currentGraph.GetNodeFromGUID(x.outputSlot.nodeGuid).FindOutputSlot(x.outputSlot.slotName) == localEdge.Left.m_Slot
&& graph.currentGraph.GetNodeFromGUID(x.inputSlot.nodeGuid).FindInputSlot(x.inputSlot.slotName) == localEdge.Right.m_Slot);
// now delete edges that the selected nodes use
// now delete the nodes
foreach (var e in elements.Where(x => x is DrawableMaterialNode))
{
var node = ((DrawableMaterialNode) e).m_Node;

foreach (var slot in node.slots)
{
for (int index = slot.edges.Count -1; index >= 0; --index)
{
var edge = slot.edges[index];
Debug.Log("Deleting edge " + edge);
graph.currentGraph.RemoveEdgeNoRevalidate(edge);
}
}
}
// now delete the nodes
foreach (var e in elements.Where(x => x is DrawableMaterialNode))
{
var node = ((DrawableMaterialNode)e).m_Node;
if (!node.canDeleteNode)
continue;
graph.currentGraph.RemoveNode(node);
graph.currentGraph.RemoveNodeNoRevalidate(node);
graph.currentGraph.RevalidateGraph();*/
graph.currentGraph.RevalidateGraph();
}
public void Connect(NodeAnchor a, NodeAnchor b)

1
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeAnchor.cs


using System;
using UnityEditor.Experimental;
using UnityEditor.Experimental.Graph;
using UnityEditor.Graphs;
using UnityEngine;
namespace UnityEditor.MaterialGraph

4
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs


protected bool InternalUpdatePreviewShader(string resultShader)
{
MaterialWindow.DebugMaterialGraph("RecreateShaderAndMaterial : " + name + "_" + guid + "\n" + resultShader);
MaterialWindow.DebugMaterialGraph("RecreateShaderAndMaterial : " + name + "_" + guid.ToString().Replace("-","_") + "\n" + resultShader);
// workaround for some internal shader compiler weirdness
// if we are in error we sometimes to not properly clean

public virtual string GetOutputVariableNameForNode()
{
return name + "_" + guid;
return name + "_" + guid.ToString().Replace("-", "_");
}
public virtual Vector4 GetNewSlotDefaultValue(SlotValueType type)

2
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PixelShaderNode.cs


if (hasError)
return false;
var shaderName = "Hidden/PreviewShader/" + name + "_" + guid;
var shaderName = "Hidden/PreviewShader/" + name + "_" + guid.ToString().Replace("-","_");
List<PropertyGenerator.TextureInfo> defaultTextures;
var resultShader = ShaderGenerator.GenerateSurfaceShader(owner.owner, shaderName, true, out defaultTextures);
m_GeneratedShaderMode = PreviewMode.Preview3D;

2
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PropertyNode.cs


get
{
if (!exposed || string.IsNullOrEmpty(m_PropertyName))
return string.Format("{0}_{1}_Uniform", name, guid);
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-","_"));
return m_PropertyName + "_Uniform";
}

正在加载...
取消
保存