浏览代码

Remap node fix, beginning of toggle node

/main
Andre McGrail 8 年前
当前提交
503b7b62
共有 11 个文件被更改,包括 159 次插入19 次删除
  1. 2
      MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
  2. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs
  4. 9
      MaterialGraphProject/Assets/Andre/Editor.meta
  5. 82
      MaterialGraphProject/Assets/Andre/ToggleNode.cs
  6. 8
      MaterialGraphProject/Assets/Andre/ToggleNode.cs.meta
  7. 44
      MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs
  8. 12
      MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs.meta
  9. 9
      MaterialGraphProject/Assets/Matt&Andre.meta
  10. 9
      MaterialGraphProject/Assets/Matt.meta

2
MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter);
typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodePresenter);
typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter);
typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter);
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter);
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter);
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter);

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs


public RemapNode ()
{
name = "Remap";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()

9
MaterialGraphProject/Assets/Andre/Editor.meta


fileFormatVersion: 2
guid: bed9a49249fc34bf8adec9aaca294542
folderAsset: yes
timeCreated: 1495545513
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

82
MaterialGraphProject/Assets/Andre/ToggleNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("Input/Toggle")]
public class ToggleNode : PropertyNode, IGeneratesBodyCode
{
[SerializeField]
private float m_Float;
private const int kOutputSlotId = 0;
private const string kOutputSlotName = "Ouput";
public ToggleNode()
{
name = "Toggle";
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));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override PropertyType propertyType
{
get { return PropertyType.Float; }
}
public float value
{
get { return m_Float; }
set
{
if (m_Float == value)
return;
m_Float = value;
if (onModified != null)
{
onModified(this, ModificationScope.Node);
}
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed)
visitor.AddShaderProperty(new FloatPropertyChunk(propertyName, description, 0f, PropertyChunk.HideState.Visible));
}
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
visitor.AddShaderChunk(precision + " " + propertyName + ";", true);
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
return;
visitor.AddShaderChunk(value.ToString (), true);
}
public override PreviewProperty GetPreviewProperty()
{
return new PreviewProperty
{
m_Name = propertyName,
m_PropType = PropertyType.Float,
m_Float = value
};
}
}
}

8
MaterialGraphProject/Assets/Andre/ToggleNode.cs.meta


fileFormatVersion: 2
guid: fccc54ac137a8451d8011f29847e63b1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

44
MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing
{
[Serializable]
class ToggleNodeControlPresenter : GraphControlPresenter
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var cNode = node as BlendModeNode;
if (cNode == null)
return;
cNode.blendMode = (BlendModesEnum)EditorGUILayout.EnumPopup("", cNode.blendMode);
}
/* public override float GetHeight()
{
return EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
*/
public override float GetHeight()
{
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class ToggleNodePresenter : MaterialNodePresenter
{
protected override IEnumerable<GraphElementPresenter> GetControlData()
{
var instance = CreateInstance<ToggleNodeControlPresenter>();
instance.Initialize(node);
return new List<GraphElementPresenter> { instance };
}
}
}

12
MaterialGraphProject/Assets/Andre/Editor/ToggleNodePresenter.cs.meta


fileFormatVersion: 2
guid: 55391b421fcbe4e60bf16325132025ff
timeCreated: 1495456482
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Matt&Andre.meta


fileFormatVersion: 2
guid: 07096cbe059c94e42b244abc3e875ccf
folderAsset: yes
timeCreated: 1495475979
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
MaterialGraphProject/Assets/Matt.meta


fileFormatVersion: 2
guid: d44a270dca2589e4bb89c277d87ac0d9
folderAsset: yes
timeCreated: 1495475979
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存