浏览代码

Added input/output checking

/main
Jennifer Nordwall 8 年前
当前提交
2adf665a
共有 2 个文件被更改,包括 20 次插入0 次删除
  1. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  2. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs

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


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

typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter);
typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter);
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter);
}
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter)
{
return allChildren.OfType<NodeAnchorPresenter>()
.Where(nap => nap.IsConnectable() &&
nap.orientation == startAnchor.orientation &&
nap.direction != startAnchor.direction &&
nodeAdapter.GetAdapter(nap.source, startAnchor.source) != null &&
(startAnchor is GraphAnchorPresenter && ((GraphAnchorPresenter)nap).slot is MaterialSlot &&
((MaterialSlot)((GraphAnchorPresenter)startAnchor).slot).IsCompatibleWithInputSlotType(((MaterialSlot)((GraphAnchorPresenter)nap).slot).valueType)))
.ToList();
}
}
}

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


visitor.AddShaderChunk(matOwner.precision + AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(concreteValueType) + " " + matOwner.GetVariableNameForSlot(id) + ";", true);
}
public bool IsCompatibleWithInputSlotType(SlotValueType inputType)
{
return (inputType == SlotValueType.Dynamic || valueType == SlotValueType.Vector1 || valueType <= inputType);
}
public string GetDefaultValue(GenerationMode generationMode)
{
var matOwner = owner as AbstractMaterialNode;

正在加载...
取消
保存