您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

58 行
1.7 KiB

using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
interface IMayRequireMeshUV
{
bool RequiresMeshUV(UVChannel channel);
}
[Title("Input/UV Node")]
public class UVNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
{
public const int OutputSlotId = 0;
private const string kOutputSlotName = "UV";
[SerializeField]
private UVChannel m_OutputChannel;
public UVChannel uvChannel
{
get { return m_OutputChannel; }
set
{
if (m_OutputChannel == value)
return;
m_OutputChannel = value;
if (onModified != null)
{
onModified(this, ModificationScope.Graph);
}
}
}
public override bool hasPreview { get { return true; } }
public UVNode()
{
name = "UV";
UpdateNodeAfterDeserialization();
}
public override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForSlot(OutputSlotId) + " = " + m_OutputChannel.GetUVName() + ";", true);
}
public bool RequiresMeshUV(UVChannel channel)
{
return channel == uvChannel;
}
}
}