浏览代码

Merge branch 'master' into node-bugfixes

/main
Matt Dean 7 年前
当前提交
9c0b93c1
共有 20 个文件被更改,包括 296 次插入226 次删除
  1. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  2. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs
  3. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs
  4. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardField.cs
  5. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs
  6. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/EdgeConnectorListener.cs
  7. 59
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs
  8. 82
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs
  9. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
  10. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
  11. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/SerializationTests.cs
  12. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/CopyPasteGraph.cs
  13. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs
  14. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs.meta
  15. 40
      MaterialGraphProject/Assets/Vector1PropGraph.ShaderGraph
  16. 7
      MaterialGraphProject/Assets/Vector1PropGraph.ShaderGraph.meta
  17. 65
      MaterialGraphProject/Assets/TestAssets/RockMaterial1.sbsar.meta
  18. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs.meta
  19. 53
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/PropertyControl.cs

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


public virtual void OnAfterDeserialize()
{
// have to deserialize 'globals' before nodes
m_Properties = SerializationHelper.Deserialize<IShaderProperty>(m_SerializedProperties, null);
m_Properties = SerializationHelper.Deserialize<IShaderProperty>(m_SerializedProperties, GraphUtil.GetLegacyTypeRemapping());
var nodes = SerializationHelper.Deserialize<INode>(m_SerializableNodes, GraphUtil.GetLegacyTypeRemapping());
m_Nodes = new List<AbstractMaterialNode>(nodes.Count);
m_NodeDictionary = new Dictionary<Guid, INode>(nodes.Count);

m_SerializableNodes = null;
m_Edges = SerializationHelper.Deserialize<IEdge>(m_SerializableEdges, null);
m_Edges = SerializationHelper.Deserialize<IEdge>(m_SerializableEdges, GraphUtil.GetLegacyTypeRemapping());
m_SerializableEdges = null;
foreach (var edge in m_Edges)
AddEdgeToNodeEdges(edge);

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs


else
m_Guid = Guid.NewGuid();
m_Slots = SerializationHelper.Deserialize<ISlot>(m_SerializableSlots, null);
m_Slots = SerializationHelper.Deserialize<ISlot>(m_SerializableSlots, GraphUtil.GetLegacyTypeRemapping());
m_SerializableSlots = null;
foreach (var s in m_Slots)
s.owner = this;

17
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs


if (property is Vector1ShaderProperty)
{
AddSlot(new Vector1MaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, 0));
AddSlot(new Vector1MaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, 0));
AddSlot(new Vector2MaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector2MaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector3MaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, Vector4.zero));
AddSlot(new Vector4MaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, Vector4.zero));
AddSlot(new Texture2DMaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output));
AddSlot(new Texture2DMaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output));
AddSlot(new CubemapMaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output));
AddSlot(new CubemapMaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output));
AddSlot(new BooleanMaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, false));
AddSlot(new BooleanMaterialSlot(OutputSlotId, property.displayName, "Out", SlotType.Output, false));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
}

}
}
[PropertyControl]
public Guid propertyGuid
{
get { return m_PropertyGuid; }

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardField.cs


activeFieldInfo.SetValue(m_SelectionDropper, false);
this.AddManipulator(m_SelectionDropper);
var contextualMenuManipulator = (IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu);
this.AddManipulator(contextualMenuManipulator);
this.AddManipulator((IManipulator)Activator.CreateInstance(s_ContextualMenuManipulator, (Action<ContextualMenuPopulateEvent>)BuildContextualMenu));
}
void BuildContextualMenu(ContextualMenuPopulateEvent evt)

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Blackboard/BlackboardProvider.cs


moveItemRequested = MoveItemRequested
};
m_WindowDraggable = new WindowDraggable();
m_WindowDraggable = new WindowDraggable(blackboard.shadow.Children().First().Q("header"));
blackboard.AddManipulator(m_WindowDraggable);
m_ResizeBorderFrame = new ResizeBorderFrame(blackboard) { name = "resizeBorderFrame" };

var property = visualElement.userData as IShaderProperty;
if (property == null)
return;
m_Graph.owner.RegisterCompleteObjectUndo("Move Property");
m_Graph.MoveShaderProperty(property, newIndex);
}

var property = (IShaderProperty)field.userData;
if (newText != property.displayName)
{
m_Graph.owner.RegisterCompleteObjectUndo("Edit Property Name");
property.displayName = newText;
field.text = newText;
DirtyNodes();

{
field.RenameGo();
row.expanded = true;
m_Graph.owner.RegisterCompleteObjectUndo("Create Property");
m_Graph.AddShaderProperty(property);
}
}

foreach (var node in m_Graph.GetNodes<PropertyNode>())
{
node.OnEnable();
}
}
}
}

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/EdgeConnectorListener.cs


using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.Graphing;
using UnityEngine;
using Edge = UnityEditor.Experimental.UIElements.GraphView.Edge;

59
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs


using System;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

bool m_Active;
bool m_DockLeft;
bool m_DockTop;
WindowDockingLayout m_WindowDockingLayout;
VisualElement m_Handle;
public WindowDraggable(bool resizeWithParentwindow = false)
public WindowDraggable(VisualElement handle = null, bool resizeWithParentwindow = false)
m_Handle = handle;
m_WindowDockingLayout = new WindowDockingLayout();
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
if (m_Handle == null)
m_Handle = target;
m_Handle.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
m_Handle.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture);
m_Handle.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture);
m_LocalMosueOffset = target.WorldToLocal(evt.mousePosition);
m_LocalMosueOffset = m_Handle.WorldToLocal(evt.mousePosition);
target.TakeMouseCapture();
evt.StopPropagation();
m_Handle.TakeMouseCapture();
evt.StopImmediatePropagation();
}
void OnMouseMove(MouseMoveEvent evt)

}
}
void OnMouseUp(MouseUpEvent evt)
{
bool emitDragFinishedEvent = m_Active;

if (target.HasMouseCapture())
if (m_Handle.HasMouseCapture())
target.ReleaseMouseCapture();
m_Handle.ReleaseMouseCapture();
evt.StopPropagation();
evt.StopImmediatePropagation();
RefreshDocking();
m_WindowDockingLayout.CalculateDockingCornerAndOffset(target.layout, target.parent.layout);
if (emitDragFinishedEvent && OnDragFinished != null)
{

void RefreshDocking()
{
Vector2 windowCenter = new Vector2(target.layout.x + target.layout.width * .5f, target.layout.y + target.layout.height * .5f);
windowCenter /= target.parent.layout.size;
m_DockLeft = windowCenter.x < .5f;
m_DockTop = windowCenter.y < .5f;
}
void InitialLayoutSetup(PostLayoutEvent postLayoutEvent)
{
m_PreviousParentRect = target.parent.layout;

RefreshDocking();
m_WindowDockingLayout.CalculateDockingCornerAndOffset(target.layout, target.parent.layout);
}
void OnPostLayout(PostLayoutEvent postLayoutEvent)

}
Vector2 distanceFromParentEdge = Vector2.zero;
distanceFromParentEdge.x = m_DockLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width);
distanceFromParentEdge.y = m_DockTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height);
distanceFromParentEdge.x = m_WindowDockingLayout.dockingLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width);
distanceFromParentEdge.y = m_WindowDockingLayout.dockingTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height);
Vector2 normalizedDistanceFromEdge = distanceFromParentEdge / m_PreviousParentRect.size;

normalizedDistanceFromEdge = distanceFromParentEdge / target.parent.layout.size;
}
if (m_DockLeft)
if (m_WindowDockingLayout.dockingLeft)
{
windowRect.x = normalizedDistanceFromEdge.x * target.parent.layout.width;
}

}
if (m_DockTop)
if (m_WindowDockingLayout.dockingTop)
{
windowRect.y = normalizedDistanceFromEdge.y * target.parent.layout.height;
}

82
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs


using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using INode = UnityEditor.Graphing.INode;
namespace UnityEditor.ShaderGraph.Drawing
{

public int compatibleSlotId;
}
List<int> m_Ids;
List<ISlot> m_Slots = new List<ISlot>();
public List<SearchTreeEntry> CreateSearchTree(SearchWindowContext context)

if (attrs != null && attrs.Length > 0)
{
var node = (AbstractMaterialNode) Activator.CreateInstance(type);
var compatibleSlotId = -1;
if (connectedPort != null)
{
compatibleSlotId = GetFirstCompatibleSlotId(node);
if (compatibleSlotId == -1)
continue;
}
nodeEntries.Add(new NodeEntry { title = attrs[0].title, node = node, compatibleSlotId = compatibleSlotId});
AddEntries(node, attrs[0].title, nodeEntries);
}
}
}

var asset = AssetDatabase.LoadAssetAtPath<MaterialSubGraphAsset>(AssetDatabase.GUIDToAssetPath(guid));
var node = Activator.CreateInstance<SubGraphNode>();
node.subGraphAsset = asset;
var compatibleSlotId = -1;
if (connectedPort != null)
{
compatibleSlotId = GetFirstCompatibleSlotId(node);
if (compatibleSlotId == -1)
continue;
}
nodeEntries.Add(new NodeEntry
{
title = new[] { "Sub-graph Assets", asset.name },
node = node,
compatibleSlotId = compatibleSlotId
});
var node = new SubGraphNode { subGraphAsset = asset };
AddEntries(node, new [] { "Sub-graph Assets", asset.name }, nodeEntries);
}
foreach (var property in m_Graph.properties)
{
var node = new PropertyNode();
var property1 = property;
node.owner = m_Graph;
node.propertyGuid = property1.guid;
node.owner = null;
AddEntries(node, new [] { "Properties", "Property: " + property.displayName }, nodeEntries);
}
// Sort the entries lexicographically by group then title with the requirement that items always comes before sub-groups in the same group.

return tree;
}
int GetFirstCompatibleSlotId(AbstractMaterialNode node)
void AddEntries(AbstractMaterialNode node, string[] title, List<NodeEntry> nodeEntries)
if (connectedPort == null)
{
nodeEntries.Add(new NodeEntry
{
node = node,
title = title,
compatibleSlotId = -1
});
return;
}
var hasSingleSlot = m_Slots.Count(s => s.isOutputSlot != connectedSlot.isOutputSlot) == 1;
m_Slots.RemoveAll(slot =>
{
var materialSlot = (MaterialSlot)slot;
return !materialSlot.IsCompatibleWith(connectedSlot);
});
if (hasSingleSlot && m_Slots.Count == 1)
{
nodeEntries.Add(new NodeEntry
{
node = node,
title = title,
compatibleSlotId = m_Slots.First().id
});
return;
}
var materialSlot = (MaterialSlot)slot;
if (materialSlot.IsCompatibleWith(connectedSlot))
var entryTitle = new string[title.Length];
title.CopyTo(entryTitle, 0);
entryTitle[entryTitle.Length - 1] += ": " + slot.displayName;
nodeEntries.Add(new NodeEntry
return materialSlot.id;
}
title = entryTitle,
node = node,
compatibleSlotId = slot.id
});
return -1;
}
public bool OnSelectEntry(SearchTreeEntry entry, SearchWindowContext context)

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


[Serializable]
class FloatingWindowsLayout
{
public Rect previewLayout;
public Rect blackboardLayout;
public WindowDockingLayout previewLayout = new WindowDockingLayout();
public WindowDockingLayout blackboardLayout = new WindowDockingLayout();
}
public class GraphEditorView : VisualElement, IDisposable

m_GraphView.graphViewChanged = GraphViewChanged;
m_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
string serializedWindowLayout = EditorUserSettings.GetConfigValue(m_FloatingWindowsLayoutKey);
if (!String.IsNullOrEmpty(serializedWindowLayout))
{
m_FloatingWindowsLayout = JsonUtility.FromJson<FloatingWindowsLayout>(serializedWindowLayout);
m_MasterPreviewView.layout = m_FloatingWindowsLayout.previewLayout;
if (m_FloatingWindowsLayout.blackboardLayout.width > 0)
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.blackboardLayout;
}
else
{
m_FloatingWindowsLayout = new FloatingWindowsLayout();
}
RegisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
}
m_SearchWindowProvider = ScriptableObject.CreateInstance<SearchWindowProvider>();

}
}
void ApplySerializewindowLayouts(PostLayoutEvent evt)
{
UnregisterCallback<PostLayoutEvent>(ApplySerializewindowLayouts);
m_FloatingWindowsLayoutKey = "UnityEditor.ShaderGraph.FloatingWindowsLayout";
string serializedWindowLayout = EditorUserSettings.GetConfigValue(m_FloatingWindowsLayoutKey);
if (!String.IsNullOrEmpty(serializedWindowLayout))
{
m_FloatingWindowsLayout = JsonUtility.FromJson<FloatingWindowsLayout>(serializedWindowLayout);
m_MasterPreviewView.layout = m_FloatingWindowsLayout.previewLayout.GetLayout(layout);
m_BlackboardProvider.blackboard.layout = m_FloatingWindowsLayout.blackboardLayout.GetLayout(layout);
}
else
{
m_FloatingWindowsLayout = new FloatingWindowsLayout();
}
}
m_FloatingWindowsLayout.previewLayout = m_MasterPreviewView.layout;
m_FloatingWindowsLayout.blackboardLayout = m_BlackboardProvider.blackboard.layout;
m_FloatingWindowsLayout.previewLayout.CalculateDockingCornerAndOffset(m_MasterPreviewView.layout, layout);
m_FloatingWindowsLayout.blackboardLayout.CalculateDockingCornerAndOffset(m_BlackboardProvider.blackboard.layout, layout);
string serializedWindowLayout = JsonUtility.ToJson(m_FloatingWindowsLayout);
EditorUserSettings.SetConfigValue(m_FloatingWindowsLayoutKey, serializedWindowLayout);

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


using System.Text;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
[ScriptedImporter(4, ShaderGraphImporter.ShaderGraphExtension)]
[ScriptedImporter(10, ShaderGraphImporter.ShaderGraphExtension)]
public class ShaderGraphImporter : ScriptedImporter
{
public const string ShaderGraphExtension = "shadergraph";

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/IntegrationTests/SerializationTests.cs


var serialized = SerializationHelper.Serialize<SimpleSerializeClass>(toSerialize);
Assert.AreEqual(1, serialized.Count);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, null);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, GraphUtil.GetLegacyTypeRemapping());
Assert.AreEqual(1, loaded.Count);
Assert.IsInstanceOf<SimpleSerializeClass>(loaded[0]);
loaded[0].AssertAsReference();

var serialized = SerializationHelper.Serialize<SimpleSerializeClass>(toSerialize);
Assert.AreEqual(3, serialized.Count);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, null);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, GraphUtil.GetLegacyTypeRemapping());
Assert.AreEqual(3, loaded.Count);
Assert.IsInstanceOf<SimpleSerializeClass>(loaded[0]);
Assert.IsInstanceOf<ChildClassA>(loaded[1]);

var serialized = SerializationHelper.Serialize<ITestInterface>(toSerialize);
Assert.AreEqual(3, serialized.Count);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, null);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(serialized, GraphUtil.GetLegacyTypeRemapping());
Assert.AreEqual(3, loaded.Count);
Assert.IsInstanceOf<SimpleSerializeClass>(loaded[0]);
Assert.IsInstanceOf<ChildClassA>(loaded[1]);

var serializedContainer = JsonUtility.ToJson(container, true);
var deserializedContainer = JsonUtility.FromJson<SerializationContainer>(serializedContainer);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(deserializedContainer.serializedElements, null);
var loaded = SerializationHelper.Deserialize<SimpleSerializeClass>(deserializedContainer.serializedElements, GraphUtil.GetLegacyTypeRemapping());
Assert.AreEqual(1, loaded.Count);
Assert.IsInstanceOf<SimpleSerializeClass>(loaded[0]);
loaded[0].AssertAsReference();

};
var serialized = SerializationHelper.Serialize<MaterialSlot>(toSerialize);
var loaded = SerializationHelper.Deserialize<MaterialSlot>(serialized, null);
var loaded = SerializationHelper.Deserialize<MaterialSlot>(serialized, GraphUtil.GetLegacyTypeRemapping());
Assert.AreEqual(2, loaded.Count);
Assert.IsInstanceOf<MaterialSlot>(loaded[0]);

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Util/CopyPasteGraph.cs


using System.Text;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph;
namespace UnityEditor.Graphing.Util
{

public void OnAfterDeserialize()
{
var nodes = SerializationHelper.Deserialize<INode>(m_SerializableNodes, null);
var nodes = SerializationHelper.Deserialize<INode>(m_SerializableNodes, GraphUtil.GetLegacyTypeRemapping());
var edges = SerializationHelper.Deserialize<IEdge>(m_SerializableEdges, null);
var edges = SerializationHelper.Deserialize<IEdge>(m_SerializableEdges, GraphUtil.GetLegacyTypeRemapping());
m_Edges.Clear();
foreach (var edge in edges)
m_Edges.Add(edge);

105
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs


using System;
using UnityEngine;
namespace UnityEditor.ShaderGraph.Drawing
{
[Serializable]
public class WindowDockingLayout
{
[SerializeField]
bool m_DockingLeft;
public bool dockingLeft
{
get { return m_DockingLeft; }
}
[SerializeField]
bool m_DockingTop;
public bool dockingTop
{
get { return m_DockingTop; }
}
[SerializeField]
float m_VerticalOffset;
public float verticalOffset
{
get { return m_VerticalOffset; }
}
[SerializeField]
float m_HorizontalOffset;
public float horizontalOffset
{
get { return m_HorizontalOffset; }
}
[SerializeField]
Vector2 m_Size;
public Vector2 size
{
get { return m_Size; }
}
public void CalculateDockingCornerAndOffset(Rect layout, Rect parentLayout)
{
Vector2 layoutCenter = new Vector2(layout.x + layout.width * .5f, layout.y + layout.height * .5f);
layoutCenter /= parentLayout.size;
m_DockingLeft = layoutCenter.x < .5f;
m_DockingTop = layoutCenter.y < .5f;
if (m_DockingLeft)
{
m_HorizontalOffset = layout.x;
}
else
{
m_HorizontalOffset = parentLayout.width - layout.x - layout.width;
}
if (m_DockingTop)
{
m_VerticalOffset = layout.y;
}
else
{
m_VerticalOffset = parentLayout.height - layout.y - layout.height;
}
m_Size = layout.size;
}
public Rect GetLayout(Rect parentLayout)
{
Rect layout = new Rect();
layout.size = size;
if (dockingLeft)
{
layout.x = horizontalOffset;
}
else
{
layout.x = parentLayout.width - size.x - horizontalOffset;
}
if (dockingTop)
{
layout.y = verticalOffset;
}
else
{
layout.y = parentLayout.height - size.y - verticalOffset;
}
return layout;
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/WindowDockingLayout.cs.meta


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

40
MaterialGraphProject/Assets/Vector1PropGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件

7
MaterialGraphProject/Assets/Vector1PropGraph.ShaderGraph.meta


fileFormatVersion: 2
guid: 7d765c30286182d4a9e23edbdaf01865
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

65
MaterialGraphProject/Assets/TestAssets/RockMaterial1.sbsar.meta


fileFormatVersion: 2
guid: b69a7e88e13e24260acb38513f619ff2
timeCreated: 1495753980
licenseType: Pro
SubstanceImporter:
serializedVersion: 5
materialInstances:
- serializedVersion: 16
name: RockMaterial1
prototypeName: RockMaterial1
shaderName:
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
shaderKeywords:
renderQueue: -1
lightmapFlags: 4
inputs: []
materialInformation:
serializedVersion: 5
offset: {x: 0, y: 0}
scale: {x: 1, y: 1}
generateMipmaps: 1
generateAllOutputs: 0
animationUpdateRate: 0
materialProperties:
serializedVersion: 3
texEnvs: []
floats: []
colors: []
textureParameters:
- name: RockMaterial1_basecolor
alphaSource: 6
filterMode: 1
aniso: 1
wrapMode: 0
- name: RockMaterial1_normal
alphaSource: 0
filterMode: 1
aniso: 1
wrapMode: 0
- name: RockMaterial1_metallic
alphaSource: 7
filterMode: 1
aniso: 1
wrapMode: 0
textureAssignments:
- shaderProp: _MainTex
material: {instanceID: 0}
baseUID: 779270956
- shaderProp: _BumpMap
material: {instanceID: 0}
baseUID: 779270958
- shaderProp: _MetallicGlossMap
material: {instanceID: 0}
baseUID: 779270954
buildTargetSettings:
- serializedVersion: 2
buildTarget:
textureWidth: 512
textureHeight: 512
textureFormat: 0
loadingBehavior: 1
deletedPrototypes: []
userData:
assetBundleName:
assetBundleVariant:

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


fileFormatVersion: 2
guid: bb1167be0ec94c0a849394d34df45a98
timeCreated: 1507819549

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


using System;
using System.Linq;
using System.Reflection;
using UnityEditor.Graphing;
using UnityEngine.Experimental.UIElements;
using UnityEditor.ShaderGraph;
namespace UnityEditor.ShaderGraph.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, INodeModificationListener
{
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(currentSelectedIndex, properties.Select(x => x.displayName).ToArray());
if (changeCheckScope.changed)
{
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
m_Node.propertyGuid = propertiesGUID[value];
}
}
}
public void OnNodeModified(ModificationScope scope)
{
Dirty(ChangeType.Repaint);
}
}
}

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

正在加载...
取消
保存