Thomas ICHÉ
5 年前
当前提交
baf245a1
共有 20 个文件被更改,包括 466 次插入 和 466 次删除
-
22ImageSequencer/Editor/FilterPopup/ProcessorDataProvider.cs
-
16ImageSequencer/Editor/ImageSequencer.Export.cs
-
46ImageSequencer/Editor/ImageSequencer.GUI.cs
-
26ImageSequencer/Editor/ImageSequencer.InputFrames.cs
-
68ImageSequencer/Editor/ImageSequencer.Processors.cs
-
66ImageSequencer/Editor/ImageSequencer.cs
-
10ImageSequencer/Editor/ImageSequencerCanvas.cs
-
22ImageSequencer/Editor/ProcessingFrame.cs
-
34ImageSequencer/Editor/ProcessingFrameSequence.cs
-
4ImageSequencer/Editor/Serialization/ProcessorBase.cs
-
2ImageSequencer/Editor/Serialization/Processors/CropProcessor.cs
-
24ImageSequencer/Editor/ProcessingNode.cs
-
157ImageSequencer/Editor/ProcessingNodeStack.Serialization.cs
-
139ImageSequencer/Editor/ProcessingNodeStack.cs
-
157ImageSequencer/Editor/FrameProcessorStack.Serialization.cs
-
139ImageSequencer/Editor/FrameProcessorStack.cs
-
0/ImageSequencer/Editor/ProcessingNode.cs.meta
-
0/ImageSequencer/Editor/ProcessingNodeStack.Serialization.cs.meta
-
0/ImageSequencer/Editor/ProcessingNodeStack.cs.meta
-
0/ImageSequencer/Editor/ProcessingNode.cs
|
|||
using UnityEngine; |
|||
using System; |
|||
using System.Reflection; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal partial class ProcessingNodeStack |
|||
{ |
|||
public void AddSettingsObjectToAsset(ImageSequence asset, ScriptableObject settings) |
|||
{ |
|||
AssetDatabase.AddObjectToAsset(settings,asset); |
|||
settings.hideFlags = HideFlags.HideInHierarchy; |
|||
} |
|||
|
|||
public void AddProcessorInfoObjectToAsset(ImageSequence asset, ProcessorInfo info) |
|||
{ |
|||
AssetDatabase.AddObjectToAsset(info,asset); |
|||
info.hideFlags = HideFlags.HideInHierarchy; |
|||
} |
|||
|
|||
public void RemoveAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Clear(); |
|||
m_InputSequence.frames.Clear(); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void SortAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Sort((guidA,guidB) => { |
|||
return string.Compare(AssetDatabase.GUIDToAssetPath(guidA), AssetDatabase.GUIDToAssetPath(guidB)); |
|||
}); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void ReverseAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Reverse(); |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void LoadFramesFromAsset(ImageSequence asset) |
|||
{ |
|||
inputSequence.frames.Clear(); |
|||
if (asset.inputFrameGUIDs != null && asset.inputFrameGUIDs.Count > 0) |
|||
{ |
|||
int count = asset.inputFrameGUIDs.Count; |
|||
int i = 1; |
|||
foreach (string guid in asset.inputFrameGUIDs) |
|||
{ |
|||
VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Loading Textures (" + i + "/" + count + ")", (float)i/count, 0.1f); |
|||
string path = AssetDatabase.GUIDToAssetPath(guid); |
|||
Texture2D t = AssetDatabase.LoadAssetAtPath<Texture2D>(path); |
|||
if (t != null) |
|||
{ |
|||
inputSequence.frames.Add(new ProcessingFrame(t)); |
|||
} |
|||
else |
|||
{ |
|||
inputSequence.frames.Add(ProcessingFrame.Missing); |
|||
} |
|||
i++; |
|||
} |
|||
VFXToolboxGUIUtility.ClearProgressBar(); |
|||
} |
|||
} |
|||
|
|||
public void SyncFramesToAsset(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Clear(); |
|||
foreach(ProcessingFrame f in inputSequence.frames) |
|||
{ |
|||
asset.inputFrameGUIDs.Add(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(f.texture))); |
|||
} |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void AddProcessor(ProcessingNode node, ImageSequence asset) |
|||
{ |
|||
AddProcessorInfoObjectToAsset(asset, node.ProcessorInfo); |
|||
asset.processorInfos.Add(node.ProcessorInfo); |
|||
|
|||
ProcessorBase settings = node.GetSettingsAbstract(); |
|||
if (settings != null) |
|||
{ |
|||
AddSettingsObjectToAsset(asset, settings); |
|||
node.ProcessorInfo.Settings = settings; |
|||
} |
|||
m_ProcessingNodes.Add(node); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void RemoveAllProcessors(ImageSequence asset) |
|||
{ |
|||
asset.processorInfos.Clear(); |
|||
m_ProcessingNodes.Clear(); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void RemoveProcessor(int index, ImageSequence asset) |
|||
{ |
|||
asset.processorInfos.RemoveAt(index); |
|||
m_ProcessingNodes.RemoveAt(index); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void ReorderProcessors(ImageSequence asset) |
|||
{ |
|||
if(m_ProcessingNodes.Count > 0) |
|||
{ |
|||
List<ProcessingNode> old = new List<ProcessingNode>(); |
|||
foreach(ProcessingNode n in m_ProcessingNodes) |
|||
{ |
|||
old.Add(n); |
|||
} |
|||
|
|||
m_ProcessingNodes.Clear(); |
|||
foreach(ProcessorInfo info in asset.processorInfos) |
|||
{ |
|||
foreach(ProcessingNode p in old) |
|||
{ |
|||
if(p.ProcessorInfo.Equals(info)) |
|||
{ |
|||
m_ProcessingNodes.Add(p); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
} |
|||
|
|||
public void LoadProcessorsFromAsset(ImageSequence asset) |
|||
{ |
|||
m_ProcessingNodes.Clear(); |
|||
|
|||
var infos = asset.processorInfos; |
|||
|
|||
UpdateProcessorsFromAssembly(); |
|||
|
|||
// Creating Runtime
|
|||
foreach(ProcessorInfo procInfo in infos) |
|||
{ |
|||
var processor = (ProcessingNode)Activator.CreateInstance(typeof(ProcessingNode), this, procInfo); |
|||
m_ProcessingNodes.Add(processor); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal partial class ProcessingNodeStack |
|||
{ |
|||
public ProcessingFrameSequence inputSequence |
|||
{ |
|||
get |
|||
{ |
|||
return m_InputSequence; |
|||
} |
|||
} |
|||
|
|||
public ProcessingFrameSequence outputSequence |
|||
{ |
|||
get |
|||
{ |
|||
if (m_ProcessingNodes.Count > 0) |
|||
return m_ProcessingNodes[m_ProcessingNodes.Count - 1].OutputSequence; |
|||
else |
|||
return m_InputSequence; |
|||
} |
|||
} |
|||
|
|||
public ImageSequencer imageSequencer |
|||
{ |
|||
get { return m_ImageSequencer; } |
|||
} |
|||
|
|||
public List<ProcessingNode> nodes |
|||
{ |
|||
get |
|||
{ |
|||
return m_ProcessingNodes; |
|||
} |
|||
} |
|||
|
|||
private List<ProcessingNode> m_ProcessingNodes; |
|||
private ProcessingFrameSequence m_InputSequence; |
|||
private ImageSequencer m_ImageSequencer; |
|||
|
|||
public ProcessingNodeStack(ProcessingFrameSequence inputSequence, ImageSequencer imageSequencer) |
|||
{ |
|||
m_InputSequence = inputSequence; |
|||
m_ProcessingNodes = new List<ProcessingNode>(); |
|||
m_ImageSequencer = imageSequencer; |
|||
|
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
foreach(ProcessingNode p in m_ProcessingNodes) |
|||
{ |
|||
p.Dispose(); |
|||
} |
|||
m_ProcessingNodes.Clear(); |
|||
} |
|||
|
|||
public ProcessingFrameSequence GetOutputSequence() |
|||
{ |
|||
if(m_ProcessingNodes.Count > 0) |
|||
{ |
|||
return m_ProcessingNodes[m_ProcessingNodes.Count - 1].OutputSequence; |
|||
} |
|||
else |
|||
{ |
|||
return inputSequence; |
|||
} |
|||
} |
|||
|
|||
public ProcessingFrameSequence GetInputSequence(ProcessingNode processor) |
|||
{ |
|||
int index = m_ProcessingNodes.IndexOf(processor); |
|||
|
|||
if (index > 0) |
|||
{ |
|||
return m_ProcessingNodes[index - 1].OutputSequence; |
|||
} |
|||
else |
|||
return m_InputSequence; |
|||
} |
|||
|
|||
public ProcessingNode GetNextProcessor(ProcessingNode node) |
|||
{ |
|||
int index = m_ProcessingNodes.IndexOf(node); |
|||
if(index < m_ProcessingNodes.Count-1) |
|||
{ |
|||
return m_ProcessingNodes[index + 1]; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public void Invalidate(ProcessingNode node) |
|||
{ |
|||
int index = m_ProcessingNodes.IndexOf(node); |
|||
if(index != -1) |
|||
m_ProcessingNodes[index].Invalidate(); |
|||
} |
|||
|
|||
public void InvalidateAll() |
|||
{ |
|||
if (m_ProcessingNodes.Count > 0) |
|||
m_ProcessingNodes[0].Invalidate(); |
|||
} |
|||
|
|||
|
|||
public Dictionary<Type, ProcessorAttribute> settingsDefinitions { get; private set; } |
|||
|
|||
public void UpdateProcessorsFromAssembly() |
|||
{ |
|||
settingsDefinitions = new Dictionary<Type, ProcessorAttribute>(); |
|||
|
|||
var assembly = Assembly.GetAssembly(typeof(ProcessorBase)); |
|||
var types = assembly.GetTypes(); |
|||
var processorType = typeof(ProcessorBase); |
|||
var attrType = typeof(ProcessorAttribute); |
|||
|
|||
var allProcessorTypes = types |
|||
.Where(t => t.IsClass |
|||
&& !t.IsAbstract |
|||
&& t.IsSubclassOf(processorType) |
|||
&& t.IsDefined(attrType, false)); |
|||
|
|||
foreach (var type in allProcessorTypes) |
|||
{ |
|||
var attr = (ProcessorAttribute)type.GetCustomAttributes(attrType, false)[0]; |
|||
|
|||
settingsDefinitions.Add(type, attr); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
} |
|
|||
using UnityEngine; |
|||
using System; |
|||
using System.Reflection; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal partial class FrameProcessorStack |
|||
{ |
|||
public void AddSettingsObjectToAsset(ImageSequence asset, ScriptableObject settings) |
|||
{ |
|||
AssetDatabase.AddObjectToAsset(settings,asset); |
|||
settings.hideFlags = HideFlags.HideInHierarchy; |
|||
} |
|||
|
|||
public void AddProcessorInfoObjectToAsset(ImageSequence asset, ProcessorInfo info) |
|||
{ |
|||
AssetDatabase.AddObjectToAsset(info,asset); |
|||
info.hideFlags = HideFlags.HideInHierarchy; |
|||
} |
|||
|
|||
public void RemoveAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Clear(); |
|||
m_InputSequence.frames.Clear(); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void SortAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Sort((guidA,guidB) => { |
|||
return string.Compare(AssetDatabase.GUIDToAssetPath(guidA), AssetDatabase.GUIDToAssetPath(guidB)); |
|||
}); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void ReverseAllInputFrames(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Reverse(); |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void LoadFramesFromAsset(ImageSequence asset) |
|||
{ |
|||
inputSequence.frames.Clear(); |
|||
if (asset.inputFrameGUIDs != null && asset.inputFrameGUIDs.Count > 0) |
|||
{ |
|||
int count = asset.inputFrameGUIDs.Count; |
|||
int i = 1; |
|||
foreach (string guid in asset.inputFrameGUIDs) |
|||
{ |
|||
VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Loading Textures (" + i + "/" + count + ")", (float)i/count, 0.1f); |
|||
string path = AssetDatabase.GUIDToAssetPath(guid); |
|||
Texture2D t = AssetDatabase.LoadAssetAtPath<Texture2D>(path); |
|||
if (t != null) |
|||
{ |
|||
inputSequence.frames.Add(new ProcessingFrame(t)); |
|||
} |
|||
else |
|||
{ |
|||
inputSequence.frames.Add(ProcessingFrame.Missing); |
|||
} |
|||
i++; |
|||
} |
|||
VFXToolboxGUIUtility.ClearProgressBar(); |
|||
} |
|||
} |
|||
|
|||
public void SyncFramesToAsset(ImageSequence asset) |
|||
{ |
|||
asset.inputFrameGUIDs.Clear(); |
|||
foreach(ProcessingFrame f in inputSequence.frames) |
|||
{ |
|||
asset.inputFrameGUIDs.Add(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(f.texture))); |
|||
} |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void AddProcessor(FrameProcessor processor, ImageSequence asset) |
|||
{ |
|||
AddProcessorInfoObjectToAsset(asset, processor.ProcessorInfo); |
|||
asset.processorInfos.Add(processor.ProcessorInfo); |
|||
|
|||
ProcessorBase settings = processor.GetSettingsAbstract(); |
|||
if (settings != null) |
|||
{ |
|||
AddSettingsObjectToAsset(asset, settings); |
|||
processor.ProcessorInfo.Settings = settings; |
|||
} |
|||
m_Processors.Add(processor); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void RemoveAllProcessors(ImageSequence asset) |
|||
{ |
|||
asset.processorInfos.Clear(); |
|||
m_Processors.Clear(); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void RemoveProcessor(int index, ImageSequence asset) |
|||
{ |
|||
asset.processorInfos.RemoveAt(index); |
|||
m_Processors.RemoveAt(index); |
|||
|
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
|
|||
public void ReorderProcessors(ImageSequence asset) |
|||
{ |
|||
if(m_Processors.Count > 0) |
|||
{ |
|||
List<FrameProcessor> old = new List<FrameProcessor>(); |
|||
foreach(FrameProcessor p in m_Processors) |
|||
{ |
|||
old.Add(p); |
|||
} |
|||
|
|||
m_Processors.Clear(); |
|||
foreach(ProcessorInfo info in asset.processorInfos) |
|||
{ |
|||
foreach(FrameProcessor p in old) |
|||
{ |
|||
if(p.ProcessorInfo.Equals(info)) |
|||
{ |
|||
m_Processors.Add(p); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
EditorUtility.SetDirty(asset); |
|||
} |
|||
} |
|||
|
|||
public void LoadProcessorsFromAsset(ImageSequence asset) |
|||
{ |
|||
m_Processors.Clear(); |
|||
|
|||
var infos = asset.processorInfos; |
|||
|
|||
UpdateProcessorsFromAssembly(); |
|||
|
|||
// Creating Runtime
|
|||
foreach(ProcessorInfo procInfo in infos) |
|||
{ |
|||
var processor = (FrameProcessor)Activator.CreateInstance(typeof(FrameProcessor), this, procInfo); |
|||
m_Processors.Add(processor); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal partial class FrameProcessorStack |
|||
{ |
|||
public ProcessingFrameSequence inputSequence |
|||
{ |
|||
get |
|||
{ |
|||
return m_InputSequence; |
|||
} |
|||
} |
|||
|
|||
public ProcessingFrameSequence outputSequence |
|||
{ |
|||
get |
|||
{ |
|||
if (m_Processors.Count > 0) |
|||
return m_Processors[m_Processors.Count - 1].OutputSequence; |
|||
else |
|||
return m_InputSequence; |
|||
} |
|||
} |
|||
|
|||
public ImageSequencer imageSequencer |
|||
{ |
|||
get { return m_ImageSequencer; } |
|||
} |
|||
|
|||
public List<FrameProcessor> processors |
|||
{ |
|||
get |
|||
{ |
|||
return m_Processors; |
|||
} |
|||
} |
|||
|
|||
private List<FrameProcessor> m_Processors; |
|||
private ProcessingFrameSequence m_InputSequence; |
|||
private ImageSequencer m_ImageSequencer; |
|||
|
|||
public FrameProcessorStack(ProcessingFrameSequence inputSequence, ImageSequencer imageSequencer) |
|||
{ |
|||
m_InputSequence = inputSequence; |
|||
m_Processors = new List<FrameProcessor>(); |
|||
m_ImageSequencer = imageSequencer; |
|||
|
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
foreach(FrameProcessor p in m_Processors) |
|||
{ |
|||
p.Dispose(); |
|||
} |
|||
m_Processors.Clear(); |
|||
} |
|||
|
|||
public ProcessingFrameSequence GetOutputSequence() |
|||
{ |
|||
if(m_Processors.Count > 0) |
|||
{ |
|||
return m_Processors[m_Processors.Count - 1].OutputSequence; |
|||
} |
|||
else |
|||
{ |
|||
return inputSequence; |
|||
} |
|||
} |
|||
|
|||
public ProcessingFrameSequence GetInputSequence(FrameProcessor processor) |
|||
{ |
|||
int index = m_Processors.IndexOf(processor); |
|||
|
|||
if (index > 0) |
|||
{ |
|||
return m_Processors[index - 1].OutputSequence; |
|||
} |
|||
else |
|||
return m_InputSequence; |
|||
} |
|||
|
|||
public FrameProcessor GetNextProcessor(FrameProcessor processor) |
|||
{ |
|||
int index = m_Processors.IndexOf(processor); |
|||
if(index < m_Processors.Count-1) |
|||
{ |
|||
return m_Processors[index + 1]; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public void Invalidate(FrameProcessor processor) |
|||
{ |
|||
int index = m_Processors.IndexOf(processor); |
|||
if(index != -1) |
|||
m_Processors[index].Invalidate(); |
|||
} |
|||
|
|||
public void InvalidateAll() |
|||
{ |
|||
if (m_Processors.Count > 0) |
|||
m_Processors[0].Invalidate(); |
|||
} |
|||
|
|||
|
|||
public Dictionary<Type, ProcessorAttribute> settingsDefinitions { get; private set; } |
|||
|
|||
public void UpdateProcessorsFromAssembly() |
|||
{ |
|||
settingsDefinitions = new Dictionary<Type, ProcessorAttribute>(); |
|||
|
|||
var assembly = Assembly.GetAssembly(typeof(ProcessorBase)); |
|||
var types = assembly.GetTypes(); |
|||
var processorType = typeof(ProcessorBase); |
|||
var attrType = typeof(ProcessorAttribute); |
|||
|
|||
var allProcessorTypes = types |
|||
.Where(t => t.IsClass |
|||
&& !t.IsAbstract |
|||
&& t.IsSubclassOf(processorType) |
|||
&& t.IsDefined(attrType, false)); |
|||
|
|||
foreach (var type in allProcessorTypes) |
|||
{ |
|||
var attr = (ProcessorAttribute)type.GetCustomAttributes(attrType, false)[0]; |
|||
|
|||
settingsDefinitions.Add(type, attr); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue