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

55 行
1.5 KiB

using System;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{
[Serializable]
public class UVMaterialSlot : Vector2MaterialSlot, IMayRequireMeshUV
{
private UVChannel m_Channel = UVChannel.uv0;
public UVChannel channel
{
get { return m_Channel; }
set { m_Channel = value; }
}
public UVMaterialSlot()
{}
public UVMaterialSlot(int slotId, string displayName, string shaderOutputName, UVChannel channel,
ShaderStage shaderStage = ShaderStage.Dynamic, bool hidden = false)
: base(slotId, displayName, shaderOutputName, SlotType.Input, Vector2.zero, shaderStage, hidden)
{
this.channel = channel;
}
public override VisualElement InstantiateControl()
{
return new UVSlotControlView(this);
}
public override string GetDefaultValue(GenerationMode generationMode)
{
return string.Format("IN.{0}.xy", channel.GetUVName());
}
public bool RequiresMeshUV(UVChannel channel)
{
if (isConnected)
return false;
return m_Channel == channel;
}
public override void CopyValuesFrom(MaterialSlot foundSlot)
{
var slot = foundSlot as UVMaterialSlot;
if (slot != null)
channel = slot.channel;
}
}
}