浏览代码

API Call Simplification

/main
Thomas ICHÉ 5 年前
当前提交
277b5678
共有 4 个文件被更改,包括 54 次插入56 次删除
  1. 26
      ImageSequencer/Editor/FrameProcessor.cs
  2. 22
      ImageSequencer/Editor/Serialization/ProcessorBase.cs
  3. 51
      ImageSequencer/Editor/Serialization/Processors/AssembleProcessor.cs
  4. 11
      ImageSequencer/Editor/Serialization/Processors/BreakFlipbookProcessor.cs

26
ImageSequencer/Editor/FrameProcessor.cs


{
get {
if (Enabled)
return m_Processor.GetNumU(this);
return m_Processor.numU;
else
return InputSequence.numU;
}

get {
if (Enabled)
return m_Processor.GetNumV(this);
return m_Processor.numV;
else
return InputSequence.numV;
}

Linear = true;
GenerateMipMaps = true;
settings.AttachTo(this);
}
public void SetEnabled(bool value)

if(Enabled != m_ProcessorInfo.Enabled)
Enabled = m_ProcessorInfo.Enabled;
UpdateSequenceLength();
m_Processor.UpdateOutputSize(this);
m_Processor.UpdateOutputSize();
m_Processor.UpdateOutputSize(this);
m_Processor.UpdateOutputSize();
m_Processor.UpdateOutputSize(this);
m_Processor.UpdateOutputSize();
return m_OutputHeight;
}
public void SetOutputSize(int width, int height)

using (new EditorGUI.DisabledScope(!Enabled))
{
m_SerializedObject.Update();
bHasChanged = m_Processor.OnInspectorGUI(bHasChanged, m_SerializedObject, this);
bHasChanged = m_Processor.OnInspectorGUI(bHasChanged, m_SerializedObject);
m_SerializedObject.ApplyModifiedProperties();
}

}
public bool Process(int frame)
{
return m_Processor.Process(this, frame);
return m_Processor.Process(frame);
public void ExecuteShaderAndDump(int outputframe, Texture mainTex)
{
ExecuteShaderAndDump(outputframe, mainTex, material);

}
public int GetProcessorSequenceLength()
{
return m_Processor.GetProcessorSequenceLength(this);
return m_Processor.sequenceLength;
public void UpdateSequenceLength()
{
int currentCount = m_OutputSequence.frames.Count;

}
}
}
public void Invalidate()
{
UpdateSequenceLength();

if(next != null)
next.Invalidate();
}
public ProcessorBase GetSettingsAbstract()
{
return settings;

22
ImageSequencer/Editor/Serialization/ProcessorBase.cs


public abstract string shaderPath { get; }
public abstract string processorName { get; }
public virtual string label => processorName;
public virtual int GetNumU(FrameProcessor processor) => 1;
public virtual int GetNumV(FrameProcessor processor) => 1;
public abstract bool Process(FrameProcessor processor, int frame);
public virtual void UpdateOutputSize(FrameProcessor processor)
protected FrameProcessor processor;
public void AttachTo(FrameProcessor processor)
processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height);
this.processor = processor;
public abstract int GetProcessorSequenceLength(FrameProcessor processor);
public abstract bool OnInspectorGUI(bool changed, SerializedObject serializedObject, FrameProcessor processor);
public virtual int numU => 1;
public virtual int numV => 1;
public virtual int sequenceLength => processor.InputSequence.length;
public abstract bool Process(int frame);
public virtual void UpdateOutputSize()
{
processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height);
}
public abstract bool OnInspectorGUI(bool changed, SerializedObject serializedObject);
}
}

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


Mode = AssembleMode.FullSpriteSheet;
}
public override void UpdateOutputSize(FrameProcessor processor)
public override void UpdateOutputSize()
{
switch (Mode)
{

processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height * FlipbookNumV);
break;
}
public override int GetProcessorSequenceLength(FrameProcessor processor)
public override int sequenceLength
switch (Mode)
get
default:
case AssembleMode.FullSpriteSheet:
return 1;
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return 1;
case AssembleMode.VerticalSequence:
return processor.InputSequence.length / FlipbookNumV;
case AssembleMode.VerticalSequence:
return processor.InputSequence.length / FlipbookNumV;
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{

return false;
}
public override int GetNumU(FrameProcessor processor)
public override int numU
switch (Mode)
get
default:
case AssembleMode.FullSpriteSheet:
return FlipbookNumU * processor.InputSequence.numU;
case AssembleMode.VerticalSequence:
return processor.InputSequence.numU;
switch (Mode)
{
default:
case AssembleMode.FullSpriteSheet:
return FlipbookNumU * processor.InputSequence.numU;
case AssembleMode.VerticalSequence:
return processor.InputSequence.numU;
}
public override int GetNumV(FrameProcessor processor)
{
return FlipbookNumV * processor.InputSequence.numV;
}
public override int numV => FlipbookNumV * processor.InputSequence.numV;
public override bool Process(FrameProcessor processor, int frame)
public override bool Process(int frame)
{
int length = processor.InputSequence.length;

bool hasChanged = false;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject, FrameProcessor processor)
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var flipbookNumU = serializedObject.FindProperty("FlipbookNumU");
var flipbookNumV = serializedObject.FindProperty("FlipbookNumV");

seq_flipbookNumV.intValue = seq_numV;
serializedObject.ApplyModifiedProperties();
UpdateOutputSize(processor);
UpdateOutputSize();
processor.Invalidate();
}
, value);

if (EditorGUI.EndChangeCheck())
{
UpdateOutputSize(processor);
UpdateOutputSize();
processor.Invalidate();
hasChanged = true;
}

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


FlipbookNumV = 5;
}
public override void UpdateOutputSize(FrameProcessor processor)
public override void UpdateOutputSize()
{
int width = (int)Mathf.Ceil((float)processor.InputSequence.RequestFrame(0).texture.width / FlipbookNumU);
int height = (int)Mathf.Ceil((float)processor.InputSequence.RequestFrame(0).texture.height / FlipbookNumV);

public override int GetProcessorSequenceLength(FrameProcessor processor)
{
return Mathf.Min(FlipbookNumU, processor.InputSequence.width) * Mathf.Min(FlipbookNumV, processor.InputSequence.height);
}
public override int sequenceLength => Mathf.Min(FlipbookNumU, processor.InputSequence.width) * Mathf.Min(FlipbookNumV, processor.InputSequence.height);
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{

public override bool Process(FrameProcessor processor, int frame)
public override bool Process(int frame)
{
Texture texture = processor.InputSequence.RequestFrame(0).texture;
processor.material.SetTexture("_MainTex", texture);

return true;
}
public override bool OnInspectorGUI(bool hasChanged, SerializedObject serializedObject, FrameProcessor processor)
public override bool OnInspectorGUI(bool hasChanged, SerializedObject serializedObject)
{
var flipbookNumU = serializedObject.FindProperty("FlipbookNumU");
var flipbookNumV = serializedObject.FindProperty("FlipbookNumV");

正在加载...
取消
保存