您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
46 行
1.7 KiB
46 行
1.7 KiB
using UnityEditor.Graphing;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Title("Input", "Scene", "Object")]
|
|
public sealed class ObjectNode : AbstractMaterialNode
|
|
{
|
|
const string kOutputSlotName = "Position";
|
|
const string kOutputSlot1Name = "Scale";
|
|
|
|
public const int OutputSlotId = 0;
|
|
public const int OutputSlot1Id = 1;
|
|
|
|
public ObjectNode()
|
|
{
|
|
name = "Object";
|
|
UpdateNodeAfterDeserialization();
|
|
}
|
|
|
|
public override string documentationURL
|
|
{
|
|
get { return "https://github.com/Unity-Technologies/ShaderGraph/wiki/Object-Node"; }
|
|
}
|
|
|
|
public override void UpdateNodeAfterDeserialization()
|
|
{
|
|
AddSlot(new Vector3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector3.zero));
|
|
AddSlot(new Vector3MaterialSlot(OutputSlot1Id, kOutputSlot1Name, kOutputSlot1Name, SlotType.Output, Vector3.zero));
|
|
RemoveSlotsNameNotMatching(new[] { OutputSlotId, OutputSlot1Id });
|
|
}
|
|
|
|
public override string GetVariableNameForSlot(int slotId)
|
|
{
|
|
switch (slotId)
|
|
{
|
|
case OutputSlot1Id:
|
|
return @"float3(length(float3(unity_ObjectToWorld[0].x, unity_ObjectToWorld[1].x, unity_ObjectToWorld[2].x)),
|
|
length(float3(unity_ObjectToWorld[0].y, unity_ObjectToWorld[1].y, unity_ObjectToWorld[2].y)),
|
|
length(float3(unity_ObjectToWorld[0].z, unity_ObjectToWorld[1].z, unity_ObjectToWorld[2].z)))";
|
|
default:
|
|
return "unity_ObjectToWorld._m03_m13_m23";
|
|
}
|
|
}
|
|
}
|
|
}
|