Tim Cooper
8 年前
当前提交
8e10c8cb
共有 13 个文件被更改,包括 220 次插入 和 176 次删除
-
4MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/GraphEditWindow.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/SubGraphIONodeUI.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AddNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphIONode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MaterialSubGraphAsset.cs
-
73MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
-
179MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphOutputNode.cs
-
50MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/SubGraphNodeUI.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/SubGraphNodeUI.cs.meta
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine.Graphing; |
|||
public class SubGraphInputNode : AbstractSubGraphIONode, IGenerateProperties |
|||
public class SubGraphInputNode : AbstractSubGraphIONode |
|||
/* |
|||
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
public override void AddSlot() |
|||
base.GeneratePropertyBlock(visitor, generationMode); |
|||
var index = GetOutputSlots<ISlot>().Count(); |
|||
AddSlot(new MaterialSlot("Input" + index, "Input" + index, SlotType.Output, index, SlotValueType.Vector4, Vector4.zero)); |
|||
} |
|||
if (!generationMode.IsPreview()) |
|||
public override void RemoveSlot() |
|||
{ |
|||
var index = GetOutputSlots<ISlot>().Count(); |
|||
if (index == 0) |
|||
foreach (var slot in outputSlots) |
|||
{ |
|||
if (slot.edges.Count == 0) |
|||
continue; |
|||
|
|||
var defaultValue = GetSlotDefaultValue(slot.name); |
|||
if (defaultValue != null) |
|||
defaultValue.GeneratePropertyBlock(visitor, generationMode); |
|||
} |
|||
RemoveSlot("Input" + (index - 1)); |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode, ConcreteSlotValueType slotValueType) |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode, ConcreteSlotValueType valueType) |
|||
base.GeneratePropertyUsages(visitor, generationMode, slotValueType); |
|||
|
|||
if (!generationMode.IsPreview()) |
|||
return; |
|||
|
|||
foreach (var slot in outputSlots) |
|||
foreach (var slot in GetOutputSlots<MaterialSlot>()) |
|||
if (slot.edges.Count == 0) |
|||
continue; |
|||
|
|||
var defaultValue = GetSlotDefaultValue(slot.name); |
|||
if (defaultValue != null) |
|||
defaultValue.GeneratePropertyUsages(visitor, generationMode, slotValueType); |
|||
var outDimension = ConvertConcreteSlotValueTypeToString(slot.concreteValueType); |
|||
visitor.AddShaderChunk("float" + outDimension + " " + GetOutputVariableNameForSlot(slot) + ";", true); |
|||
protected override void CollectPreviewMaterialProperties (List<PreviewProperty> properties) |
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
foreach (var slot in outputSlots) |
|||
foreach (var slot in GetOutputSlots<MaterialSlot>()) |
|||
if (slot.edges.Count == 0) |
|||
continue; |
|||
|
|||
var defaultOutput = GetSlotDefaultValue(slot.name); |
|||
if (defaultOutput == null) |
|||
continue; |
|||
|
|||
var pp = new PreviewProperty |
|||
{ |
|||
m_Name = defaultOutput.inputName, |
|||
m_PropType = PropertyType.Vector4, |
|||
m_Vector4 = defaultOutput.defaultValue |
|||
}; |
|||
properties.Add (pp); |
|||
properties.Add( |
|||
new PreviewProperty |
|||
{ |
|||
m_Name = GetOutputVariableNameForSlot(slot), |
|||
m_PropType = PropertyType.Vector4, |
|||
m_Vector4 = slot.defaultValue |
|||
} |
|||
); |
|||
}*/ |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor.Graphing; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
[CustomNodeUI(typeof(SubGraphNode))] |
|||
public class SubgraphNodeUI : ICustomNodeUi |
|||
{ |
|||
private SubGraphNode m_Node; |
|||
|
|||
public float GetNodeUiHeight(float width) |
|||
{ |
|||
return 1 * EditorGUIUtility.singleLineHeight; |
|||
} |
|||
|
|||
public GUIModificationType Render(Rect area) |
|||
{ |
|||
if (m_Node == null) |
|||
return GUIModificationType.None; |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
m_Node.subGraphAsset = (MaterialSubGraphAsset) EditorGUI.ObjectField(new Rect(area.x, area.y, area.width, EditorGUIUtility.singleLineHeight), |
|||
new GUIContent("SubGraph"), |
|||
m_Node.subGraphAsset, |
|||
typeof(MaterialSubGraphAsset), false); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
m_Node.UpdateNodeAfterDeserialization(); |
|||
return GUIModificationType.ModelChanged; |
|||
} |
|||
|
|||
return GUIModificationType.None; |
|||
} |
|||
|
|||
public void SetNode(INode node) |
|||
{ |
|||
if (node is SubGraphNode) |
|||
m_Node = (SubGraphNode) node; |
|||
} |
|||
|
|||
public float GetNodeWidth() |
|||
{ |
|||
return 200; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 311840105ab3e5c48859be33dab6b33e |
|||
timeCreated: 1468327292 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue