浏览代码

Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017

/main
bfogerty 8 年前
当前提交
2df2cc2b
共有 6 个文件被更改,包括 70 次插入13 次删除
  1. 7
      MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs
  2. 2
      MaterialGraphProject/Assets/Matt/EyeMaster.ShaderGraph
  3. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ColorNodePresenter.cs
  4. 23
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs
  5. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs
  6. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs

7
MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs


UpdateNodeAfterDeserialization();
}
/* public override bool hasPreview
{
get { return true; }
}*/
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector1, Vector2.zero));

public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, PropertyChunk.HideState.Visible));
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, FloatPropertyChunk.FloatType.Toggle, PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

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

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ColorNodePresenter.cs


using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{

if (cNode == null)
return;
cNode.color = EditorGUILayout.ColorField("Color", cNode.color);
cNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), cNode.exposedState);
cNode.color = EditorGUILayout.ColorField(new GUIContent ("Color"), cNode.color, true, true, cNode.HDR, new ColorPickerHDRConfig(0f, 8f, 0.125f, 3f));
cNode.HDR = EditorGUILayout.Toggle("HDR", cNode.HDR);
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
return EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
}
}

23
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/ColorNode.cs


[Title("Input/Color")]
public class ColorNode : PropertyNode, IGeneratesBodyCode
{
[SerializeField]
[SerializeField]
private bool m_HDR;
[SerializeField]
public bool HDR
{
get { return m_HDR; }
set
{
if (m_HDR == value)
return;
m_HDR = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
public ColorNode()
{

public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new ColorPropertyChunk(propertyName, description, color, PropertyChunk.HideState.Visible));
visitor.AddShaderProperty(new ColorPropertyChunk(propertyName, description, color, m_HDR ? ColorPropertyChunk.ColorType.HDR : ColorPropertyChunk.ColorType.Default , PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/ColorPropertyChunk.cs


{
public class ColorPropertyChunk : PropertyChunk
{
public enum ColorType
{
Default,
HDR
}
private ColorType m_colorType;
public ColorPropertyChunk(string propertyName, string propertyDescription, Color defaultColor, HideState hideState)
public ColorPropertyChunk(string propertyName, string propertyDescription, Color defaultColor, ColorType colorType, HideState hideState)
m_colorType = colorType;
m_DefaultColor = defaultColor;
}

public override string GetPropertyString()
{
var result = new StringBuilder();
if(m_colorType == ColorType.HDR)
result.Append ("[HDR]");
result.Append(propertyName);
result.Append("(\"");
result.Append(propertyDescription);

31
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Util/FloatPropertyChunk.cs


{
public class FloatPropertyChunk : PropertyChunk
{
public enum FloatType
{
Float,
Toggle,
Range,
PowerSlider
}
private readonly FloatType m_FloatType;
private readonly Vector3 m_rangeValues = new Vector3(0f, 1f, 2f);
public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, HideState hideState)
: base(propertyName, propertyDescription, hideState)
{

public FloatPropertyChunk(string propertyName, string propertyDescription, float defaultValue, FloatType floatType, HideState hideState)
: base(propertyName, propertyDescription, hideState)
{
m_FloatType = floatType;
m_DefaultValue = defaultValue;
}
public float defaultValue
{
get { return m_DefaultValue; }

{
var result = new StringBuilder();
if (m_FloatType == FloatType.Toggle)
result.Append ("[Toggle]");
else if(m_FloatType == FloatType.PowerSlider)
result.Append ("[PowerSlider(" + m_rangeValues.z + ")]");
result.Append("\", Float) = ");
if (m_FloatType == FloatType.Float || m_FloatType == FloatType.Toggle) {
result.Append ("\", Float) = ");
}else if(m_FloatType == FloatType.Range || m_FloatType == FloatType.PowerSlider){
result.Append ("\", Range(");
result.Append (m_rangeValues.x + ", " + m_rangeValues.y);
result.Append (")) = ");
}
result.Append(defaultValue);
return result.ToString();
}
正在加载...
取消
保存