您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
40 行
1.1 KiB
40 行
1.1 KiB
using System.Reflection;
|
|
using UnityEngine;
|
|
using UnityEditor.Graphing;
|
|
|
|
namespace UnityEditor.ShaderGraph
|
|
{
|
|
[Title("UV/Flipbook")]
|
|
public class FlipbookNode : CodeFunctionNode
|
|
{
|
|
public FlipbookNode()
|
|
{
|
|
name = "Flipbook";
|
|
}
|
|
|
|
protected override MethodInfo GetFunctionToConvert()
|
|
{
|
|
return GetType().GetMethod("Unity_Flipbook", BindingFlags.Static | BindingFlags.NonPublic);
|
|
}
|
|
|
|
static string Unity_Flipbook(
|
|
[Slot(0, Binding.MeshUV0)] Vector2 UV,
|
|
[Slot(1, Binding.None, 1, 1, 1, 1)] Vector1 Width,
|
|
[Slot(2, Binding.None, 1, 1, 1, 1)] Vector1 Height,
|
|
[Slot(3, Binding.None)] Vector1 Tile,
|
|
[Slot(4, Binding.None)] out Vector2 Out)
|
|
{
|
|
Out = Vector2.zero;
|
|
|
|
return
|
|
@"
|
|
{
|
|
{precision}2 tileCount = {precision}2(1.0, 1.0) / {precision}2(Width, Height);
|
|
{precision} tileY = floor(Tile * tileCount.x);
|
|
{precision} tileX = Tile - Width * tileY;
|
|
Out = (UV + {precision}2(tileX, tileY)) * tileCount;
|
|
}
|
|
";
|
|
}
|
|
}
|
|
}
|