浏览代码

Merging master.

/main
damian 7 年前
当前提交
83548475
共有 118 个文件被更改,包括 1501 次插入788 次删除
  1. 32
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  2. 115
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  3. 118
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
  4. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
  5. 3
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs
  6. 3
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs
  7. 223
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/GradientNode.cs
  8. 2
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/ConstantsNode.cs
  9. 5
      MaterialGraphProject/Assets/NewNodes/Editor/Keep/BlendModeNode.cs
  10. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs
  11. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphNode.cs
  12. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs.meta
  13. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs
  14. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphNode.cs.meta
  15. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraph.cs.meta
  16. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorRejectionNode.cs
  17. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorProjectionNode.cs
  18. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyNode.cs
  19. 22
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PreviewNode.cs
  20. 261
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Logic/IFNode.cs
  21. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector4Node.cs
  22. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector3Node.cs
  23. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector2Node.cs
  24. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector1Node.cs
  25. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
  26. 62
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs
  27. 56
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
  28. 46
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs
  29. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs
  30. 28
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/ColorNode.cs
  31. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/AbstractLightweightMasterNode.cs.meta
  32. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/NeededCoordinateSpace.cs.meta
  33. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/VectorShaderProperty.cs.meta
  34. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector4ShaderProperty.cs.meta
  35. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector3ShaderProperty.cs.meta
  36. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector2ShaderProperty.cs.meta
  37. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureShaderProperty.cs.meta
  38. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureSamplerState.cs.meta
  39. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ShaderGraphRequirements.cs.meta
  40. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableTexture.cs.meta
  41. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerStateShaderProperty.cs.meta
  42. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderProperty.cs.meta
  43. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/FloatShaderProperty.cs.meta
  44. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ColorShaderProperty.cs.meta
  45. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractShaderProperty.cs.meta
  46. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/StackPool.cs.meta
  47. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/SerializationHelper.cs
  48. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/QueuePool.cs.meta
  49. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs
  50. 1
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraph.cs
  51. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/GraphChange.cs.meta
  52. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data.meta
  53. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls.meta
  54. 61
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Draggable.cs
  55. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Draggable.cs.meta
  56. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/Gradient.ShaderGraph
  57. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/Gradient.ShaderGraph.meta
  58. 8
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs
  59. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs.meta
  60. 65
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs
  61. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs.meta
  62. 53
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
  63. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs.meta
  64. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs.meta
  65. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IControlAttribute.cs
  66. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IControlAttribute.cs.meta
  67. 165
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/VectorControl.cs
  68. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/VectorControl.cs.meta
  69. 52
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs
  70. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs.meta
  71. 44
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs
  72. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs.meta
  73. 89
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/GradientControl.cs
  74. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/GradientControl.cs.meta
  75. 53
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ObjectControl.cs
  76. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ObjectControl.cs.meta
  77. 29
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs
  78. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime.meta
  79. 12
      MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs.meta
  80. 12
      MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs.meta
  81. 12
      MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs.meta
  82. 12
      MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs.meta
  83. 45
      MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs
  84. 56
      MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs
  85. 62
      MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs
  86. 53
      MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs
  87. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs.meta
  88. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta
  89. 48
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs
  90. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime.meta
  91. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Keep.meta
  92. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/Kill.meta
  93. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/ChannelBlendNode.cs
  94. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/ChannelBlendNode.cs.meta
  95. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs
  96. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs.meta
  97. 0
      /MaterialGraphProject/Assets/NewNodes/Editor/ConstantType.cs

32
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


{
public override AbstractMaterialGraph GetMaterialGraph()
{
return inMemoryAsset;
return inMemoryAsset.graph as AbstractMaterialGraph;
}
}

{
return inMemoryAsset;
return inMemoryAsset.graph as AbstractMaterialGraph;
}
}

{
return inMemoryAsset;
return inMemoryAsset.graph as AbstractMaterialGraph;
}
}

Object m_Selected;
[SerializeField]
TGraphType m_InMemoryAsset;
SerializableGraphObject m_InMemoryAsset;
GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView

}
}
protected TGraphType inMemoryAsset
protected SerializableGraphObject inMemoryAsset
set { m_InMemoryAsset = value; }
set
{
if (m_InMemoryAsset != null)
DestroyImmediate(m_InMemoryAsset);
m_InMemoryAsset = value;
}
}
public override Object selected

void Update()
{
if (graphEditorView == null || graphEditorView.graphPresenter == null)
graphEditorView = new GraphEditorView(inMemoryAsset, this, selected.name);
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name);
if (graphEditorView != null)
graphEditorView.previewSystem.Update();
}

{
UpdateAsset();
}
DestroyImmediate(inMemoryAsset);
graphEditorView = null;
}

private void UpdateShaderGraphOnDisk(string path)
{
var graph = inMemoryAsset as UnityEngine.MaterialGraph.MaterialGraph;
var graph = inMemoryAsset.graph as UnityEngine.MaterialGraph.MaterialGraph;
if (graph == null)
return;

AssetDatabase.ImportAsset(path);
}
public override void ChangeSelection(Object newSelection)
{
if (!EditorUtility.IsPersistent(newSelection))

var path = AssetDatabase.GetAssetPath(newSelection);
var textGraph = File.ReadAllText(path, Encoding.UTF8);
inMemoryAsset = JsonUtility.FromJson<TGraphType>(textGraph);
inMemoryAsset.OnEnable();
inMemoryAsset.ValidateGraph();
inMemoryAsset = CreateInstance<SerializableGraphObject>();
inMemoryAsset.graph = JsonUtility.FromJson<TGraphType>(textGraph);
inMemoryAsset.graph.OnEnable();
inMemoryAsset.graph.ValidateGraph();
graphEditorView = new GraphEditorView(inMemoryAsset, this, selected.name);
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name);
titleContent = new GUIContent(selected.name);
Repaint();

115
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


namespace UnityEditor.MaterialGraph.Drawing
{
public class MaterialGraphObject : ScriptableObject
{
[SerializeField]
public string serializedGraph;
[SerializeField]
public int version;
}
GraphTypeMapper typeMapper { get; set; }
[SerializeField]
IMaterialGraphEditWindow m_Container;
[SerializeField]
MaterialGraphObject m_GraphObject;
[SerializeField]
int m_GraphVersion;
typeMapper = new GraphTypeMapper(typeof(MaterialNodeView));
typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodeView);
typeMapper[typeof(ColorNode)] = typeof(ColorNodeView);
typeMapper[typeof(GradientNode)] = typeof(GradientNodeView);
// typeMapper[typeof(ScatterNode)] = typeof(ScatterNodeView);
//typeMapper[typeof(TextureNode)] = typeof(TextureNodeView);
//typeMapper[typeof(SamplerAssetNode)] = typeof(SamplerAssetNodeView);
//typeMapper[typeof(TextureSamplerNode)] = typeof(TextureSamplerNodeView);
// typeMapper[typeof(Texture2DNode)] = typeof(TextureAssetNodeView);
// typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodeView);
typeMapper[typeof(SamplerStateNode)] = typeof(SamplerStateNodeView);
// typeMapper[typeof(CubemapNode)] = typeof(CubeNodeView);
// typeMapper[typeof(ToggleNode)] = typeof(ToggleNodeView);
typeMapper[typeof(UVNode)] = typeof(UVNodeView);
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodeView);
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodeView);
typeMapper[typeof(Vector3Node)] = typeof(Vector3NodeView);
typeMapper[typeof(Vector4Node)] = typeof(Vector4NodeView);
typeMapper[typeof(PropertyNode)] = typeof(PropertyNodeView);
/* typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView
typeMapper[typeof(AACheckerboard3dNode)] = typeof(AnyNodeView); // anything derived from AnyNode should use the AnyNodeView*/
typeMapper[typeof(SubGraphNode)] = typeof(SubgraphNodeView);
typeMapper[typeof(MasterRemapNode)] = typeof(MasterRemapNodeView);
// typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodeView);
typeMapper[typeof(AbstractSubGraphIONode)] = typeof(SubgraphIONodeView);
// typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterNodeView);
typeMapper[typeof(LevelsNode)] = typeof(LevelsNodeView);
typeMapper[typeof(ConstantsNode)] = typeof(ConstantsNodeView);
//typeMapper[typeof(SwizzleNode)] = typeof(SwizzleNodeView);
typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodeView);
// typeMapper[typeof(AddManyNode)] = typeof(AddManyNodeView);
typeMapper[typeof(IfNode)] = typeof(IfNodeView);
//typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodeView);
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodeView);
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodeView);
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodeView);
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodeView);
typeMapper[typeof(TransformNode)] = typeof(TransformNodeView);
// typeMapper[typeof(ConvolutionFilterNode)] = typeof(ConvolutionFilterNodeView);
}
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)

m_PreviewSystem = previewSystem;
this.graph = graph;
m_Container = container;
if (graph == null)
return;

EdgeAdded(new EdgeAddedGraphChange(edge));
this.graph.onChange += OnChange;
m_GraphObject = CreateInstance<MaterialGraphObject>();
Undo.undoRedoPerformed += UndoRedoPerformed;
RecordState();
}
void UndoRedoPerformed()
{
if (m_GraphObject.version != m_GraphVersion)
{
var targetGraph = JsonUtility.FromJson(m_GraphObject.serializedGraph, graph.GetType()) as IGraph;
graph.ReplaceWith(targetGraph);
m_GraphVersion = m_GraphObject.version;
}
}
void RecordState()
{
m_GraphObject.serializedGraph = JsonUtility.ToJson(graph, false);
m_GraphObject.version++;
m_GraphVersion = m_GraphObject.version;
}
void OnChange(GraphChange change)

public void AddNode(INode node)
{
Undo.RecordObject(m_GraphObject, "Add " + node.name);
graph.owner.RegisterCompleteObjectUndo("Add " + node.name);
RecordState();
}
public void RemoveElements(IEnumerable<MaterialNodeView> nodes, IEnumerable<Edge> edges)

{
if (left != null && right != null)
{
Undo.RecordObject(m_GraphObject, "Connect Edge");
graph.owner.RegisterCompleteObjectUndo("Connect Edge");
RecordState();
}
}

public void Cut()
{
Copy();
Undo.RecordObject(m_GraphObject, "Cut");
graph.owner.RegisterCompleteObjectUndo("Cut");
RecordState();
}
public bool canPaste

public void Paste()
{
var pastedGraph = DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer);
Undo.RecordObject(m_GraphObject, "Paste");
graph.owner.RegisterCompleteObjectUndo("Paste");
RecordState();
}
public bool canDuplicate

public void Duplicate()
{
var graph = DeserializeCopyBuffer(JsonUtility.ToJson(CreateCopyPasteGraph(m_GraphView.selection.OfType<GraphElement>()), true));
Undo.RecordObject(m_GraphObject, "Duplicate");
InsertCopyPasteGraph(graph);
RecordState();
var deserializedGraph = DeserializeCopyBuffer(JsonUtility.ToJson(CreateCopyPasteGraph(m_GraphView.selection.OfType<GraphElement>()), true));
graph.owner.RegisterCompleteObjectUndo("Duplicate");
InsertCopyPasteGraph(deserializedGraph);
}
public bool canDelete

public void Delete()
{
RecordState();
Undo.RecordObject(m_GraphObject, "Delete");
graph.owner.RegisterCompleteObjectUndo("Delete");
RecordState();
}
public override void AddElement(EdgePresenter edge)

118
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor.MaterialGraph.Drawing.Controls;
<<<<<<< HEAD
=======
using UnityEngine.Experimental.UIElements.StyleSheets;
>>>>>>> master
namespace UnityEditor.MaterialGraph.Drawing
{

////////////////////////////////////////////////////////////////////////////////////
VisualElement m_ControlsContainer;
List<GraphControlPresenter> m_CurrentControls;
List<VisualElement> m_ControlViews;
Guid m_NodeGuid;
VisualElement m_ResizeHandle;
bool m_ResizeHandleAdded;
public MaterialNodeView()
{

name = "controls"
};
leftContainer.Add(m_ControlsContainer);
m_CurrentControls = new List<GraphControlPresenter>();
m_ControlViews = new List<VisualElement>();
m_PreviewToggle = new VisualElement { name = "toggle", text = "" };
m_PreviewToggle.AddManipulator(new Clickable(OnPreviewToggle));

pickingMode = PickingMode.Ignore,
image = Texture2D.whiteTexture
};
m_ResizeHandleAdded = false;
}
void OnResize(Vector2 deltaSize)
{
float updatedWidth = Mathf.Min(leftContainer.layout.width + deltaSize.x, 1000f);
float updatedHeight = m_PreviewImage.layout.height + deltaSize.y;
PreviewNode previewNode = GetPresenter<MaterialNodePresenter>().node as PreviewNode;
if (previewNode != null)
{
previewNode.SetDimensions(updatedWidth, updatedHeight);
UpdateSize();
}
}
void OnPreviewToggle()

void UpdateControls()
{
if (controls.SequenceEqual(m_CurrentControls) && expanded)
return;
if (!node.guid.Equals(m_NodeGuid))
{
m_ControlViews.Clear();
foreach (var propertyInfo in node.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
foreach (IControlAttribute attribute in propertyInfo.GetCustomAttributes(typeof(IControlAttribute), false))
m_ControlViews.Add(attribute.InstantiateControl(node, propertyInfo));
}
}
if (!nodePresenter.expanded)
{
m_CurrentControls.Clear();
Dirty(ChangeType.Layout);
}
else if (m_ControlsContainer.childCount != m_ControlViews.Count)
{
m_ControlsContainer.Clear();
foreach (var view in m_ControlViews)
m_ControlsContainer.Add(view);
}
}
if (!expanded)
/*
public override void SetPosition(Rect newPos)
{
var nodePresenter = GetPresenter<MaterialNodePresenter>();
if (nodePresenter != null)
nodePresenter.position = newPos;
base.SetPosition(newPos);
}
public override void OnDataChanged()
{
base.OnDataChanged();
var nodePresenter = GetPresenter<MaterialNodePresenter>();
if (nodePresenter == null)
{
m_ControlsContainer.Clear();
m_ControlViews.Clear();
UpdatePreviewTexture(null);
}
foreach (var controlData in controls)
m_PreviewToggle.text = nodePresenter.node.previewExpanded ? "▲" : "▼";
if (nodePresenter.node.hasPreview)
m_PreviewToggle.RemoveFromClassList("inactive");
else
m_PreviewToggle.AddToClassList("inactive");
UpdateControls(nodePresenter);
UpdatePreviewTexture(nodePresenter.node.previewExpanded ? nodePresenter.previewTexture : null);
m_NodeGuid = nodePresenter.node.guid;
if (GetPresenter<MaterialNodePresenter>().node is PreviewNode)
m_ControlsContainer.Add(new IMGUIContainer(controlData.OnGUIHandler)
if (!m_ResizeHandleAdded)
name = "element"
});
m_CurrentControls.Add(controlData);
m_ResizeHandle = new VisualElement() { name = "resize", text = "" };
m_ResizeHandle.AddManipulator(new Draggable(OnResize));
Add(m_ResizeHandle);
m_ResizeHandleAdded = true;
}
UpdateSize();
}
}
*/
void UpdateSize()
{
var previewNode = node as PreviewNode;
if (previewNode == null)
{
return;
float width = previewNode.width;
float height = previewNode.height;
leftContainer.style.width = width;
m_PreviewImage.style.height = height;
}
}
}

17
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


background-color: rgba(0, 0, 0, 0.66);
}
MaterialNodeView > #resize {
background-color: rgb(0, 0, 255);
position-type: absolute;
position-right: 5;
position-bottom: 5;
width: 10;
height: 10;
}
MaterialNodeView > #resize:hover {
background-color: rgb(0, 127, 127);
}
MaterialNodeView > #resize:active {
background-color: rgb(0, 225, 25);
}
GridBackground {
grid-background-color: rgb(20, 21, 21);
line-color: rgb(20, 21, 21);

3
MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs


using UnityEngine.Graphing;
using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
namespace UnityEngine.MaterialGraph
{

private const string kInputSlotName = "Input";
private const string kOutputSlotName = "Output";
[EnumControl("From")]
public SimpleMatrixType spaceFrom
{
get { return m_spaceListFrom; }

get { return false; }
}
[EnumControl("To")]
public SimpleMatrixType spaceTo
{
get { return m_spaceListTo; }

3
MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs


using System;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

[SerializeField]
private TextureSamplerState.FilterMode m_filter = TextureSamplerState.FilterMode.Linear;
[EnumControl]
public TextureSamplerState.FilterMode filter
{
get { return m_filter; }

[SerializeField]
private TextureSamplerState.WrapMode m_wrap = TextureSamplerState.WrapMode.Repeat;
[EnumControl]
public TextureSamplerState.WrapMode wrap
{
get { return m_wrap; }

223
MaterialGraphProject/Assets/NewNodes/Editor/Keep/GradientNode.cs


using System.Reflection;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.MaterialGraph.Drawing.Controls;
public class GradientNode : CodeFunctionNode
public class GradientNode : AbstractMaterialNode, IGeneratesBodyCode
Gradient m_Gradient;
private Gradient m_gradient;
Vector4[] m_SerializableColorKeys = { new Vector4(1f, 1f, 1f, 0f), new Vector4(0f, 0f, 0f, 1f), };
[SerializeField]
Vector2[] m_SerializableAlphaKeys = { new Vector2(1f, 0f), new Vector2(1f, 1f) };
[GradientControl("")]
get { return m_gradient; }
get
{
return m_Gradient;
}
if (m_gradient == value)
return;
var scope = ModificationScope.Nothing;
m_gradient = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
var currentColorKeys = m_Gradient.colorKeys;
var currentAlphaKeys = m_Gradient.alphaKeys;
var newColorKeys = value.colorKeys;
var newAlphaKeys = value.alphaKeys;
if (currentColorKeys.Length != newColorKeys.Length || currentAlphaKeys.Length != newAlphaKeys.Length)
{
scope = scope < ModificationScope.Graph ? ModificationScope.Graph : scope;
}
else
{
for (var i = 0; i < currentColorKeys.Length; i++)
{
if (currentColorKeys[i].color != newColorKeys[i].color || Math.Abs(currentColorKeys[i].time - newColorKeys[i].time) > 1e-9)
scope = scope < ModificationScope.Node ? ModificationScope.Node : scope;
}
for (var i = 0; i < currentAlphaKeys.Length; i++)
{
if (Math.Abs(currentAlphaKeys[i].alpha - newAlphaKeys[i].alpha) > 1e-9 || Math.Abs(currentAlphaKeys[i].time - newAlphaKeys[i].time) > 1e-9)
scope = scope < ModificationScope.Node ? ModificationScope.Node : scope;
}
}
if (scope > ModificationScope.Nothing)
{
gradient.SetKeys(newColorKeys, newAlphaKeys);
if (onModified != null)
onModified(this, scope);
}
public void UpdateGradient()
{
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
public const int TimeInputSlotId = 0;
const string k_TimeInputSlotName = "Time";
// Debug.Log("UPDATED GRAPH");
}
public const int RGBAOutputSlotId = 1;
const string k_RGBAOutputSlotName = "RGBA";
public const int ROutputSlotId = 2;
const string k_ROutputSlotName = "R";
public const int GOutputSlotId = 3;
const string k_GOutputSlotName = "G";
public const int BOutputSlotId = 4;
const string k_BOutputSlotName = "B";
public const int AOutputSlotId = 5;
const string k_AOutputSlotName = "A";
UpdateNodeAfterDeserialization();
protected override MethodInfo GetFunctionToConvert()
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(TimeInputSlotId, k_TimeInputSlotName, k_TimeInputSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(RGBAOutputSlotId, k_RGBAOutputSlotName, k_RGBAOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
AddSlot(new MaterialSlot(ROutputSlotId, k_ROutputSlotName, k_ROutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(GOutputSlotId, k_GOutputSlotName, k_GOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(BOutputSlotId, k_BOutputSlotName, k_BOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AOutputSlotId, k_AOutputSlotName, k_AOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { TimeInputSlotId, RGBAOutputSlotId, ROutputSlotId, GOutputSlotId, BOutputSlotId, AOutputSlotId });
m_Gradient = new Gradient();
var colorKeys = m_SerializableColorKeys.Select(k => new GradientColorKey(new Color(k.x, k.y, k.z, 1f), k.w)).ToArray();
var alphaKeys = m_SerializableAlphaKeys.Select(k => new GradientAlphaKey(k.x, k.y)).ToArray();
m_Gradient.SetKeys(colorKeys, alphaKeys);
}
public override void OnBeforeSerialize()
{
base.OnBeforeSerialize();
m_SerializableColorKeys = gradient.colorKeys.Select(k => new Vector4(k.color.r, k.color.g, k.color.b, k.time)).ToArray();
m_SerializableAlphaKeys = gradient.alphaKeys.Select(k => new Vector2(k.alpha, k.time)).ToArray();
}
string GetColorKeyName(int index)
{
return string.Format("{0}_ck{1}", GetVariableNameForNode(), index);
}
string GetAlphaKeyName(int index)
return GetType().GetMethod("Unity_Gradient", BindingFlags.NonPublic | BindingFlags.Instance);
return string.Format("{0}_ak{1}", GetVariableNameForNode(), index);
string Unity_Gradient(
[Slot(0, Binding.None)] Vector1 value,
[Slot(1, Binding.None)] out Vector4 result)
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
result = Vector4.zero;
base.CollectShaderProperties(properties, generationMode);
var colorKeys = m_Gradient.colorKeys;
var alphaKeys = m_Gradient.alphaKeys;
GradientColorKey[] colorkeys = m_gradient.colorKeys;
GradientAlphaKey[] alphakeys = m_gradient.alphaKeys;
for (var i = 0; i < colorKeys.Length; i++)
{
var colorKey = colorKeys[i];
properties.AddShaderProperty(new Vector4ShaderProperty
{
overrideReferenceName = GetColorKeyName(i),
generatePropertyBlock = false,
value = new Vector4(colorKey.color.r, colorKey.color.g, colorKey.color.b, colorKey.time)
});
}
//Start
StringBuilder outputString = new StringBuilder();
string start = @"
{
";
outputString.Append(start);
//Color
Color c;
float cp;
for (int i = 0; i < colorkeys.Length; i++)
for (var i = 0; i < alphaKeys.Length; i++)
c = colorkeys[i].color;
cp = colorkeys[i].time;
outputString.AppendLine(string.Format("\t{{precision}}3 color{0}=float3({1},{2},{3});", i, c.r, c.g, c.b));
outputString.AppendLine(string.Format("\t{{precision}} colorp{0}={1};", i, cp));
properties.AddShaderProperty(new Vector2ShaderProperty
{
overrideReferenceName = GetAlphaKeyName(i),
generatePropertyBlock = false,
value = new Vector2(alphaKeys[i].alpha, alphaKeys[i].time)
});
}
outputString.AppendLine("\t{precision}3 gradcolor = color0;");
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
base.CollectPreviewMaterialProperties(properties);
for (int i = 0; i < colorkeys.Length - 1; i++)
var colorKeys = m_Gradient.colorKeys;
var alphaKeys = m_Gradient.alphaKeys;
for (var i = 0; i < colorKeys.Length; i++)
int j = i + 1;
outputString.AppendLine(string.Format("\t{{precision}} colorLerpPosition{0}=smoothstep(colorp{0},colorp{1},value);", i, j));
outputString.AppendLine(string.Format("\tgradcolor = lerp(gradcolor,color{0},colorLerpPosition{1});", j, i));
var colorKey = colorKeys[i];
properties.Add(new PreviewProperty()
{
m_Name = GetColorKeyName(i),
m_PropType = PropertyType.Vector4,
m_Vector4 = new Vector4(colorKey.color.r, colorKey.color.g, colorKey.color.b, colorKey.time)
});
//Alpha
float a;
float ap;
for (int i = 0; i < alphakeys.Length; i++)
for (var i = 0; i < alphaKeys.Length; i++)
a = alphakeys[i].alpha;
ap = alphakeys[i].time;
outputString.AppendLine(string.Format("\t{{precision}} alpha{0}={1};", i, a));
outputString.AppendLine(string.Format("\t{{precision}} alphap{0}={1};", i, ap));
properties.Add(new PreviewProperty
{
m_Name = GetAlphaKeyName(i),
m_PropType = PropertyType.Vector2,
m_Vector4 = new Vector2(alphaKeys[i].alpha, alphaKeys[i].time)
});
}
outputString.AppendLine("\t{precision} gradalpha = alpha0;");
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
var rgbaOutputName = GetVariableNameForSlot(RGBAOutputSlotId);
visitor.AddShaderChunk(string.Format("{0}4 {1} = {0}4({2}.rgb, {3}.r);", precision, rgbaOutputName, GetColorKeyName(0), GetAlphaKeyName(0)), false);
for (int i = 0; i < alphakeys.Length - 1; i++)
visitor.AddShaderChunk("{", false);
visitor.Indent();
int j = i + 1;
outputString.AppendLine(string.Format("\t{{precision}} alphaLerpPosition{0}=smoothstep(alphap{0},alphap{1},value);", i, j));
outputString.AppendLine(string.Format("\tgradalpha = lerp(gradalpha,alpha{0},alphaLerpPosition{1});", j, i));
var timeInputValue = GetSlotValue(TimeInputSlotId, generationMode);
// Color interpolation
for (var i = 0; i < m_Gradient.colorKeys.Length - 1; i++)
visitor.AddShaderChunk(string.Format("{3}.rgb = lerp({3}.rgb, {1}.rgb, smoothstep({0}.a, {1}.a, {2}));", GetColorKeyName(i), GetColorKeyName(i + 1), timeInputValue, rgbaOutputName), false);
// Alpha interpolation
for (var i = 0; i < m_Gradient.alphaKeys.Length - 1; i++)
visitor.AddShaderChunk(string.Format("{3}.a = lerp({3}.a, {1}.r, smoothstep({0}.g, {1}.g, {2}));", GetAlphaKeyName(i), GetAlphaKeyName(i + 1), timeInputValue, rgbaOutputName), false);
visitor.Deindent();
visitor.AddShaderChunk("}", false);
//Result
outputString.AppendLine("\tresult = float4(gradcolor,gradalpha);");
outputString.AppendLine("}");
return outputString.ToString();
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.r;", precision, GetVariableNameForSlot(ROutputSlotId), rgbaOutputName), false);
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.g;", precision, GetVariableNameForSlot(GOutputSlotId), rgbaOutputName), false);
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.b;", precision, GetVariableNameForSlot(BOutputSlotId), rgbaOutputName), false);
visitor.AddShaderChunk(string.Format("{0} {1} = {2}.a;", precision, GetVariableNameForSlot(AOutputSlotId), rgbaOutputName), false);
}
}
}

2
MaterialGraphProject/Assets/NewNodes/Editor/Keep/ConstantsNode.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.MaterialGraph;
using UnityEngine.Graphing;

private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Constant";
[EnumControl("")]
public ConstantType constant
{
get { return m_constant; }

5
MaterialGraphProject/Assets/NewNodes/Editor/Keep/BlendModeNode.cs


using System.Reflection;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

}
[SerializeField]
private BlendModesEnum m_BlendMode;
BlendModesEnum m_BlendMode;
[EnumControl("")]
public BlendModesEnum blendMode
{
get { return m_BlendMode; }

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs


using System;
using System.Reflection;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

name = "SubGraphOutputs";
}
[SubGraphOutputControl]
int controlDummy { get; set; }
public override int AddSlot()
{
var index = GetInputSlots<ISlot>().Count() + 1;

}
public override bool allowedInRemapGraph { get { return false; } }
}
public class SubGraphOutputControlAttribute : Attribute, IControlAttribute
{
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (!(node is AbstractSubGraphIONode))
throw new ArgumentException("Node must inherit from AbstractSubGraphIONode.", "node");
return new SubGraphOutputControlView((AbstractSubGraphIONode)node);
}
}
public class SubGraphOutputControlView : VisualElement
{
AbstractSubGraphIONode m_Node;
public SubGraphOutputControlView(AbstractSubGraphIONode node)
{
m_Node = node;
Add(new Button(OnAdd) { text = "Add Slot" });
Add(new Button(OnRemove) { text = "Remove Slot" });
}
void OnAdd()
{
m_Node.AddSlot();
}
void OnRemove()
{
m_Node.RemoveSlot();
}
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphNode.cs


using System;
using System.Linq;
using UnityEditor.MaterialGraph.Drawing.Controls;
#if UNITY_EDITOR
using UnityEditor;
#endif

}
#if UNITY_EDITOR
[ObjectControl("Subgraph")]
public MaterialSubGraphAsset subGraphAsset
{
get

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs.meta


fileFormatVersion: 2
guid: 861139fc6f60415cae2eb9a9625aaeb8
fileFormatVersion: 2
guid: 861139fc6f60415cae2eb9a9625aaeb8
timeCreated: 1506873607

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs


using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

}
#if UNITY_EDITOR
[ObjectControl("Remap")]
public MasterRemapGraphAsset remapGraphAsset
{
get

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphNode.cs.meta


fileFormatVersion: 2
guid: bc4cf774a7a6480ba543eb6069cd1c50
fileFormatVersion: 2
guid: bc4cf774a7a6480ba543eb6069cd1c50
timeCreated: 1506847426

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraph.cs.meta


fileFormatVersion: 2
guid: f2b67435729448498da7e7b90f052ebd
fileFormatVersion: 2
guid: f2b67435729448498da7e7b90f052ebd
timeCreated: 1506844687

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorRejectionNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Vector/Rejection Node")]
public class VectorRejectionNode : CodeFunctionNode
{
public VectorRejectionNode()
{
name = "VectorRejection";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_VectorRejection", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_VectorRejection(
[Slot(0, Binding.None)] DynamicDimensionVector first,
[Slot(1, Binding.None)] DynamicDimensionVector second,
[Slot(2, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = first - (second * dot(first, second) / dot(second, second));
}
";
}
}
}

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VectorProjectionNode.cs


using System.Reflection;
namespace UnityEngine.MaterialGraph
{
[Title("Vector/Projection Node")]
public class VectorProjectionNode : CodeFunctionNode
{
public VectorProjectionNode()
{
name = "VectorProjection";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_VectorProjection", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_VectorProjection(
[Slot(0, Binding.None)] DynamicDimensionVector first,
[Slot(1, Binding.None)] DynamicDimensionVector second,
[Slot(2, Binding.None)] out DynamicDimensionVector result)
{
return
@"
{
result = second * dot(first, second) / dot(second, second);
}";
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyNode.cs


using System;
using System.Linq;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

return edges.Count == 0;
}
[PropertyControl]
public Guid propertyGuid
{
get { return m_PropertyGuid; }

22
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PreviewNode.cs


{
public override bool hasPreview { get { return true; } }
[SerializeField]
float m_Width;
[SerializeField]
float m_Height;
public void SetDimensions(float width, float height)
{
m_Width = width;
m_Height = height;
}
public float width
{
get { return m_Width; }
}
public float height
{
get { return m_Height; }
}
public PreviewNode()
{
name = "Preview";

261
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Logic/IFNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Logic/If")]
public class IfNode : CodeFunctionNode
{
public enum ComparisonOperationType
{
Equal = 0,
NotEqual,
GreaterThan,
GreaterThanOrEqual,
LessThan,
LessThanOrEqual
}
[SerializeField]
private ComparisonOperationType m_comparisonOperation = ComparisonOperationType.Equal;
public ComparisonOperationType ComparisonOperation
{
get { return m_comparisonOperation; }
set
{
if (m_comparisonOperation == value)
return;
m_comparisonOperation = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public IfNode()
{
name = "If";
}
protected override MethodInfo GetFunctionToConvert()
{
switch (ComparisonOperation)
{
case ComparisonOperationType.Equal:
return GetType().GetMethod("Unity_IfEqual", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonOperationType.NotEqual:
return GetType().GetMethod("Unity_IfNotEqual", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonOperationType.GreaterThan:
return GetType().GetMethod("Unity_IfGreaterThan", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonOperationType.GreaterThanOrEqual:
return GetType().GetMethod("Unity_IfGreaterThanOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonOperationType.LessThan:
return GetType().GetMethod("Unity_IfLessThan", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonOperationType.LessThanOrEqual:
return GetType().GetMethod("Unity_IfLessThanOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
default:
throw new ArgumentOutOfRangeException();
}
}
const string functionTemplate = @"
{
if({comparitor})
{
result = trueValue;
}
else
{
result = falseValue;
}
}
";
static string Unity_IfEqual(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a == b");
}
static string Unity_IfNotEqual(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a != b");
}
static string Unity_IfGreaterThan(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a > b");
}
static string Unity_IfGreaterThanOrEqual(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a >= b");
}
static string Unity_IfLessThan(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a < b");
}
static string Unity_IfLessThanOrEqual(
[Slot(0, Binding.None)] DynamicDimensionVector a,
[Slot(1, Binding.None)] DynamicDimensionVector b,
[Slot(2, Binding.None)] DynamicDimensionVector trueValue,
[Slot(3, Binding.None)] DynamicDimensionVector falseValue,
[Slot(4, Binding.None)] DynamicDimensionVector result)
{
return functionTemplate.Replace("{comparitor}", "a <= b");
}
}
// PROBABLY USEFUL, BUT BROKEN AT THE MOMENT
// [Title("Logic/If")]
// public class IfNode : CodeFunctionNode
// {
// public enum ComparisonOperationType
// {
// Equal = 0,
// NotEqual,
// GreaterThan,
// GreaterThanOrEqual,
// LessThan,
// LessThanOrEqual
// }
//
// [SerializeField]
// private ComparisonOperationType m_comparisonOperation = ComparisonOperationType.Equal;
//
// public ComparisonOperationType ComparisonOperation
// {
// get { return m_comparisonOperation; }
// set
// {
// if (m_comparisonOperation == value)
// return;
//
// m_comparisonOperation = value;
// if (onModified != null)
// {
// onModified(this, ModificationScope.Graph);
// }
// }
// }
//
// public IfNode()
// {
// name = "If";
// }
//
// protected override MethodInfo GetFunctionToConvert()
// {
// switch (ComparisonOperation)
// {
// case ComparisonOperationType.Equal:
// return GetType().GetMethod("Unity_IfEqual", BindingFlags.Static | BindingFlags.NonPublic);
// case ComparisonOperationType.NotEqual:
// return GetType().GetMethod("Unity_IfNotEqual", BindingFlags.Static | BindingFlags.NonPublic);
// case ComparisonOperationType.GreaterThan:
// return GetType().GetMethod("Unity_IfGreaterThan", BindingFlags.Static | BindingFlags.NonPublic);
// case ComparisonOperationType.GreaterThanOrEqual:
// return GetType().GetMethod("Unity_IfGreaterThanOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
// case ComparisonOperationType.LessThan:
// return GetType().GetMethod("Unity_IfLessThan", BindingFlags.Static | BindingFlags.NonPublic);
// case ComparisonOperationType.LessThanOrEqual:
// return GetType().GetMethod("Unity_IfLessThanOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
// default:
// throw new ArgumentOutOfRangeException();
// }
// }
//
// const string functionTemplate = @"
//{
// if({comparitor})
// {
// result = trueValue;
// }
// else
// {
// result = falseValue;
// }
//}
//";
// static string Unity_IfEqual(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a == b");
// }
//
// static string Unity_IfNotEqual(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a != b");
// }
//
// static string Unity_IfGreaterThan(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a > b");
// }
//
// static string Unity_IfGreaterThanOrEqual(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a >= b");
// }
//
// static string Unity_IfLessThan(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a < b");
// }
//
// static string Unity_IfLessThanOrEqual(
// [Slot(0, Binding.None)] DynamicDimensionVector a,
// [Slot(1, Binding.None)] DynamicDimensionVector b,
// [Slot(2, Binding.None)] DynamicDimensionVector trueValue,
// [Slot(3, Binding.None)] DynamicDimensionVector falseValue,
// [Slot(4, Binding.None)] DynamicDimensionVector result)
// {
// return functionTemplate.Replace("{comparitor}", "a <= b");
// }
// }
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector4Node.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[MultiFloatControl("")]
public Vector4 value
{
get { return m_Value; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector3Node.cs


using System;
using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[MultiFloatControl("")]
public Vector3 value
{
get { return m_Value; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector2Node.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[MultiFloatControl("")]
public Vector2 value
{
get { return m_Value; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector1Node.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[MultiFloatControl("")]
public float value
{
get { return m_Value; }

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs


using System.ComponentModel;
using UnityEngine.Graphing;
using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
namespace UnityEngine.MaterialGraph
{

public override bool hasPreview { get { return false; } }
[EnumControl("")]
public CommonMatrixType matrix
{
get { return m_matrix; }

62
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
const int kOutputSlotId = 0;
const string kOutputSlotName = "Value";
private Vector4[] m_Value = new Vector4[4];
Vector4 m_Row0;
[SerializeField]
Vector4 m_Row1;
[SerializeField]
Vector4 m_Row2;
[SerializeField]
Vector4 m_Row3;
public Vector4 this[int index]
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector4 row0
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
get { return m_Row0; }
set { SetRow(ref m_Row0, value); }
}
m_Value[index] = value;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector4 row1
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}
if (onModified != null)
onModified(this, ModificationScope.Node);
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector4 row2
{
get { return m_Row2; }
set { SetRow(ref m_Row2, value); }
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector4 row3
{
get { return m_Row3; }
set { SetRow(ref m_Row3, value); }
}
void SetRow(ref Vector4 row, Vector4 value)
{
if (value == row)
return;
row = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
}
public Matrix4Node()

//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "4x4 " + propertyName + " = " + precision + "4x4 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[0].z + ", " + m_Value[0].w + ", " + m_Value[1].x + ", " + m_Value[1].y + ", " + m_Value[1].z + ", " + m_Value[1].w + ", " + m_Value[2].x + ", " + m_Value[2].y + ", " + m_Value[2].z + ", " + m_Value[2].w + ", " + m_Value[3].x + ", " + m_Value[3].y + ", " + m_Value[3].z + ", " + m_Value[3].w + ");", true);
visitor.AddShaderChunk(precision + "4x4 " + propertyName + " = " + precision + "4x4 (" + row0.x + ", " + row0.y + ", " + row0.z + ", " + row0.w + ", " + m_Row1.x + ", " + m_Row1.y + ", " + m_Row1.z + ", " + m_Row1.w + ", " + m_Row2.x + ", " + m_Row2.y + ", " + m_Row2.z + ", " + m_Row2.w + ", " + m_Row3.x + ", " + m_Row3.y + ", " + m_Row3.z + ", " + m_Row3.w + ");", true);
private string m_Description = string.Empty;
string m_Description = string.Empty;
public string description
{

56
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
const int kOutputSlotId = 0;
const string kOutputSlotName = "Value";
private Vector3[] m_Value = new Vector3[3];
Vector3 m_Row0;
public Vector3 this[int index]
[SerializeField]
Vector3 m_Row1;
[SerializeField]
Vector3 m_Row2;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row0
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
get { return m_Row0; }
set { SetRow(ref m_Row0, value); }
}
m_Value[index] = value;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row1
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}
if (onModified != null)
onModified(this, ModificationScope.Node);
}
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector3 row2
{
get { return m_Row2; }
set { SetRow(ref m_Row2, value); }
}
void SetRow(ref Vector3 row, Vector3 value)
{
if (value == row)
return;
row = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
}
public Matrix3Node()

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector4.zero));
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "3x3 " + propertyName + " = " + precision + "3x3 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[0].z + ", " + m_Value[1].x + ", " + m_Value[1].y + ", " + m_Value[1].z + ", " + m_Value[2].x + ", " + m_Value[2].y + ", " + m_Value[2].z + ");", true);
visitor.AddShaderChunk(precision + "3x3 " + propertyName + " = " + precision + "3x3 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row0.z + ", " + m_Row1.x + ", " + m_Row1.y + ", " + m_Row1.z + ", " + m_Row2.x + ", " + m_Row2.y + ", " + m_Row2.z + ");", true);
private string m_Description = string.Empty;
string m_Description = string.Empty;
public string description
{

{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector4 = m_Value
m_Vector3 = m_Value
};
}*/
}

46
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

{
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Value";
const int kOutputSlotId = 0;
const string kOutputSlotName = "Value";
private Vector2[] m_Value = new Vector2[2];
Vector2 m_Row0;
public Vector2 this[int index]
[SerializeField]
Vector2 m_Row1;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector2 row0
get { return m_Value[index]; }
set
{
if (m_Value[index] == value)
return;
get { return m_Row0; }
set { SetRow(ref m_Row0, value); }
}
m_Value[index] = value;
[MultiFloatControl("", " ", " ", " ", " ")]
public Vector2 row1
{
get { return m_Row1; }
set { SetRow(ref m_Row1, value); }
}
if (onModified != null)
onModified(this, ModificationScope.Node);
}
void SetRow(ref Vector2 row, Vector2 value)
{
if (value == row)
return;
row = value;
if (onModified != null)
onModified(this, ModificationScope.Graph);
}
public Matrix2Node()

public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix2, Vector4.zero));
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix2, Vector2.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}

//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
// return;
visitor.AddShaderChunk(precision + "2 " + name + " = " + precision + "2x2 (" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[1].x + ", " + m_Value[1].y + ");", true);
visitor.AddShaderChunk(precision + "2 " + name + " = " + precision + "2x2 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row1.x + ", " + m_Row1.y + ");", true);
private string m_Description = string.Empty;
string m_Description = string.Empty;
public string description
{

{
m_Name = propertyName,
m_PropType = PropertyType.Vector2,
m_Vector4 = m_Value
m_Vector2 = m_Value
};
}*/
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs


using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

[SerializeField]
private UVChannel m_OutputChannel;
[EnumControl("")]
public UVChannel uvChannel
{
get { return m_OutputChannel; }

28
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/ColorNode.cs


using System.Collections.Generic;
using UnityEditor.MaterialGraph.Drawing.Controls;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph

{
[SerializeField]
private bool m_HDR;
[SerializeField]
private Color m_Color;

public bool HDR
{
get { return m_HDR; }
set
{
if (m_HDR == value)
return;
m_HDR = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
public ColorNode()
{
name = "Color";

public override bool hasPreview
{
get { return true; }
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));

[ColorControl("")]
public Color color
{
get { return m_Color; }

overrideReferenceName = GetVariableNameForNode(),
generatePropertyBlock = false,
value = color,
HDR = HDR
HDR = false
});
}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/AbstractLightweightMasterNode.cs.meta


fileFormatVersion: 2
guid: 72c867ea29464bec864ea612e2bcecd3
fileFormatVersion: 2
guid: 72c867ea29464bec864ea612e2bcecd3
timeCreated: 1505799928

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/NeededCoordinateSpace.cs.meta


fileFormatVersion: 2
guid: 8ad845bb8ef34e4589bcf630a8a8a31a
fileFormatVersion: 2
guid: 8ad845bb8ef34e4589bcf630a8a8a31a
timeCreated: 1505627582

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/VectorShaderProperty.cs.meta


fileFormatVersion: 2
guid: 4f83ebb04c5c4df184601ef18aa7d89d
fileFormatVersion: 2
guid: 4f83ebb04c5c4df184601ef18aa7d89d
timeCreated: 1505408377

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector4ShaderProperty.cs.meta


fileFormatVersion: 2
guid: 3989871719194dbdba09613ac74761b3
fileFormatVersion: 2
guid: 3989871719194dbdba09613ac74761b3
timeCreated: 1505346935

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector3ShaderProperty.cs.meta


fileFormatVersion: 2
guid: 34a68571f5ae4ebe8221824597dc0675
fileFormatVersion: 2
guid: 34a68571f5ae4ebe8221824597dc0675
timeCreated: 1505346931

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector2ShaderProperty.cs.meta


fileFormatVersion: 2
guid: dbd5691737554a15ab0b098fca999382
fileFormatVersion: 2
guid: dbd5691737554a15ab0b098fca999382
timeCreated: 1505346926

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureShaderProperty.cs.meta


fileFormatVersion: 2
guid: 08e62564fb95471d9580619b660c6531
fileFormatVersion: 2
guid: 08e62564fb95471d9580619b660c6531
timeCreated: 1505346949

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/TextureSamplerState.cs.meta


fileFormatVersion: 2
guid: a0238123ffe44c05bc05acf347c4d52d
fileFormatVersion: 2
guid: a0238123ffe44c05bc05acf347c4d52d
timeCreated: 1505436371

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ShaderGraphRequirements.cs.meta


fileFormatVersion: 2
guid: b80c0c5cd7f940d7bc0f37b22c454d40
fileFormatVersion: 2
guid: b80c0c5cd7f940d7bc0f37b22c454d40
timeCreated: 1505698038

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableTexture.cs.meta


fileFormatVersion: 2
guid: a4a4ff926ce74b059400bb049aefcba2
fileFormatVersion: 2
guid: a4a4ff926ce74b059400bb049aefcba2
timeCreated: 1505346945

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SamplerStateShaderProperty.cs.meta


fileFormatVersion: 2
guid: b48a2e97e3e24303833a0062f90f4f13
fileFormatVersion: 2
guid: b48a2e97e3e24303833a0062f90f4f13
timeCreated: 1505436387

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderProperty.cs.meta


fileFormatVersion: 2
guid: 7594463b49eb4d70a1b938f328f0c0b0
fileFormatVersion: 2
guid: 7594463b49eb4d70a1b938f328f0c0b0
timeCreated: 1505346909

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/FloatShaderProperty.cs.meta


fileFormatVersion: 2
guid: 572cce24ed76430db4c21dfe82d01252
fileFormatVersion: 2
guid: 572cce24ed76430db4c21dfe82d01252
timeCreated: 1505346922

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ColorShaderProperty.cs.meta


fileFormatVersion: 2
guid: 47cf9e64b21b48b09320f42eb82ac3c3
fileFormatVersion: 2
guid: 47cf9e64b21b48b09320f42eb82ac3c3
timeCreated: 1505346940

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractShaderProperty.cs.meta


fileFormatVersion: 2
guid: b1411039ed1342fa8efff6fa8a4c179d
fileFormatVersion: 2
guid: b1411039ed1342fa8efff6fa8a4c179d
timeCreated: 1505346915

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/StackPool.cs.meta


fileFormatVersion: 2
guid: 93c41a4331c94d09a7561ea6b4983439
fileFormatVersion: 2
guid: 93c41a4331c94d09a7561ea6b4983439
timeCreated: 1505275069

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/SerializationHelper.cs


TypeSerializationInfo info = item.typeInfo;
if (remapper != null)
info = DoTypeRemap(info, remapper);
info.assemblyName = "Assembly-CSharp-Editor";
throw new ArgumentException(string.Format("Can not deserialize {0}, type {1} is invalid", info));
throw new ArgumentException(string.Format("Can not deserialize ({0}, {1}), type is invalid", info.assemblyName, info.fullName));
T instance;
try

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Util/QueuePool.cs.meta


fileFormatVersion: 2
guid: 4e895afeaf2a438195fbc4de17a4bedc
fileFormatVersion: 2
guid: 4e895afeaf2a438195fbc4de17a4bedc
timeCreated: 1505278549

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs


public OnGraphChange onChange { get; set; }
public IGraphObject owner { get; set; }
protected void NotifyChange(GraphChange change)
{
if (onChange != null)

1
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraph.cs


void ValidateGraph();
void ReplaceWith(IGraph other);
OnGraphChange onChange { get; set; }
IGraphObject owner { get; set; }
}
}

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/GraphChange.cs.meta


fileFormatVersion: 2
guid: cbfac7ed81744ca281be9e21eae861c7
fileFormatVersion: 2
guid: cbfac7ed81744ca281be9e21eae861c7
timeCreated: 1505620762

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data.meta


fileFormatVersion: 2
guid: f56929b05da66c942ad2e3fe376346fa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls.meta


fileFormatVersion: 2
guid: 29309be0e1004fad967256187775c528
timeCreated: 1507642261

61
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Draggable.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.MaterialGraph.Drawing
{
public class Draggable : MouseManipulator
{
Action<Vector2> m_Handler;
bool m_Active;
public Draggable(Action<Vector2> handler)
{
m_Handler = handler;
m_Active = false;
activators.Add(new ManipulatorActivationFilter()
{
button = MouseButton.LeftMouse
});
}
protected override void RegisterCallbacksOnTarget()
{
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
}
protected override void UnregisterCallbacksFromTarget()
{
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
}
void OnMouseDown(MouseDownEvent evt)
{
target.TakeCapture();
m_Active = true;
evt.StopPropagation();
}
void OnMouseMove(MouseMoveEvent evt)
{
if (m_Active)
{
m_Handler(evt.localMousePosition);
}
}
void OnMouseUp(MouseUpEvent evt)
{
m_Active = false;
target.ReleaseCapture();
evt.StopPropagation();
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/Draggable.cs.meta


fileFormatVersion: 2
guid: ad4cd8fec883e80418e5427585b426db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

42
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/Gradient.ShaderGraph
文件差异内容过多而无法显示
查看文件

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/Graphs/Gradient.ShaderGraph.meta


fileFormatVersion: 2
guid: 090ac3a2dd039884ba2dfa3b2ca34452
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

8
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs


namespace UnityEngine.Graphing
{
public interface IGraphObject
{
IGraph graph { get; set; }
void RegisterCompleteObjectUndo(string name);
}
}

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Interfaces/IGraphObject.cs.meta


fileFormatVersion: 2
guid: 59661073fa1046e9b3aa3fea5c7f5c54
timeCreated: 1508144485

65
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs


using System;
using UnityEditor;
namespace UnityEngine.Graphing
{
public class SerializableGraphObject : ScriptableObject, IGraphObject, ISerializationCallbackReceiver
{
[SerializeField]
SerializationHelper.JSONSerializedElement m_SerializedGraph;
IGraph m_Graph;
IGraph m_DeserializedGraph;
public IGraph graph
{
get { return m_Graph; }
set
{
if (m_Graph != null)
m_Graph.owner = null;
m_Graph = value;
if (m_Graph != null)
m_Graph.owner = this;
}
}
public void RegisterCompleteObjectUndo(string name)
{
Undo.RegisterCompleteObjectUndo(this, name);
}
public void OnBeforeSerialize()
{
m_SerializedGraph = SerializationHelper.Serialize(graph);
}
public void OnAfterDeserialize()
{
var deserializedGraph = SerializationHelper.Deserialize<IGraph>(m_SerializedGraph, null);
if (graph == null)
graph = m_DeserializedGraph;
else
m_DeserializedGraph = deserializedGraph; // graph.ReplaceWith(m_DeserializedGraph);
}
void OnEnable()
{
Undo.undoRedoPerformed += UndoRedoPerformed;
}
void OnDisable()
{
Undo.undoRedoPerformed -= UndoRedoPerformed;
}
void UndoRedoPerformed()
{
if (m_DeserializedGraph != null)
{
graph.ReplaceWith(m_DeserializedGraph);
m_DeserializedGraph = null;
}
}
}
}

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraphObject.cs.meta


fileFormatVersion: 2
guid: 463ff292c8554dc18fb52fb725707a21
timeCreated: 1508144011

53
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs


using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class ColorControlAttribute : Attribute, IControlAttribute
{
string m_Label;
public ColorControlAttribute(string label = null)
{
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new ColorControlView(m_Label, node, propertyInfo);
}
}
public class ColorControlView : VisualElement
{
GUIContent m_Label;
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
public ColorControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
m_Node = node;
m_PropertyInfo = propertyInfo;
if (propertyInfo.PropertyType != typeof(Color))
throw new ArgumentException("Property must be of type Color.", "propertyInfo");
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
Add(new IMGUIContainer(OnGUIHandler));
}
void OnGUIHandler()
{
var value = (Color) m_PropertyInfo.GetValue(m_Node, null);
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
value = EditorGUILayout.ColorField(m_Label, value);
if (changeCheckScope.changed)
m_PropertyInfo.SetValue(m_Node, value, null);
}
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs.meta


fileFormatVersion: 2
guid: 34e77444559b414f9fe81f9775229abf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs.meta


fileFormatVersion: 2
guid: 20e01cb163f347c7819ae286c33baf85
timeCreated: 1507642280

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IControlAttribute.cs


using System.Reflection;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
public interface IControlAttribute
{
VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo);
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IControlAttribute.cs.meta


fileFormatVersion: 2
guid: 5f008211c3394775bdefde0b20e5c8ff
timeCreated: 1507642348

165
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/VectorControl.cs


using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class MultiFloatControlAttribute : Attribute, IControlAttribute
{
string m_Label;
string m_SubLabel1;
string m_SubLabel2;
string m_SubLabel3;
string m_SubLabel4;
public MultiFloatControlAttribute(string label = null, string subLabel1 = "X", string subLabel2 = "Y", string subLabel3 = "Z", string subLabel4 = "W")
{
m_SubLabel1 = subLabel1;
m_SubLabel2 = subLabel2;
m_SubLabel3 = subLabel3;
m_SubLabel4 = subLabel4;
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (!MultiFloatControlView.validTypes.Contains(propertyInfo.PropertyType))
return null;
return new MultiFloatControlView(m_Label, m_SubLabel1, m_SubLabel2, m_SubLabel3, m_SubLabel4, node, propertyInfo);
}
}
public class MultiFloatControlView : VisualElement
{
public static Type[] validTypes = { typeof(float), typeof(Vector2), typeof(Vector3), typeof(Vector4) };
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
float[] m_Values;
GUIContent[] m_Labels;
GUIContent m_Label;
float m_Height;
Action m_Read;
Action m_Write;
public MultiFloatControlView(string label, string subLabel1, string subLabel2, string subLabel3, string subLabel4, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
int components;
SerializedPropertyType serializedPropertyType;
if (propertyInfo.PropertyType == typeof(float))
{
components = 1;
serializedPropertyType = SerializedPropertyType.Float;
m_Read = ReadFloat;
m_Write = WriteFloat;
}
else if (propertyInfo.PropertyType == typeof(Vector2))
{
components = 2;
serializedPropertyType = SerializedPropertyType.Vector2;
m_Read = ReadVector2;
m_Write = WriteVector2;
}
else if (propertyInfo.PropertyType == typeof(Vector3))
{
components = 3;
serializedPropertyType = SerializedPropertyType.Vector3;
m_Read = ReadVector3;
m_Write = WriteVector3;
}
else if (propertyInfo.PropertyType == typeof(Vector4))
{
components = 4;
serializedPropertyType = SerializedPropertyType.Vector4;
m_Read = ReadVector4;
m_Write = WriteVector4;
}
else
{
throw new ArgumentException("Property must be of type float, Vector2, Vector3 or Vector4.", "propertyInfo");
}
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
m_Node = node;
m_PropertyInfo = propertyInfo;
m_Values = new float[components];
m_Labels = new GUIContent[components];
m_Labels[0] = new GUIContent(subLabel1);
if (components > 1)
m_Labels[1] = new GUIContent(subLabel2);
if (components > 2)
m_Labels[2] = new GUIContent(subLabel3);
if (components > 3)
m_Labels[3] = new GUIContent(subLabel4);
m_Height = EditorGUI.GetPropertyHeight(serializedPropertyType, m_Label);
Add(new IMGUIContainer(OnGUIHandler));
}
void ReadFloat()
{
var value = (float)m_PropertyInfo.GetValue(m_Node, null);
m_Values[0] = value;
}
void ReadVector2()
{
var value = (Vector2)m_PropertyInfo.GetValue(m_Node, null);
m_Values[0] = value.x;
m_Values[1] = value.y;
}
void ReadVector3()
{
var value = (Vector3)m_PropertyInfo.GetValue(m_Node, null);
m_Values[0] = value.x;
m_Values[1] = value.y;
m_Values[2] = value.z;
}
void ReadVector4()
{
var value = (Vector4)m_PropertyInfo.GetValue(m_Node, null);
m_Values[0] = value.x;
m_Values[1] = value.y;
m_Values[2] = value.z;
m_Values[3] = value.w;
}
void WriteFloat()
{
m_PropertyInfo.SetValue(m_Node, m_Values[0], null);
}
void WriteVector2()
{
m_PropertyInfo.SetValue(m_Node, new Vector2(m_Values[0], m_Values[1]), null);
}
void WriteVector3()
{
m_PropertyInfo.SetValue(m_Node, new Vector3(m_Values[0], m_Values[1], m_Values[2]), null);
}
void WriteVector4()
{
m_PropertyInfo.SetValue(m_Node, new Vector4(m_Values[0], m_Values[1], m_Values[2], m_Values[3]), null);
}
void OnGUIHandler()
{
m_Read();
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
var position = EditorGUILayout.GetControlRect(true, m_Height, EditorStyles.numberField);
EditorGUI.MultiFloatField(position, m_Label, m_Labels, m_Values);
if (changeCheckScope.changed)
m_Write();
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/VectorControl.cs.meta


fileFormatVersion: 2
guid: 8a515dc1bacc453b870777d8da9a7211
timeCreated: 1507642288

52
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs


using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class EnumControlAttribute : Attribute, IControlAttribute
{
string m_Label;
public EnumControlAttribute(string label = null)
{
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new EnumControlView(m_Label, node, propertyInfo);
}
}
public class EnumControlView : VisualElement
{
GUIContent m_Label;
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
public EnumControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
m_Node = node;
m_PropertyInfo = propertyInfo;
if (!propertyInfo.PropertyType.IsEnum)
throw new ArgumentException("Property must be an enum.", "propertyInfo");
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
Add(new IMGUIContainer(OnGUIHandler));
}
void OnGUIHandler()
{
var value = (Enum) m_PropertyInfo.GetValue(m_Node, null);
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
value = EditorGUILayout.EnumPopup(m_Label, value);
if (changeCheckScope.changed)
m_PropertyInfo.SetValue(m_Node, value, null);
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/EnumControl.cs.meta


fileFormatVersion: 2
guid: 3a1e13c5e67541d7ad7ae18ea5a834e4
timeCreated: 1507817885

44
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs


using System;
using System.Linq;
using System.Reflection;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class PropertyControlAttribute : Attribute, IControlAttribute
{
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new PropertyControlView(node);
}
}
public class PropertyControlView : VisualElement
{
PropertyNode m_Node;
public PropertyControlView(AbstractMaterialNode node)
{
m_Node = (PropertyNode) node;
Add(new IMGUIContainer(OnGUIHandler));
}
void OnGUIHandler()
{
var graph = m_Node.owner as AbstractMaterialGraph;
var currentGUID = m_Node.propertyGuid;
var properties = graph.properties.ToList();
var propertiesGUID = properties.Select(x => x.guid).ToList();
var currentSelectedIndex = propertiesGUID.IndexOf(currentGUID);
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
var value = EditorGUILayout.Popup("Property", currentSelectedIndex, properties.Select(x => x.displayName).ToArray());
if (changeCheckScope.changed)
m_Node.propertyGuid = propertiesGUID[value];
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs.meta


fileFormatVersion: 2
guid: bb1167be0ec94c0a849394d34df45a98
timeCreated: 1507819549

89
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/GradientControl.cs


using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class GradientControlAttribute : Attribute, IControlAttribute
{
string m_Label;
public GradientControlAttribute(string label = null)
{
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new GradientControlView(m_Label, node, propertyInfo);
}
}
[Serializable]
public class GradientObject : ScriptableObject
{
public Gradient gradient = new Gradient();
}
public class GradientControlView : VisualElement
{
GUIContent m_Label;
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
string m_PrevWindow = "";
[SerializeField]
GradientObject m_GradientObject;
[SerializeField]
SerializedObject m_SerializedObject;
[SerializeField]
SerializedProperty m_SerializedProperty;
public GradientControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name));
m_Node = node;
m_PropertyInfo = propertyInfo;
if (propertyInfo.PropertyType != typeof(Gradient))
throw new ArgumentException("Property must be of type Gradient.", "propertyInfo");
m_GradientObject = ScriptableObject.CreateInstance<GradientObject>();
m_GradientObject.gradient = new Gradient();
m_SerializedObject = new SerializedObject(m_GradientObject);
m_SerializedProperty = m_SerializedObject.FindProperty("gradient");
Add(new IMGUIContainer(OnGUIHandler));
}
void OnGUIHandler()
{
m_SerializedObject.Update();
var gradient = (Gradient)m_PropertyInfo.GetValue(m_Node, null);
m_GradientObject.gradient.SetKeys(gradient.colorKeys, gradient.alphaKeys);
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(m_SerializedProperty, m_Label, true, null);
m_SerializedObject.ApplyModifiedProperties();
if (changeCheckScope.changed)
m_PropertyInfo.SetValue(m_Node, m_GradientObject.gradient, null);
}
var e = Event.current;
if (EditorWindow.focusedWindow != null && m_PrevWindow != EditorWindow.focusedWindow.ToString() && EditorWindow.focusedWindow.ToString() != "(UnityEditor.GradientPicker)")
{
m_PropertyInfo.SetValue(m_Node, m_GradientObject.gradient, null);
m_PrevWindow = EditorWindow.focusedWindow.ToString();
Debug.Log("Update Gradient Shader");
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/GradientControl.cs.meta


fileFormatVersion: 2
guid: 41930fdac13e47db8faedb82e6411a4f
timeCreated: 1507882043

53
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ObjectControl.cs


using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class ObjectControlAttribute : Attribute, IControlAttribute
{
string m_Label;
public ObjectControlAttribute(string label = null)
{
m_Label = label;
}
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
return new ObjectControlView(m_Label, node, propertyInfo);
}
}
public class ObjectControlView : VisualElement
{
AbstractMaterialNode m_Node;
PropertyInfo m_PropertyInfo;
GUIContent m_Label;
public ObjectControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (!typeof(Object).IsAssignableFrom(propertyInfo.PropertyType))
throw new ArgumentException("Property must be assignable to UnityEngine.Object.");
m_Node = node;
m_PropertyInfo = propertyInfo;
m_Label = new GUIContent(label ?? propertyInfo.Name);
Add(new IMGUIContainer(OnGUIHandler));
}
void OnGUIHandler()
{
var value = (Object) m_PropertyInfo.GetValue(m_Node, null);
using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
value = EditorGUILayout.MiniThumbnailObjectField(m_Label, value, m_PropertyInfo.PropertyType);
if (changeCheckScope.changed)
m_PropertyInfo.SetValue(m_Node, value, null);
}
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ObjectControl.cs.meta


fileFormatVersion: 2
guid: 3f483132ae7b4689b20fd6b8c59633b5
timeCreated: 1507900115

29
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs


using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.MaterialGraph;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing.Controls
{
[AttributeUsage(AttributeTargets.Property)]
public class DefaultControlAttribute : Attribute, IControlAttribute
{
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo)
{
if (propertyInfo.PropertyType == typeof(Color))
return new ColorControlView(null, node, propertyInfo);
if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType))
return new EnumControlView(null, node, propertyInfo);
if (propertyInfo.PropertyType == typeof(Gradient))
return new GradientControlView(null, node, propertyInfo);
if (MultiFloatControlView.validTypes.Contains(propertyInfo.PropertyType))
return new MultiFloatControlView(null, "X", "Y", "Z", "W", node, propertyInfo);
if (typeof(Object).IsAssignableFrom(propertyInfo.PropertyType))
return new ObjectControlView(null, node, propertyInfo);
return null;
}
}
}

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime.meta


fileFormatVersion: 2
guid: 96b491f66dc38674cb2874ef6c452b3d
folderAsset: yes
timeCreated: 1464601235
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs.meta


fileFormatVersion: 2
guid: 68be9386ef4794d49967bf453668964e
timeCreated: 1495448531
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs.meta


fileFormatVersion: 2
guid: cebc29fc489af774fbf2b756ba815122
timeCreated: 1495456482
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs.meta


fileFormatVersion: 2
guid: 55391b421fcbe4e60bf16325132025ff
timeCreated: 1495456482
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs.meta


fileFormatVersion: 2
guid: 01ea0408c41734e0b8b28e0983f7a700
timeCreated: 1476732809
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

45
MaterialGraphProject/Assets/NewNodes/Editor/ToggleNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
/* [Serializable]
class ToggleNodeControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as ToggleNode;
if (cNode == null)
return;
cNode.value = EditorGUILayout.Toggle(cNode.value);
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
}
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*
public override float GetHeight()
{
return 2 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class ToggleNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<ToggleNodeControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}*/
}

56
MaterialGraphProject/Assets/NewNodes/Editor/BlendModeNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class BlendModeNodeControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as BlendModeNode;
if (cNode == null)
return;
cNode.blendMode = (BlendModesEnum)EditorGUILayout.EnumPopup("", cNode.blendMode);
}
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.standardVerticalSpacing;
}
}
#if WITH_PRESENTER
[Serializable]
public class BlendModeNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<BlendModeNodeControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
#endif
public class BlendModeNodeView : MaterialNodeView
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = ScriptableObject.CreateInstance<BlendModeNodeControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
}

62
MaterialGraphProject/Assets/NewNodes/Editor/ConstantsNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEngine.MaterialGraph;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class ConstantsContolPresenter : GraphControlPresenter
{
private string[] m_ConstantTypeNames;
private string[] constantTypeNames
{
get
{
if (m_ConstantTypeNames == null)
m_ConstantTypeNames = Enum.GetNames(typeof(ConstantType));
return m_ConstantTypeNames;
}
}
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as UnityEngine.MaterialGraph.ConstantsNode;
if (cNode == null)
return;
cNode.constant = (ConstantType)EditorGUILayout.Popup((int)cNode.constant, constantTypeNames, EditorStyles.popup);
}
public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
#if WITH_PRESENTER
[Serializable]
public class ConstantsNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<ConstantsContolPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
#endif
public class ConstantsNodeView : MaterialNodeView
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = ScriptableObject.CreateInstance<ConstantsContolPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
}

53
MaterialGraphProject/Assets/NewNodes/Editor/TransformNodePresenter.cs


using System;
using System.Collections.Generic;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine.MaterialGraph;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
class TransformControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as TransformNode;
if (tNode == null)
return;
//EditorGUILayout.BeginHorizontal ();
tNode.spaceFrom = (SimpleMatrixType)EditorGUILayout.EnumPopup("From", tNode.spaceFrom);
tNode.spaceTo = (SimpleMatrixType)EditorGUILayout.EnumPopup("To", tNode.spaceTo);
//EditorGUILayout.BeginHorizontal ();
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
#if WITH_PRESENTER
[Serializable]
public class TransformNodePresenter : PropertyNodePresenter
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = CreateInstance<TransformControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter>(base.GetControlData()) { instance };
}
}
#endif
public class TransformNodeView : PropertyNodeView
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = ScriptableObject.CreateInstance<TransformControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs.meta


fileFormatVersion: 2
guid: eaa1f14b82a26aa49b8a51ce08653c87
timeCreated: 1477985625
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta


fileFormatVersion: 2
guid: 7e4695133ddd49cf97b1629ca5537e5b
timeCreated: 1502981029

48
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/PropertyNodePresenter.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
public class PropertyControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var tNode = node as PropertyNode;
if (tNode == null)
return;
var graph = node.owner as AbstractMaterialGraph;
var currentGUID = tNode.propertyGuid;
var properties = graph.properties.ToList();
var propertiesGUID = properties.Select(x => x.guid).ToList();
var currentSelectedIndex = propertiesGUID.IndexOf(currentGUID);
var newIndex = EditorGUILayout.Popup("Property", currentSelectedIndex, properties.Select(x => x.displayName).ToArray());
if (newIndex != currentSelectedIndex)
tNode.propertyGuid = propertiesGUID[newIndex];
}
public override float GetHeight()
{
return (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 2 + EditorGUIUtility.standardVerticalSpacing;
}
}
public class PropertyNodeView : MaterialNodeView
{
protected override IEnumerable<GraphControlPresenter> GetControlData()
{
var instance = ScriptableObject.CreateInstance<PropertyControlPresenter>();
instance.Initialize(node);
return new List<GraphControlPresenter> { instance };
}
}
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Runtime.meta


fileFormatVersion: 2
guid: c196fa3d7b5ae4049afeb1cd0400d9b6
folderAsset: yes
timeCreated: 1464601235
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/MaterialGraphProject/Assets/NewNodes/Keep.meta → /MaterialGraphProject/Assets/NewNodes/Editor/Keep.meta

/MaterialGraphProject/Assets/NewNodes/Kill.meta → /MaterialGraphProject/Assets/NewNodes/Editor/Kill.meta

/MaterialGraphProject/Assets/NewNodes/ChannelBlendNode.cs → /MaterialGraphProject/Assets/NewNodes/Editor/ChannelBlendNode.cs

/MaterialGraphProject/Assets/NewNodes/ChannelBlendNode.cs.meta → /MaterialGraphProject/Assets/NewNodes/Editor/ChannelBlendNode.cs.meta

/MaterialGraphProject/Assets/NewNodes/CommonMatrixType.cs → /MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs

/MaterialGraphProject/Assets/NewNodes/CommonMatrixType.cs.meta → /MaterialGraphProject/Assets/NewNodes/Editor/CommonMatrixType.cs.meta

/MaterialGraphProject/Assets/NewNodes/ConstantType.cs → /MaterialGraphProject/Assets/NewNodes/Editor/ConstantType.cs

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存