浏览代码

[Shader graph]working delete + connect of nodes / edges

/main
Tim Cooper 9 年前
当前提交
3da9634f
共有 16 个文件被更改,包括 516 次插入403 次删除
  1. 36
      UnityProject/Assets/GraphFramework/Canvas2D/Editor/Graph.cs
  2. 183
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/DrawableMaterialNode.cs
  3. 19
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs
  4. 3
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialWindow.cs
  5. 211
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/SimpleWidgets.cs
  6. 152
      UnityProject/Assets/UnityShaderEditor/Graphs/GlowMud.ShaderGraph
  7. 96
      UnityProject/Assets/UnityShaderEditor/Graphs/LayeredTarp.ShaderGraph
  8. 5
      UnityProject/ProjectSettings/GraphicsSettings.asset
  9. 2
      UnityProject/ProjectSettings/ProjectSettings.asset
  10. 2
      UnityProject/ProjectSettings/ProjectVersion.txt
  11. 59
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MyNodeAdapters.cs
  12. 12
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MyNodeAdapters.cs.meta
  13. 85
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeAnchor.cs
  14. 12
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeAnchor.cs.meta
  15. 30
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeOutputAnchor.cs
  16. 12
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeOutputAnchor.cs.meta

36
UnityProject/Assets/GraphFramework/Canvas2D/Editor/Graph.cs


internal class Edge<T> : CanvasElement where T : CanvasElement, IConnect
{
private T Left = null;
private T Right = null;
private T m_Left = null;
private T m_Right = null;
private ICanvasDataSource m_Data;
public Edge(ICanvasDataSource data, T left, T right)
{

left.AddDependency(this);
right.AddDependency(this);
Left = left;
Right = right;
m_Left = left;
m_Right = right;
UpdateModel(UpdateType.eUpdate);

private bool OnDeleteEdge(CanvasElement element, Event e, Canvas2D canvas)
public T Left
{
get { return m_Left; }
}
public T Right
{
get { return m_Right; }
}
private bool OnDeleteEdge(CanvasElement element, Event e, Canvas2D canvas)
{
if (e.type == EventType.Used)
return false;

// bounding box check succeeded, do more fine grained check by checking intersection between the rectangles' diagonal
// and the line segments
Vector3 from = Left.ConnectPosition();
Vector3 to = Right.ConnectPosition();
Vector3 from = m_Left.ConnectPosition();
Vector3 to = m_Right.ConnectPosition();
if (to.x < from.x)
{

// bounding box check succeeded, do more fine grained check by measuring distance to bezier points
Vector3 from = Left.ConnectPosition();
Vector3 to = Right.ConnectPosition();
Vector3 from = m_Left.ConnectPosition();
Vector3 to = m_Right.ConnectPosition();
if (to.x < from.x)
{

{
Color edgeColor = selected ? Color.yellow : Color.white;
Vector3 from = Left.ConnectPosition();
Vector3 to = Right.ConnectPosition();
Vector3 from = m_Left.ConnectPosition();
Vector3 to = m_Right.ConnectPosition();
if (to.x < from.x)
{

public override void UpdateModel(UpdateType t)
{
Vector3 from = Left.ConnectPosition();
Vector3 to = Right.ConnectPosition();
Vector3 from = m_Left.ConnectPosition();
Vector3 to = m_Right.ConnectPosition();
Rect r = new Rect();
r.min = new Vector2(Math.Min(from.x, to.x), Math.Min(from.y, to.y));

183
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/DrawableMaterialNode.cs


using System;
using System.Linq;
using UnityEditor.Experimental.Graph;
using UnityEditor.Graphs;
internal class PortSource<T>
{
}
private readonly MaterialGraphDataSource m_Data;
private Rect previewArea;
private Rect m_PreviewArea;
AddManipulator(new IMGUIContainer());
m_Data = data;
Vector3 pos = new Vector3(5.0f, 10.0f, 0.0f);

pos.y += 22;
if (node.hasPreview)
{
previewArea = new Rect(10, pos.y, width - 20, width - 20);
{
m_PreviewArea = new Rect(10, pos.y, width - 20, width - 20);
KeyDown += OnDeleteNode;
public override void Render(Rect parentRect, Canvas2D canvas)
private bool OnDeleteNode(CanvasElement element, Event e, Canvas2D canvas)
base.Render(parentRect, canvas);
if (m_Node.hasPreview)
if (e.type == EventType.Used)
return false;
if (e.keyCode == KeyCode.Delete)
GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
GUI.DrawTexture(previewArea, m_Node.RenderPreview(new Rect(0, 0, previewArea.width, previewArea.height)), ScaleMode.StretchToFill, false);
GL.sRGBWrite = false;
m_Data.DeleteElement(this);
return true;
return false;
}
public class NodeAnchor : CanvasElement, IConnect
{
protected Type m_Type;
protected object m_Source;
protected Direction m_Direction;
private MaterialGraphDataSource m_Data;
public Slot m_Slot;
public NodeAnchor(Vector3 position, Type type, Slot slot, MaterialGraphDataSource data)
public override void UpdateModel(UpdateType t)
m_Type = type;
scale = new Vector3(15.0f, 15.0f, 1.0f);
translation = position;
AddManipulator(new EdgeConnector<NodeAnchor>());
m_Direction = Direction.eInput;
Type genericClass = typeof (PortSource<>);
Type constructedClass = genericClass.MakeGenericType(type);
m_Source = Activator.CreateInstance(constructedClass);
m_Data = data;
m_Slot = slot;
base.UpdateModel(t);
var pos = m_Node.position;
pos.min = translation;
m_Node.position = pos;
EditorUtility.SetDirty (m_Node);
var anchorColor = Color.yellow;
anchorColor.a = 0.7f;
EditorGUI.DrawRect(new Rect(translation.x, translation.y, scale.x, scale.y), anchorColor);
Rect labelRect = new Rect(translation.x + scale.x + 10.0f, translation.y, parentRect.width, 20.0f);
GUI.Label(labelRect, m_Slot.name);
}
// IConnect
public Direction GetDirection()
{
return m_Direction;
}
public void Highlight(bool highlighted)
{
}
public void RenderOverlay(Canvas2D canvas)
{
Rect thisRect = canvasBoundingRect;
thisRect.x += 4;
thisRect.y += 4;
thisRect.width -= 8;
thisRect.height -= 8;
thisRect = canvas.CanvasToScreen(thisRect);
EditorGUI.DrawRect(thisRect, new Color(0.0f, 0.0f, 0.8f));
}
public object Source()
{
return m_Source;
}
public Vector3 ConnectPosition()
{
return canvasBoundingRect.center;
}
public void OnConnect(IConnect other)
{
if (other == null)
return;
NodeAnchor otherAnchor = other as NodeAnchor;
m_Data.Connect(this, otherAnchor);
ParentCanvas().ReloadData();
}
};
public class NodeOutputAnchor : NodeAnchor
{
public NodeOutputAnchor(Vector3 position, Type type, Slot slot, MaterialGraphDataSource data)
: base(position, type, slot, data)
{
m_Direction = Direction.eOutput;
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
var anchorColor = Color.yellow;
anchorColor.a = 0.7f;
base.Render(parentRect, canvas);
EditorGUI.DrawRect(new Rect(translation.x, translation.y, scale.x, scale.y), anchorColor);
Vector2 sizeOfText = GUIStyle.none.CalcSize(new GUIContent(m_Type.Name));
Rect labelRect = new Rect(translation.x - sizeOfText.x - 4.0f, translation.y, sizeOfText.x + 4.0f, sizeOfText.y + 4.0f);
GUI.Label(labelRect, m_Slot.name);
}
};
internal static class MyNodeAdapters
{
internal static bool Adapt(this NodeAdapter value, PortSource<int> a, PortSource<int> b)
{
// run adapt code for int to int connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<float> a, PortSource<float> b)
{
// run adapt code for float to float connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<int> a, PortSource<float> b)
{
// run adapt code for int to float connections, perhaps by insertion a conversion node
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Vector3> a, PortSource<Vector3> b)
{
// run adapt code for vec3 to vec3 connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Color> a, PortSource<Color> b)
{
// run adapt code for Color to Color connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Vector3> a, PortSource<Color> b)
{
// run adapt code for vec3 to Color connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Color> a, PortSource<Vector3> b)
{
// run adapt code for Color to vec3 connections
return true;
if (m_Node.hasPreview)
{
GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
GUI.DrawTexture(m_PreviewArea, m_Node.RenderPreview(new Rect(0, 0, m_PreviewArea.width, m_PreviewArea.height)), ScaleMode.StretchToFill, false);
GL.sRGBWrite = false;
}
}
}
}

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


public void DeleteElement(CanvasElement e)
{
//m_Elements.Remove(e);
Debug.Log("Trying to delete " + e);
if (e is DrawableMaterialNode)
{
Debug.Log("Deleting node " + e + " " + ((DrawableMaterialNode) e).m_Node);
graph.currentGraph.RemoveNode(((DrawableMaterialNode) e).m_Node);
}
else if (e is Edge<NodeAnchor>)
{
//find the edge
var localEdge = (Edge<NodeAnchor>) e;
var edge = graph.currentGraph.edges.FirstOrDefault(x => x.fromSlot == localEdge.Left.m_Slot && x.toSlot == localEdge.Right.m_Slot);
graph.currentGraph.RemoveEdge(edge);
}
e.ParentCanvas().ReloadData();
Debug.Log("Connecting: " + a + " " + b);
var pixelGraph = graph.currentGraph;
pixelGraph.Connect(a.m_Slot, b.m_Slot);
//m_Elements.Add();
}
}

3
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialWindow.cs


#define DEBUG_MAT_GEN
using UnityEditor.Experimental;
using UnityEditor.Graphs;
using UnityEngine;
namespace UnityEditor.MaterialGraph

}
private MaterialGraph m_MaterialGraph;
private Canvas2D m_Canvas = null;
private EditorWindow m_HostWindow = null;
private MaterialGraphDataSource m_DataSource;

211
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/SimpleWidgets.cs


namespace UnityEditor.MaterialGraph
{
public class SimpleBox : CanvasElement
{
protected string m_Title = "simpleBox";
public SimpleBox(Vector2 position, float width)
{
translation = position;
scale = new Vector2(width, width);
}
{
protected string m_Title = "simpleBox";
public SimpleBox(Vector2 position, float width)
{
translation = position;
scale = new Vector2(width, width);
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.7f);
Color selectedColor = new Color(1.0f, 0.7f, 0.0f, 0.7f);
EditorGUI.DrawRect(new Rect(0, 0, scale.x, scale.y), selected ? selectedColor : backgroundColor );
GUI.Label(new Rect(0, 0, scale.x, 26f), GUIContent.none, new GUIStyle("preToolbar"));
GUI.Label(new Rect(10, 2, scale.x - 20.0f, 16.0f), m_Title, EditorStyles.toolbarTextField);
base.Render(parentRect, canvas);
}
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.7f);
Color selectedColor = new Color(1.0f, 0.7f, 0.0f, 0.7f);
EditorGUI.DrawRect(new Rect(0, 0, scale.x, scale.y), selected ? selectedColor : backgroundColor);
GUI.Label(new Rect(0, 0, scale.x, 26f), GUIContent.none, new GUIStyle("preToolbar"));
GUI.Label(new Rect(10, 2, scale.x - 20.0f, 16.0f), m_Title, EditorStyles.toolbarTextField);
base.Render(parentRect, canvas);
}
}
{
public MoveableBox(Vector2 position, float width)
: base(position,width)
{
m_Title = "Drag me!";
AddManipulator(new Draggable());
}
{
public MoveableBox(Vector2 position, float width)
: base(position, width)
{
m_Title = "Drag me!";
AddManipulator(new Draggable());
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
}
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
}
}
internal class ResizableBox : SimpleBox
{
public ResizableBox(Vector2 position, float width)
: base(position, width)
{
m_Title = "Resize me!";
AddManipulator(new Resizable());
AddManipulator(new Draggable());
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
}
}
class ResizableBox : SimpleBox
{
public ResizableBox(Vector2 position, float width)
: base(position, width)
{
m_Title = "Resize me!";
AddManipulator(new Resizable());
AddManipulator(new Draggable());
}
internal class WWWImageBox : SimpleBox
{
private Texture2D m_WWWTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
private WWW www = null;
private float timeToNextPicture = 0.0f;
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
}
}
public WWWImageBox(Vector2 position, float width)
: base(position, width)
{
m_Title = "I cause repaints every frame!";
AddManipulator(new Draggable());
}
class WWWImageBox : SimpleBox
{
Texture2D m_WWWTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
WWW www = null;
private float timeToNextPicture = 0.0f;
public override void Render(Rect parentRect, Canvas2D canvas)
{
if (www != null && www.isDone)
{
www.LoadImageIntoTexture(m_WWWTexture);
www = null;
timeToNextPicture = 3.0f;
}
public WWWImageBox(Vector2 position, float width)
: base(position, width)
{
m_Title = "I cause repaints every frame!";
AddManipulator(new Draggable());
}
timeToNextPicture -= Time.deltaTime;
if (timeToNextPicture < 0.0f)
{
timeToNextPicture = 99999.0f;
www = new WWW("http://lorempixel.com/200/200");
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
if (www != null && www.isDone)
{
www.LoadImageIntoTexture(m_WWWTexture);
www = null;
timeToNextPicture = 3.0f;
}
base.Render(parentRect, canvas);
timeToNextPicture -= Time.deltaTime;
if (timeToNextPicture < 0.0f)
{
timeToNextPicture = 99999.0f;
www = new WWW("http://lorempixel.com/200/200");
}
GUI.DrawTexture(new Rect(0, 20, 200, 200), m_WWWTexture);
Invalidate();
canvas.Repaint();
}
}
base.Render(parentRect, canvas);
internal class IMGUIControls : SimpleBox
{
private string m_Text1 = "this is a text field";
private string m_Text2 = "this is a text field";
private bool m_Toggle = true;
private Texture2D m_aTexture = null;
GUI.DrawTexture(new Rect(0, 20, 200, 200), m_WWWTexture);
Invalidate();
canvas.Repaint();
}
}
public IMGUIControls(Vector2 position, float width)
: base(position, width)
{
m_Caps = Capabilities.Unselectable;
class IMGUIControls : SimpleBox
{
private string m_Text1 = "this is a text field";
private string m_Text2 = "this is a text field";
private bool m_Toggle = true;
private Texture2D m_aTexture = null;
m_Title = "modal";
AddManipulator(new Draggable());
AddManipulator(new Resizable());
AddManipulator(new IMGUIContainer());
}
public IMGUIControls(Vector2 position, float width)
: base(position, width)
{
m_Caps = Capabilities.Unselectable;
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
m_Title = "modal";
AddManipulator(new Draggable());
AddManipulator(new Resizable());
AddManipulator(new IMGUIContainer());
}
int currentY = 22;
public override void Render(Rect parentRect, Canvas2D canvas)
{
base.Render(parentRect, canvas);
m_Text1 = GUI.TextField(new Rect(0, currentY, 80, 20), m_Text1);
currentY += 22;
int currentY = 22;
m_Text1 = GUI.TextField(new Rect(0, currentY, 80, 20), m_Text1);
currentY += 22;
m_Toggle = GUI.Toggle(new Rect(0, currentY, 10, 10), m_Toggle, GUIContent.none);
currentY += 22;
m_Toggle = GUI.Toggle(new Rect(0, currentY, 10, 10), m_Toggle, GUIContent.none);
currentY += 22;
m_Text2 = GUI.TextField(new Rect(0, currentY, 80, 20), m_Text2);
currentY += 22;
m_Text2 = GUI.TextField(new Rect(0, currentY, 80, 20), m_Text2);
currentY += 22;
m_aTexture = EditorGUI.ObjectField(new Rect(0, currentY, 80, 100), m_aTexture, typeof(Texture2D), false) as Texture2D;
m_aTexture = EditorGUI.ObjectField(new Rect(0, currentY, 80, 100), m_aTexture, typeof (Texture2D), false) as Texture2D;
}
}
}
}
}

152
UnityProject/Assets/UnityShaderEditor/Graphs/GlowMud.ShaderGraph


style: node
position:
serializedVersion: 2
x: -576
y: 672
width: 178
height: 80
x: -1045.8572
y: 737.28
width: 647.8572
height: 14.719971
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -516
y: 840
width: 213
height: 137
x: -1196.1097
y: 825.244
width: 893.10974
height: 151.75598
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -264
y: 852
width: 74
height: 117
x: -928.06067
y: 823.10236
width: 738.06067
height: 145.89764
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -876
y: -120
width: 74
height: 105
x: -2742.6306
y: -1199.2351
width: 1940.6306
height: 1184.2351
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -144
y: 624
width: 74
height: 141
x: -597.85693
y: 693.82404
width: 527.85693
height: 71.175964
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -312
y: 444
width: 74
height: 129
x: -1043.565
y: 284.78897
width: 805.56494
height: 288.21103
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 504
y: 192
width: 213
height: 137
x: 92.87264
y: -13.563602
width: 624.1274
height: 342.5636
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -576
y: 540
width: 178
height: 80
x: -1043.2306
y: 660.08527
width: 645.2306
height: -40.085266
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 240
y: -312
width: 213
height: 139
x: -286.00098
y: -539.7324
width: 739.00104
height: 366.73242
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 420
y: 516
width: 74
height: 141
x: 594.5603
y: 421.239
width: -100.5603
height: 235.76099
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -984
y: 0
width: 178
height: 80
x: -2537.4495
y: -1141.3364
width: 1731.4495
height: 1221.3364
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 240
y: 132
width: 213
height: 139
x: -279.95486
y: 240.82782
width: 732.9549
height: 30.172058
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -588
y: 360
width: 213
height: 139
x: -1317.91
y: 200.78899
width: 942.91003
height: 298.211
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -744
y: -60
width: 74
height: 141
x: -2128.9863
y: -1195.1257
width: 1458.9863
height: 1276.1259
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 240
y: 552
width: 74
height: 129
x: 210.07529
y: 694.14197
width: 103.92471
height: -13.141968
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 240
y: -156
width: 213
height: 139
x: -286.00098
y: -383.7324
width: 739.00104
height: 366.7324
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 240
y: -12
width: 213
height: 139
x: -286.00098
y: -239.73224
width: 739.00104
height: 366.73224
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -24
y: 636
width: 213
height: 137
x: -186.0918
y: 758.19226
width: 375.09174
height: 14.807739
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -660
y: 864
width: 74
height: 105
x: -1498.3367
y: 824.0602
width: 912.3367
height: 144.93982
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

96
UnityProject/Assets/UnityShaderEditor/Graphs/LayeredTarp.ShaderGraph


style: node
position:
serializedVersion: 2
x: 144
y: 360
width: 213
height: 139
x: 293.37222
y: 467.4137
width: 63.62796
height: 31.586304
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 948
y: -36
width: 74
height: 161
x: 286.73352
y: 151.97438
width: 735.2665
height: -26.974396
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 0, y: 0, z: 0, w: 0}

style: node
position:
serializedVersion: 2
x: -36
y: 72
width: 74
height: 141
x: -1063.1451
y: -241.84991
width: 1101.145
height: 454.85022
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 144
y: 504
width: 213
height: 139
x: 293.37222
y: 611.4138
width: 63.62796
height: 31.586182
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 144
y: 216
width: 213
height: 139
x: -544.1203
y: 155.57974
width: 901.1207
height: 199.42026
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 744
y: -132
width: 74
height: 141
x: 5.5296288
y: -130.32156
width: 812.4704
height: 139.32155
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 540
y: -180
width: 74
height: 129
x: -473.71893
y: -176.64322
width: 1087.7189
height: 125.64322
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -276
y: 84
width: 178
height: 80
x: -1492.7986
y: -85.51249
width: 1394.7986
height: 249.51251
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: -180
y: -72
width: 74
height: 105
x: -1502.5343
y: -365.70996
width: 1396.5343
height: 398.70993
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 540
y: -48
width: 58
height: 80
x: -243.78564
y: -68.14007
width: 841.78564
height: 100.14006
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 624
y: 600
width: 213
height: 137
x: 843.8631
y: 633.56647
width: -6.863098
height: 103.43353
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

style: node
position:
serializedVersion: 2
x: 144
y: 72
width: 213
height: 139
x: -748.8779
y: -176.39458
width: 1105.8782
height: 387.39478
showEmptySlots: 1
m_SlotDefaultValues:
- m_DefaultVector: {x: 1, y: 1, z: 1, w: 1}

5
UnityProject/ProjectSettings/GraphicsSettings.asset


- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_ShaderSettings:
useScreenSpaceShadows: 1
m_BuildTargetShaderSettings: []
m_FogStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDirSeparate: 1

m_FogStripping: 0
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1

2
UnityProject/ProjectSettings/ProjectSettings.asset


defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_ShowUnitySplashScreen: 1
m_VirtualRealitySplashScreen: {fileID: 0}
defaultScreenWidth: 1024
defaultScreenHeight: 768
defaultScreenWidthWeb: 960

iPadHighResPortraitSplashScreen: {fileID: 0}
iPadLandscapeSplashScreen: {fileID: 0}
iPadHighResLandscapeSplashScreen: {fileID: 0}
appleTVSplashScreen: {fileID: 0}
iOSLaunchScreenType: 0
iOSLaunchScreenPortrait: {fileID: 0}
iOSLaunchScreenLandscape: {fileID: 0}

2
UnityProject/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.3.0b2
m_EditorVersion: 5.3.0b5
m_StandardAssetsVersion: 0

59
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MyNodeAdapters.cs


using UnityEditor.Experimental.Graph;
using UnityEngine;
namespace UnityEditor.MaterialGraph
{
internal class PortSource<T>
{
}
internal static class MyNodeAdapters
{
internal static bool Adapt(this NodeAdapter value, PortSource<int> a, PortSource<int> b)
{
// run adapt code for int to int connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<float> a, PortSource<float> b)
{
// run adapt code for float to float connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<int> a, PortSource<float> b)
{
// run adapt code for int to float connections, perhaps by insertion a conversion node
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Vector3> a, PortSource<Vector3> b)
{
// run adapt code for vec3 to vec3 connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Color> a, PortSource<Color> b)
{
// run adapt code for Color to Color connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Vector3> a, PortSource<Color> b)
{
// run adapt code for vec3 to Color connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Vector4> a, PortSource<Vector4> b)
{
// run adapt code for vec3 to Color connections
return true;
}
internal static bool Adapt(this NodeAdapter value, PortSource<Color> a, PortSource<Vector3> b)
{
// run adapt code for Color to vec3 connections
return true;
}
}
}

12
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MyNodeAdapters.cs.meta


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

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


using System;
using UnityEditor.Experimental;
using UnityEditor.Experimental.Graph;
using UnityEditor.Graphs;
using UnityEngine;
namespace UnityEditor.MaterialGraph
{
public class NodeAnchor : CanvasElement, IConnect
{
protected Type m_Type;
protected object m_Source;
protected Direction m_Direction;
private MaterialGraphDataSource m_Data;
public Slot m_Slot;
public NodeAnchor(Vector3 position, Type type, Slot slot, MaterialGraphDataSource data)
{
m_Type = type;
scale = new Vector3(15.0f, 15.0f, 1.0f);
translation = position;
AddManipulator(new EdgeConnector<NodeAnchor>());
m_Direction = Direction.eInput;
Type genericClass = typeof (PortSource<>);
Type constructedClass = genericClass.MakeGenericType(type);
m_Source = Activator.CreateInstance(constructedClass);
m_Data = data;
m_Slot = slot;
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
var anchorColor = Color.yellow;
anchorColor.a = 0.7f;
base.Render(parentRect, canvas);
EditorGUI.DrawRect(new Rect(translation.x, translation.y, scale.x, scale.y), anchorColor);
Rect labelRect = new Rect(translation.x + scale.x + 10.0f, translation.y, parentRect.width, 20.0f);
GUI.Label(labelRect, m_Slot.name);
}
// IConnect
public Direction GetDirection()
{
return m_Direction;
}
public void Highlight(bool highlighted)
{
}
public void RenderOverlay(Canvas2D canvas)
{
Rect thisRect = canvasBoundingRect;
thisRect.x += 4;
thisRect.y += 4;
thisRect.width -= 8;
thisRect.height -= 8;
thisRect = canvas.CanvasToScreen(thisRect);
EditorGUI.DrawRect(thisRect, new Color(0.0f, 0.0f, 0.8f));
}
public object Source()
{
return m_Source;
}
public Vector3 ConnectPosition()
{
return canvasBoundingRect.center;
}
public void OnConnect(IConnect other)
{
if (other == null)
return;
NodeAnchor otherAnchor = other as NodeAnchor;
m_Data.Connect(this, otherAnchor);
ParentCanvas().ReloadData();
}
};
}

12
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeAnchor.cs.meta


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

30
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeOutputAnchor.cs


using System;
using UnityEditor.Experimental;
using UnityEditor.Experimental.Graph;
using UnityEditor.Graphs;
using UnityEngine;
namespace UnityEditor.MaterialGraph
{
public class NodeOutputAnchor : NodeAnchor
{
public NodeOutputAnchor(Vector3 position, Type type, Slot slot, MaterialGraphDataSource data)
: base(position, type, slot, data)
{
m_Direction = Direction.eOutput;
}
public override void Render(Rect parentRect, Canvas2D canvas)
{
var anchorColor = Color.yellow;
anchorColor.a = 0.7f;
base.Render(parentRect, canvas);
EditorGUI.DrawRect(new Rect(translation.x, translation.y, scale.x, scale.y), anchorColor);
Vector2 sizeOfText = GUIStyle.none.CalcSize(new GUIContent(m_Type.Name));
Rect labelRect = new Rect(translation.x - sizeOfText.x - 4.0f, translation.y, sizeOfText.x + 4.0f, sizeOfText.y + 4.0f);
GUI.Label(labelRect, m_Slot.name);
}
};
}

12
UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/NodeOutputAnchor.cs.meta


fileFormatVersion: 2
guid: 7d206272c8dc0c942a9bf61ccf1310dd
timeCreated: 1445503903
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存