浏览代码

Add Comparison node

- Add boolean field for property list
- Fix missing ConcreteValueTypeToString entry
/main
Matt Dean 7 年前
当前提交
2ed31ce4
共有 7 个文件被更改,包括 160 次插入0 次删除
  1. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Implementation/NodeUtils.cs
  2. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
  3. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs
  4. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic.meta
  5. 131
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs
  6. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs.meta

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Implementation/NodeUtils.cs


{
switch (slotValue)
{
case ConcreteSlotValueType.Boolean:
return p.ToString();
case ConcreteSlotValueType.Vector1:
return p.ToString();
case ConcreteSlotValueType.Vector2:

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


UpdateNodeAfterDeserialization();
}
protected struct Boolean
{}
protected struct Vector1
{}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs


m_ValueAction = Vector3Field;
else if (property is Vector4ShaderProperty)
m_ValueAction = Vector4Field;
else if (property is BooleanShaderProperty)
m_ValueAction = BooleanField;
if (m_ValueAction != null)
{

{
var fProp = (Vector4ShaderProperty)property;
fProp.value = EditorGUILayout.Vector4Field("", fProp.value);
}
void BooleanField()
{
var fProp = (BooleanShaderProperty)property;
fProp.value = EditorGUILayout.Toggle(fProp.value);
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic.meta


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

131
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
public enum ComparisonType
{
Equal,
NotEqual,
Less,
LessOrEqual,
Greater,
GreaterOrEqual
};
[Title("Utility", "Logic", "Comparison")]
public class ComparisonNode : CodeFunctionNode
{
public ComparisonNode()
{
name = "Comparison";
}
[SerializeField]
private ComparisonType m_ComparisonType = ComparisonType.Equal;
[EnumControl("")]
public ComparisonType comparisonType
{
get { return m_ComparisonType; }
set
{
if (m_ComparisonType == value)
return;
m_ComparisonType = value;
Dirty(ModificationScope.Graph);
}
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod(string.Format("Unity_Comparison_{0}", comparisonType), BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Comparison_Equal(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A == B ? 1 : 0;
}
";
}
static string Unity_Comparison_NotEqual(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A != B ? 1 : 0;
}
";
}
static string Unity_Comparison_Less(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A < B ? 1 : 0;
}
";
}
static string Unity_Comparison_LessOrEqual(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A <= B ? 1 : 0;
}
";
}
static string Unity_Comparison_Greater(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A > B ? 1 : 0;
}
";
}
static string Unity_Comparison_GreaterOrEqual(
[Slot(0, Binding.None)] DynamicDimensionVector A,
[Slot(1, Binding.None)] DynamicDimensionVector B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A >= B ? 1 : 0;
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs.meta


fileFormatVersion: 2
guid: c66cc68d0d0862b4c8ddfc00093d0ae0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
正在加载...
取消
保存