浏览代码

Simplified More API (Sequence Length becomes abstract / Added Decimate Processor back

/main
Thomas ICHÉ 5 年前
当前提交
c87cb2e1
共有 5 个文件被更改,包括 106 次插入42 次删除
  1. 5
      ImageSequencer/Editor/Serialization/ProcessorBase.cs
  2. 71
      ImageSequencer/Editor/Serialization/Processors/AssembleProcessor.cs
  3. 5
      ImageSequencer/Editor/Serialization/Processors/BreakFlipbookProcessor.cs
  4. 55
      ImageSequencer/Editor/Serialization/Processors/DecimateProcessor.cs
  5. 12
      ImageSequencer/Editor/Serialization/Processors/DecimateProcessor.cs.meta

5
ImageSequencer/Editor/Serialization/ProcessorBase.cs


processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height);
}
public abstract bool OnInspectorGUI(bool changed, SerializedObject serializedObject);
public abstract bool OnCanvasGUI(ImageSequencerCanvas canvas);
public virtual bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
return false;
}
public abstract void Default();
}
}

71
ImageSequencer/Editor/Serialization/Processors/AssembleProcessor.cs


public int FlipbookNumV;
public AssembleMode Mode;
bool hasChanged = false;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/AssembleBlit.shader";
public override string processorName => "Assemble Flipbook";

}
}
public override int numU
{
get
{
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return FlipbookNumU * processor.InputSequence.numU;
case AssembleMode.VerticalSequence:
return processor.InputSequence.numU;
}
}
}
public override int numV => FlipbookNumV * processor.InputSequence.numV;
public override int sequenceLength
{
get
{
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return 1;
case AssembleMode.VerticalSequence:
return processor.InputSequence.length / FlipbookNumV;
}
}
}
public override void Default()
{
FlipbookNumU = 5;

}
}
public override int sequenceLength
{
get
{
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return 1;
case AssembleMode.VerticalSequence:
return processor.InputSequence.length / FlipbookNumV;
}
}
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
if (Event.current.type != EventType.Repaint)

GUI.color = Color.white;
return false;
}
public override int numU
{
get
{
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return FlipbookNumU * processor.InputSequence.numU;
case AssembleMode.VerticalSequence:
return processor.InputSequence.numU;
}
}
}
public override int numV => FlipbookNumV * processor.InputSequence.numV;
public override bool Process(int frame)
{

return true;
}
bool hasChanged = false;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{

5
ImageSequencer/Editor/Serialization/Processors/BreakFlipbookProcessor.cs


public override int sequenceLength => Mathf.Min(FlipbookNumU, processor.InputSequence.width) * Mathf.Min(FlipbookNumV, processor.InputSequence.height);
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
return false;
}
public override bool Process(int frame)
{
Texture texture = processor.InputSequence.RequestFrame(0).texture;

55
ImageSequencer/Editor/Serialization/Processors/DecimateProcessor.cs


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 => $"{name} (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;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/DecimateProcessor.cs.meta


fileFormatVersion: 2
guid: 35539f9025900914e96e7eb931166504
timeCreated: 1465476802
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存