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

55 行
1.7 KiB

using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Sequence","Decimate")]
internal class DecimateProcessor : ProcessorBase
{
public ushort DecimateBy;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Null.shader";
public override string label => $"{processorName} (1 of {DecimateBy})";
public override string processorName => "Decimate";
public override int sequenceLength => Mathf.Max(1, (int)Mathf.Floor((float)processor.InputSequence.length / DecimateBy));
public override void Default()
{
DecimateBy = 3;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var decimateBy = serializedObject.FindProperty("DecimateBy");
EditorGUI.BeginChangeCheck();
int newDecimate = Mathf.Clamp(EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Decimate by"), (int)DecimateBy), 2, processor.InputSequence.length);
if (newDecimate != decimateBy.intValue)
{
decimateBy.intValue = newDecimate;
}
if (EditorGUI.EndChangeCheck())
{
changed = true;
}
return changed;
}
public override bool Process(int frame)
{
int targetFrame = frame * DecimateBy;
Texture texture = processor.InputSequence.RequestFrame(targetFrame).texture;
processor.material.SetTexture("_MainTex", texture);
processor.ExecuteShaderAndDump(frame, texture);
return true;
}
}
}