浏览代码

[Material Graph]Show slot default inputs in the inspector.

/main
Tim Cooper 8 年前
当前提交
e6b70122
共有 9 个文件被更改,包括 84 次插入21 次删除
  1. 9
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs
  2. 4
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs
  3. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NodeInspectors/AbstractNodeInspector.cs
  4. 23
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs
  5. 1
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs
  7. 27
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  8. 24
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
  9. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TextureNode.cs

9
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphDataSource.cs


[SerializeField]
private TitleBarDrawData m_TitleBar;
[SerializeField]
private EditorWindow m_Container;
public TitleBarDrawData titleBar
{
get { return m_TitleBar; }

UpdateData();
EditorUtility.SetDirty(graphAsset.GetScriptableObject());
if (m_Container != null)
m_Container.Repaint();
}
private void UpdateData()

protected abstract void AddTypeMappings(Action<Type, Type> map);
public virtual void Initialize(IGraphAsset graphAsset)
public virtual void Initialize(IGraphAsset graphAsset, EditorWindow container)
m_Container = container;
m_TitleBar = CreateInstance<TitleBarDrawData>();
m_TitleBar.Initialize(graphAsset);

4
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/AbstractGraphEditWindow.cs


void OnEnable()
{
var source = CreateDataSource();
source.Initialize(m_LastSelection);
source.Initialize(m_LastSelection, this);
m_GraphEditorDrawer = new GraphEditorDrawer(CreateGraphView(), source);
rootVisualContainer.AddChild(m_GraphEditorDrawer);

var source = CreateDataSource();
source.Initialize(m_LastSelection);
source.Initialize(m_LastSelection, this);
m_GraphEditorDrawer.dataSource = source;
//m_GraphView.StretchToParentSize();

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NodeInspectors/AbstractNodeInspector.cs


public INode node { get; private set; }
public virtual void OnInspectorGUI()
{
}
{}
public virtual void Initialize(SerializableNode node)
{

23
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs


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

{
GUILayout.Label(node.name, EditorStyles.boldLabel);
GUILayout.Space(10);
var slots = node.GetInputSlots<MaterialSlot>().Where(x => x.showValue);
if (!slots.Any())
return;
GUILayout.Label("Default Slot Values", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
foreach (var slot in node.GetInputSlots<MaterialSlot>().Where(x => x.showValue))
slot.currentValue = EditorGUILayout.Vector4Field(slot.displayName, slot.currentValue);
if (EditorGUI.EndChangeCheck())
node.onModified(node, ModificationScope.Node);
GUILayout.Space(10);
}
}

1
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/SerializedGraphDataSource.cs


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

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SurfaceMasterNodeInspector.cs


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

var surfaceNode = node as AbstractSurfaceMasterNode;
if (surfaceNode == null)
return;
GUILayout.Label("Settings", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
options.srcBlend = (SurfaceMaterialOptions.BlendMode) EditorGUILayout.EnumPopup("Src Blend", options.srcBlend);
options.dstBlend = (SurfaceMaterialOptions.BlendMode) EditorGUILayout.EnumPopup("Dst Blend", options.dstBlend);
options.cullMode = (SurfaceMaterialOptions.CullMode) EditorGUILayout.EnumPopup("Cull Mode", options.cullMode);

options.renderType = (SurfaceMaterialOptions.RenderType) EditorGUILayout.EnumPopup("Render Type", options.renderType);
if (EditorGUI.EndChangeCheck())
node.onModified(node, ModificationScope.Node);
}
}

27
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs


set { m_OutputPrecision = value; }
}
[SerializeField]
private OutputPrecision m_OutputPrecision = OutputPrecision.half;
//[SerializeField]
private OutputPrecision m_OutputPrecision = OutputPrecision.@float;
// Nodes that want to have a preview area can override this and return true
public virtual bool hasPreview

}
}
public static PropertyType ConvertConcreteSlotValueTypeToPropertyType(ConcreteSlotValueType slotValue)
{
switch (slotValue)
{
case ConcreteSlotValueType.Vector1:
return PropertyType.Float;
case ConcreteSlotValueType.Vector2:
return PropertyType.Vector2;
case ConcreteSlotValueType.Vector3:
return PropertyType.Vector3;
case ConcreteSlotValueType.Vector4:
return PropertyType.Vector4;
default:
return PropertyType.Vector4;
}
}
/*
public virtual bool DrawSlotDefaultInput(Rect rect, MaterialSlot inputSlot)
{

var pp = new PreviewProperty
{
m_Name = GetVariableNameForSlot(s.id),
m_PropType = PropertyType.Vector4,
m_Vector4 = s.currentValue
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(s.concreteValueType),
m_Vector4 = s.currentValue,
m_Float = s.currentValue.x,
m_Color = s.currentValue
};
properties.Add(pp);
}

24
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs


[SerializeField]
private string m_ShaderOutputName;
[SerializeField]
private bool m_ShowValue;
public MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, SlotValueType valueType, Vector4 defaultValue, int priority)
: base(slotId, displayName, slotType, priority)
public MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, SlotValueType valueType, Vector4 defaultValue)
: base(slotId, displayName, slotType)
SharedInitialize(shaderOutputName, valueType, defaultValue);
SharedInitialize(shaderOutputName, valueType, true, defaultValue);
public MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, SlotValueType valueType, Vector4 defaultValue)
public MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, SlotValueType valueType, Vector4 defaultValue, bool usesDefaultValue)
SharedInitialize(shaderOutputName, valueType, defaultValue);
SharedInitialize(shaderOutputName, valueType, showValue, defaultValue);
private void SharedInitialize(string inShaderOutputName, SlotValueType inValueType, Vector4 inDefaultValue)
private void SharedInitialize(string inShaderOutputName, SlotValueType inValueType, bool usesDefaultValue, Vector4 inDefaultValue)
m_ShowValue = usesDefaultValue;
}
private static string ConcreteSlotValueTypeAsString(ConcreteSlotValueType type)

{
get { return m_ShaderOutputName; }
set { m_ShaderOutputName = value; }
}
public bool showValue
{
get { return m_ShowValue; }
set { m_ShowValue = value; }
}
public void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/TextureNode.cs


AddSlot(new MaterialSlot(OutputSlotGId, kOutputSlotGName, kOutputSlotGName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotBId, kOutputSlotBName, kOutputSlotBName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OutputSlotAId, kOutputSlotAName, kOutputSlotAName, SlotType.Output, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero));
AddSlot(new MaterialSlot(UvSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero, false));
RemoveSlotsNameNotMatching(validSlots);
}

正在加载...
取消
保存