您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
45 行
1.2 KiB
45 行
1.2 KiB
using UnityEngine.Graphing;
|
|
|
|
namespace UnityEngine.MaterialGraph
|
|
{
|
|
public interface IMayRequireScreenPosition
|
|
{
|
|
bool RequiresScreenPosition();
|
|
}
|
|
|
|
[Title("Input/Screen Pos Node")]
|
|
public class ScreenPosNode : AbstractMaterialNode, IMayRequireScreenPosition
|
|
{
|
|
public ScreenPosNode()
|
|
{
|
|
name = "ScreenPos";
|
|
UpdateNodeAfterDeserialization();
|
|
}
|
|
|
|
private const int kOutputSlotId = 0;
|
|
private const string kOutputSlotName = "ScreenPos";
|
|
|
|
public override bool hasPreview { get { return true; } }
|
|
public override PreviewMode previewMode
|
|
{
|
|
get { return PreviewMode.Preview2D; }
|
|
}
|
|
|
|
|
|
public sealed override void UpdateNodeAfterDeserialization()
|
|
{
|
|
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero));
|
|
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
|
|
}
|
|
|
|
public override string GetVariableNameForSlot(int slotId)
|
|
{
|
|
return ShaderGeneratorNames.ScreenPosition;
|
|
}
|
|
|
|
public bool RequiresScreenPosition()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|