浏览代码
Add support for setting default input values on material sub graphs (when editing the graph) so there is something to compare with.
/main
Add support for setting default input values on material sub graphs (when editing the graph) so there is something to compare with.
/main
Tim Cooper
8 年前
当前提交
17429180
共有 17 个文件被更改,包括 323 次插入 和 62 次删除
-
26MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs
-
9MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs
-
10MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphInspector.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MaterialGraphDataSource.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Remapper/MasterRemapInputNode.cs
-
39MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphInputNode.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphOutputNode.cs
-
43MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/SubgraphIONodeDrawData.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/SubgraphIONodeDrawData.cs.meta
-
85MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphInputNodeInspector.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphInputNodeInspector.cs.meta
-
76MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphOutputNodeInspector.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphOutputNodeInspector.cs.meta
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodeDrawers.7z
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/NodeDrawers.7z.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class SubgraphIONodeControlDrawData : ControlDrawData |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var ioNode = node as AbstractSubGraphIONode; |
|||
if (ioNode == null) |
|||
return; |
|||
|
|||
if (GUILayout.Button("Add Slot")) |
|||
ioNode.AddSlot(); |
|||
if (GUILayout.Button("Remove Slot")) |
|||
ioNode.RemoveSlot(); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class SubgraphIONodeDrawData : MaterialNodeDrawData |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<SubgraphIONodeControlDrawData>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b8c4dd0c197664d5ebf80f433981c6b4 |
|||
timeCreated: 1483804520 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.Graphing.Drawing |
|||
{ |
|||
public class SubgraphInputNodeInspector : BasicNodeInspector |
|||
{ |
|||
protected enum UISlotValueType |
|||
{ |
|||
Vector4, |
|||
Vector3, |
|||
Vector2, |
|||
Vector1 |
|||
} |
|||
|
|||
private static UISlotValueType ToUISlot(SlotValueType slot) |
|||
{ |
|||
switch (slot) |
|||
{ |
|||
case SlotValueType.Vector1: |
|||
return UISlotValueType.Vector1; |
|||
case SlotValueType.Vector2: |
|||
return UISlotValueType.Vector2; |
|||
case SlotValueType.Vector3: |
|||
return UISlotValueType.Vector3; |
|||
case SlotValueType.Vector4: |
|||
return UISlotValueType.Vector4; |
|||
} |
|||
return UISlotValueType.Vector4; |
|||
} |
|||
|
|||
private static SlotValueType ToSlotValueType(UISlotValueType slot) |
|||
{ |
|||
switch (slot) |
|||
{ |
|||
case UISlotValueType.Vector1: |
|||
return SlotValueType.Vector1; |
|||
case UISlotValueType.Vector2: |
|||
return SlotValueType.Vector2; |
|||
case UISlotValueType.Vector3: |
|||
return SlotValueType.Vector3; |
|||
case UISlotValueType.Vector4: |
|||
return SlotValueType.Vector4; |
|||
} |
|||
return SlotValueType.Vector4; |
|||
} |
|||
|
|||
protected override ModificationScope DoSlotsUI() |
|||
{ |
|||
var slots = node.GetSlots<MaterialSlot>().Where(x => x.showValue); |
|||
if (!slots.Any()) |
|||
return ModificationScope.Node; |
|||
|
|||
GUILayout.Label("Default Slot Values", EditorStyles.boldLabel); |
|||
|
|||
bool valueChanged = false; |
|||
bool typeChanged = false; |
|||
foreach (var slot in node.GetSlots<MaterialSlot>().Where(x => x.showValue)) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
GUILayout.Label(slot.displayName); |
|||
slot.currentValue = EditorGUILayout.Vector4Field("", slot.currentValue); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
valueChanged |= true; |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
var result = (UISlotValueType)EditorGUILayout.EnumPopup(ToUISlot(slot.valueType)); |
|||
slot.valueType = ToSlotValueType(result); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
typeChanged |= true; |
|||
} |
|||
|
|||
GUILayout.Space(10); |
|||
|
|||
if (typeChanged) |
|||
return ModificationScope.Topological; |
|||
if (valueChanged) |
|||
return ModificationScope.Node; |
|||
|
|||
return ModificationScope.Node; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cd0ffd0e21a6644488dda4d0470a30c6 |
|||
timeCreated: 1483808306 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Linq; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.Graphing.Drawing |
|||
{ |
|||
public class SubgraphOutputNodeInspector : BasicNodeInspector |
|||
{ |
|||
protected enum UISlotValueType |
|||
{ |
|||
Vector4, |
|||
Vector3, |
|||
Vector2, |
|||
Vector1 |
|||
} |
|||
|
|||
private static UISlotValueType ToUISlot(SlotValueType slot) |
|||
{ |
|||
switch (slot) |
|||
{ |
|||
case SlotValueType.Vector1: |
|||
return UISlotValueType.Vector1; |
|||
case SlotValueType.Vector2: |
|||
return UISlotValueType.Vector2; |
|||
case SlotValueType.Vector3: |
|||
return UISlotValueType.Vector3; |
|||
case SlotValueType.Vector4: |
|||
return UISlotValueType.Vector4; |
|||
} |
|||
return UISlotValueType.Vector4; |
|||
} |
|||
|
|||
private static SlotValueType ToSlotValueType(UISlotValueType slot) |
|||
{ |
|||
switch (slot) |
|||
{ |
|||
case UISlotValueType.Vector1: |
|||
return SlotValueType.Vector1; |
|||
case UISlotValueType.Vector2: |
|||
return SlotValueType.Vector2; |
|||
case UISlotValueType.Vector3: |
|||
return SlotValueType.Vector3; |
|||
case UISlotValueType.Vector4: |
|||
return SlotValueType.Vector4; |
|||
} |
|||
return SlotValueType.Vector4; |
|||
} |
|||
|
|||
protected override ModificationScope DoSlotsUI() |
|||
{ |
|||
var slots = node.GetSlots<MaterialSlot>().Where(x => x.showValue); |
|||
if (!slots.Any()) |
|||
return ModificationScope.Node; |
|||
|
|||
GUILayout.Label("Default Slot Values", EditorStyles.boldLabel); |
|||
|
|||
bool typeChanged = false; |
|||
foreach (var slot in node.GetSlots<MaterialSlot>().Where(x => x.showValue)) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
var result = (UISlotValueType)EditorGUILayout.EnumPopup(ToUISlot(slot.valueType)); |
|||
slot.valueType = ToSlotValueType(result); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
typeChanged |= true; |
|||
} |
|||
|
|||
GUILayout.Space(10); |
|||
|
|||
if (typeChanged) |
|||
return ModificationScope.Topological; |
|||
|
|||
return ModificationScope.Node; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0c7c4f1421dbb4c02a4a08f0ea8aec55 |
|||
timeCreated: 1483811239 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
7z��' �$�" |
|||
|