Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

59 行
2.0 KiB

using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[FormerName("UnityEngine.MaterialGraph.WorldPosNode")]
[Title("Input", "Geometry", "Position")]
class PositionNode : GeometryNode, IMayRequirePosition
{
private const int kOutputSlotId = 0;
public const string kOutputSlotName = "Out";
public override List<CoordinateSpace> validSpaces => new List<CoordinateSpace> {CoordinateSpace.Object, CoordinateSpace.View, CoordinateSpace.World, CoordinateSpace.Tangent, CoordinateSpace.AbsoluteWorld};
public PositionNode()
{
name = "Position";
precision = Precision.Float;
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new Vector3MaterialSlot(
kOutputSlotId,
kOutputSlotName,
kOutputSlotName,
SlotType.Output,
Vector3.zero));
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
}
public override int GetCompiledNodeVersion() => 1;
public override void UpgradeNodeWithVersion(int from, int to)
{
if (from == 0 && to == 1 && space == CoordinateSpace.World)
{
var names = validSpaces.Select(cs => cs.ToString().PascalToLabel()).ToArray();
spacePopup = new PopupList(names, (int)CoordinateSpace.AbsoluteWorld);
}
}
public override string GetVariableNameForSlot(int slotId)
{
return string.Format("IN.{0}", space.ToVariableName(InterpolatorType.Position));
}
public NeededCoordinateSpace RequiresPosition(ShaderStageCapability stageCapability)
{
return space.ToNeededCoordinateSpace();
}
}
}