public void Invalidate(FrameProcessor processor) { int index = m_Processors.IndexOf(processor); if (index != -1) { m_Processors[index].Invalidate(); } }
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 ProcessingFrameSequence GetInputSequence(FrameProcessor processor) { int index = m_Processors.IndexOf(processor); if (index > 0) { return(m_Processors[index - 1].OutputSequence); } else { return(m_InputSequence); } }
public virtual void Invalidate() { UpdateSequenceLength(); SetOutputSize(GetOutputWidth(), GetOutputHeight()); m_OutputSequence.InvalidateAll(); FrameProcessor next = m_ProcessorStack.GetNextProcessor(this); if (next != null) { next.Invalidate(); } }
/// <summary> /// Restores the visibility and lock of processors (on load or after an undo) /// </summary> public void RestoreProcessorView() { if (m_CurrentAsset.inheritSettingsReference != null && !m_IgnoreInheritSettings) { if (m_processorStack.processors.Count > 0) { if (m_CurrentAsset.editSettings.selectedProcessor > 0) { m_CurrentProcessor = m_processorStack.processors[m_CurrentAsset.editSettings.selectedProcessor]; m_ProcessorsReorderableList.index = m_CurrentAsset.editSettings.selectedProcessor; } } } else { // index Checks m_CurrentAsset.editSettings.lockedProcessor = Mathf.Clamp(m_CurrentAsset.editSettings.lockedProcessor, -1, m_processorStack.processors.Count - 1); m_CurrentAsset.editSettings.selectedProcessor = Mathf.Clamp(m_CurrentAsset.editSettings.selectedProcessor, -1, m_processorStack.processors.Count - 1); // Locked processor if (m_CurrentAsset.editSettings.lockedProcessor != -1) { m_ProcessorsReorderableList.index = m_CurrentAsset.editSettings.lockedProcessor; m_LockedPreviewProcessor = m_processorStack.processors[m_CurrentAsset.editSettings.lockedProcessor]; m_CurrentProcessor = m_processorStack.processors[m_CurrentAsset.editSettings.lockedProcessor]; } else { m_LockedPreviewProcessor = null; } // Selected Processor if (m_CurrentAsset.editSettings.selectedProcessor != -1) { m_ProcessorsReorderableList.index = m_CurrentAsset.editSettings.selectedProcessor; if (m_CurrentAsset.editSettings.lockedProcessor != -1) { m_CurrentProcessor = m_processorStack.processors[m_CurrentAsset.editSettings.lockedProcessor]; } else { m_CurrentProcessor = m_processorStack.processors[m_CurrentAsset.editSettings.selectedProcessor]; } } } m_processorStack.InvalidateAll(); RefreshCanvas(); }
public void AddProcessor(FrameProcessor processor, ImageSequence asset) { AddProcessorInfoObjectToAsset(asset, processor.ProcessorInfo); asset.processorInfos.Add(processor.ProcessorInfo); ProcessorSettingsBase settings = processor.GetSettingsAbstract(); if (settings != null) { AddSettingsObjectToAsset(asset, settings); processor.ProcessorInfo.Settings = settings; } m_Processors.Add(processor); EditorUtility.SetDirty(asset); }
public void SetCurrentFrameProcessor(FrameProcessor processor, bool wantLock) { if (wantLock) { m_LockedPreviewProcessor = processor; if (processor != null) { Undo.RecordObject(m_CurrentAsset, "Lock Processor"); m_CurrentProcessor = processor; m_CurrentAsset.editSettings.lockedProcessor = m_processorStack.processors.IndexOf(processor); } else { Undo.RecordObject(m_CurrentAsset, "Unlock Processor"); if (m_ProcessorsReorderableList.index != -1) { m_CurrentProcessor = m_processorStack.processors[Mathf.Min(m_ProcessorsReorderableList.index, m_processorStack.processors.Count - 1)]; } m_CurrentAsset.editSettings.lockedProcessor = -1; } } else { bool needChange = (m_CurrentProcessor != processor); if (needChange) { Undo.RecordObject(m_CurrentAsset, "Select Processor"); } if (m_LockedPreviewProcessor == null) { m_CurrentProcessor = processor; } else { m_CurrentProcessor = m_LockedPreviewProcessor; } } m_CurrentAsset.editSettings.selectedProcessor = m_processorStack.processors.IndexOf(processor); RefreshCanvas(); EditorUtility.SetDirty(m_CurrentAsset); }
public void AddProcessor(ProcessorElement element) { var settingType = element.m_ProcessorSettingType; // Add Element Undo.RecordObject(m_CurrentAsset, "Add Processor"); FrameProcessor processor = null; // Reflection Stuff here ProcessorAttribute attribute = m_processorStack.settingsDefinitions[settingType]; Type processorType = attribute.processorType; var info = ProcessorInfo.CreateDefault(attribute.name, true, settingType); processor = (FrameProcessor)Activator.CreateInstance(processorType, m_processorStack, info); if (processor != null) { m_processorStack.AddProcessor(processor, m_CurrentAsset); m_processorStack.InvalidateAll(); } }
private void DrawExportPanelContent() { int length = m_processorStack.outputSequence.length; if (length > 0) { m_CurrentAssetSerializedObject.Update(); EditorGUI.BeginChangeCheck(); ImageSequence.ExportSettings prevState = m_CurrentAsset.exportSettings; using (new VFXToolboxGUIUtility.HeaderSectionScope("File Export Options")) { ImageSequence.ExportMode prevMode = m_CurrentAsset.exportSettings.exportMode; m_CurrentAsset.exportSettings.exportMode = (ImageSequence.ExportMode)EditorGUILayout.Popup(VFXToolboxGUIUtility.Get("Export Format"), (int)m_CurrentAsset.exportSettings.exportMode, GetExportModeFriendlyNames()); if (prevMode != m_CurrentAsset.exportSettings.exportMode) { m_CurrentAsset.exportSettings.fileName = ""; } switch (m_CurrentAsset.exportSettings.exportMode) { case ImageSequence.ExportMode.EXR: m_CurrentAsset.exportSettings.highDynamicRange = true; m_CurrentAsset.exportSettings.sRGB = false; break; case ImageSequence.ExportMode.PNG: case ImageSequence.ExportMode.Targa: m_CurrentAsset.exportSettings.highDynamicRange = false; break; } EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField(VFXToolboxGUIUtility.Get("File Name|File name or pattern of the export sequence, using # characters will add frame number to the file name, use multiple ### to ensure leading zeroes."), m_CurrentAsset.exportSettings.fileName); EditorGUI.EndDisabledGroup(); Rect r = GUILayoutUtility.GetLastRect(); r.width += EditorGUIUtility.fieldWidth; if (Event.current.rawType == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { PingOutputTexture(m_CurrentAsset.exportSettings.fileName); } if (!m_CurrentAsset.exportSettings.highDynamicRange) { m_CurrentAsset.exportSettings.sRGB = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("sRGB (Color Data)|Whether the texture contains color (or not), HDR Data is always non sRGB."), m_CurrentAsset.exportSettings.sRGB); } EditorGUI.BeginDisabledGroup(m_CurrentAsset.exportSettings.compress && m_CurrentAsset.exportSettings.highDynamicRange); m_CurrentAsset.exportSettings.exportAlpha = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("Export Alpha|Whether to export the alpha channel"), m_CurrentAsset.exportSettings.exportAlpha); EditorGUI.EndDisabledGroup(); m_CurrentAsset.exportSettings.exportSeparateAlpha = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("Separate Alpha|Export the alpha channel as a separate TGA Grayscale file with a \"_alpha\" suffix."), m_CurrentAsset.exportSettings.exportSeparateAlpha); } using (new VFXToolboxGUIUtility.HeaderSectionScope("Texture Import Options")) { m_CurrentAsset.exportSettings.dataContents = (ImageSequence.DataContents)EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Import as|Sets the importer mode"), m_CurrentAsset.exportSettings.dataContents); if (m_CurrentAsset.exportSettings.dataContents == ImageSequence.DataContents.Sprite) { FrameProcessor p = m_processorStack.processors[m_processorStack.processors.Count - 1]; if (((float)p.OutputWidth % p.NumU) != 0 || ((float)p.OutputHeight % p.NumV) != 0) { EditorGUILayout.HelpBox("Warning : texture size is not a multiplier of rows (" + p.NumU + ") and columns (" + p.NumV + ") count, this will lead to incorrect rendering of the sprite animation", MessageType.Warning); } } switch (m_CurrentAsset.exportSettings.dataContents) { case ImageSequence.DataContents.NormalMapFromGrayscale: case ImageSequence.DataContents.NormalMap: m_CurrentAsset.exportSettings.sRGB = false; m_CurrentAsset.exportSettings.exportAlpha = false; break; default: break; } if (!m_CurrentAsset.exportSettings.highDynamicRange) { m_CurrentAsset.exportSettings.sRGB = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("sRGB (Color Data)|Whether the texture contains color (or not), HDR Data is always non sRGB."), m_CurrentAsset.exportSettings.sRGB); } m_CurrentAsset.exportSettings.compress = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("Compress|Whether to apply texture compression (HDR Compressed Data does not support alpha channel)"), m_CurrentAsset.exportSettings.compress); m_CurrentAsset.exportSettings.generateMipMaps = EditorGUILayout.Toggle(VFXToolboxGUIUtility.Get("Generate MipMaps|Whether generate mipmaps."), m_CurrentAsset.exportSettings.generateMipMaps); m_CurrentAsset.exportSettings.wrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Wrap Mode|Texture Wrap mode"), m_CurrentAsset.exportSettings.wrapMode); m_CurrentAsset.exportSettings.filterMode = (FilterMode)EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Filter Mode|Texture Filter mode"), m_CurrentAsset.exportSettings.filterMode); if (m_CurrentAsset.exportSettings.compress && m_CurrentAsset.exportSettings.highDynamicRange) { m_CurrentAsset.exportSettings.exportAlpha = false; } } if (GUILayout.Button("Export as New...", GUILayout.Height(24))) { string fileName = ""; fileName = ExportToFile(false); if (fileName != "") { m_CurrentAsset.exportSettings.fileName = fileName; m_CurrentAsset.exportSettings.frameCount = (ushort)m_processorStack.outputSequence.frames.Count; } } // Export Again if (m_CurrentAsset.exportSettings.fileName != null && ((m_CurrentAsset.exportSettings.fileName.EndsWith(".tga") && m_CurrentAsset.exportSettings.exportMode == ImageSequence.ExportMode.Targa) || (m_CurrentAsset.exportSettings.fileName.EndsWith(".exr") && m_CurrentAsset.exportSettings.exportMode == ImageSequence.ExportMode.EXR) || (m_CurrentAsset.exportSettings.fileName.EndsWith(".png") && m_CurrentAsset.exportSettings.exportMode == ImageSequence.ExportMode.PNG) )) { if (GUILayout.Button("Update Exported Assets", GUILayout.Height(24))) { UpdateExportedAssets(); } } if (m_CurrentAsset.exportSettings.dataContents == ImageSequence.DataContents.NormalMap) { EditorGUILayout.HelpBox("The selected import mode assumes that the frame data is a normal map. To generate a normal map from grayscale, use Normal Map From Grayscale instead.", MessageType.Info); } if (EditorGUI.EndChangeCheck()) { ImageSequence.ExportSettings curState = m_CurrentAsset.exportSettings; m_CurrentAsset.exportSettings = prevState; Undo.RecordObject(m_CurrentAsset, "Update Export Settings"); m_CurrentAsset.exportSettings = curState; m_CurrentAssetSerializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(m_CurrentAsset); AssetDatabase.Refresh(); } } else { EditorGUILayout.HelpBox("You do not have any frames to export.", MessageType.Warning); } }
public void LoadAsset(ImageSequence asset) { m_CurrentAsset = asset; m_InputFramesReorderableList = null; m_ProcessorsReorderableList = null; m_LockedPreviewProcessor = null; m_CurrentProcessor = null; // Free resources if any if (m_processorStack != null) { m_processorStack.Dispose(); } InitializeGUI(); if (m_CurrentAsset != null) { m_processorStack = new FrameProcessorStack(new ProcessingFrameSequence(null), this); m_CurrentAssetSerializedObject = new SerializedObject(m_CurrentAsset); VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Loading asset....", 0.0f); m_LockedPreviewProcessor = null; VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Loading Frames", 0.333333f); m_processorStack.LoadFramesFromAsset(m_CurrentAsset); UpdateInputTexturesHash(); m_InputFramesReorderableList = new ReorderableList(m_processorStack.inputSequence.frames, typeof(Texture2D), true, false, true, true); m_InputFramesReorderableList.onAddCallback = AddInputFrame; m_InputFramesReorderableList.onRemoveCallback = RemoveInputFrame; m_InputFramesReorderableList.onReorderCallback = ReorderInputFrame; m_InputFramesReorderableList.drawElementCallback = DrawInputFrameRListElement; m_InputFramesReorderableList.onSelectCallback = SelectInputFrameRListElement; VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Loading Processors", 0.66666f); ImageSequence inheritedSettingReference = m_CurrentAsset; // Loading other settings if inheriting settings if (m_CurrentAsset.inheritSettingsReference != null) { var dependencyList = new List <ImageSequence>(); var referenceAsset = FindSettingsReference(m_CurrentAsset.inheritSettingsReference, ref dependencyList); if (referenceAsset == null) { Debug.LogWarning("Dependency Loop detected, ignoring using external settings"); m_IgnoreInheritSettings = true; } else { inheritedSettingReference = referenceAsset; m_IgnoreInheritSettings = false; } } m_processorStack.LoadProcessorsFromAsset(inheritedSettingReference); m_ProcessorDataProvider = new ProcessorDataProvider(m_processorStack, m_CurrentAsset); // Construct the RList if (m_CurrentAsset.inheritSettingsReference == null) { m_ProcessorsReorderableList = new ReorderableList(m_CurrentAssetSerializedObject, m_CurrentAssetSerializedObject.FindProperty("processorInfos"), true, false, true, true); m_ProcessorsReorderableList.onAddCallback = ShowAddProcessorMenu; m_ProcessorsReorderableList.onRemoveCallback = MenuRemoveProcessor; m_ProcessorsReorderableList.onReorderCallback = ReorderProcessor; m_ProcessorsReorderableList.onSelectCallback = MenuSelectProcessor; m_ProcessorsReorderableList.drawElementCallback = DrawRListProcessorElement; m_SettingsReferenceSerializedObject = null; } else { m_SettingsReferenceSerializedObject = new SerializedObject(inheritedSettingReference); m_ProcessorsReorderableList = new ReorderableList(m_SettingsReferenceSerializedObject, m_SettingsReferenceSerializedObject.FindProperty("processorInfos"), false, false, false, false); m_ProcessorsReorderableList.drawElementCallback = DrawRListPreviewProcessorElement; m_ProcessorsReorderableList.onSelectCallback = MenuSelectProcessor; } m_PreviewCanvas.sequence = m_processorStack.inputSequence; if (m_PreviewCanvas.sequence.length > 0) { m_PreviewCanvas.currentFrameIndex = 0; } else { m_PreviewCanvas.currentFrameIndex = -1; } VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Finalizing...", 1.0f); m_processorStack.InvalidateAll(); RestoreProcessorView(); EditorUtility.ClearProgressBar(); } }
public ProcessingFrameSequence(FrameProcessor processor) { m_Frames = new List <ProcessingFrame>(); m_Processor = processor; }
public ProcessingFrame(FrameProcessor processor) { dirty = true; m_Processor = processor; ResetTexture(); }
public ProcessingFrame(Texture texture) { m_Texture = texture; dirty = false; m_Processor = null; }
private void MenuAddProcessor(object processorName) { Undo.RecordObject(m_CurrentAsset, "Add Processor : " + processorName); string name = (string)processorName; FrameProcessor processor = null; switch (name) { case "Break Flipbook": processor = new BreakFlipbookProcessor(m_processorStack, ProcessorInfo.CreateDefault <BreakFilpbookProcessorSettings>(name, true)); break; case "Crop": processor = new CropProcessor(m_processorStack, ProcessorInfo.CreateDefault <CropProcessorSettings>(name, true)); break; case "Rotate": processor = new RotateProcessor(m_processorStack, ProcessorInfo.CreateDefault <RotateProcessorSettings>(name, true)); break; case "Retime": processor = new RetimeProcessor(m_processorStack, ProcessorInfo.CreateDefault <RetimeProcessorSettings>(name, true)); break; case "Looping": processor = new LoopingProcessor(m_processorStack, ProcessorInfo.CreateDefault <LoopingProcessorSettings>(name, true)); break; case "Remove Background": processor = new RemoveBackgroundBlendingProcessor(m_processorStack, ProcessorInfo.CreateDefault <RemoveBackgroundSettings>(name, true)); break; case "Decimate": processor = new DecimateProcessor(m_processorStack, ProcessorInfo.CreateDefault <DecimateProcessorSettings>(name, true)); break; case "Fix Borders": processor = new FixBordersProcessor(m_processorStack, ProcessorInfo.CreateDefault <FixBordersProcessorSettings>(name, true)); break; case "Fade": processor = new FadeProcessor(m_processorStack, ProcessorInfo.CreateDefault <FadeProcessorSettings>(name, true)); break; case "Assemble Flipbook": processor = new AssembleProcessor(m_processorStack, ProcessorInfo.CreateDefault <AssembleProcessorSettings>(name, true)); break; case "Premultiply Alpha": processor = new PremultiplyAlphaProcessor(m_processorStack, ProcessorInfo.CreateDefault <PremultiplyAlphaProcessorSettings>(name, true)); break; case "Color Correction": processor = new ColorCorrectionProcessor(m_processorStack, ProcessorInfo.CreateDefault <ColorCorrectionProcessorSettings>(name, true)); break; case "Alpha From RGB": processor = new AlphaFromRGBProcessor(m_processorStack, ProcessorInfo.CreateDefault <AlphaFromRGBProcessorSettings>(name, true)); break; case "Remap Color": processor = new RemapColorProcessor(m_processorStack, ProcessorInfo.CreateDefault <RemapColorProcessorSettings>(name, true)); break; case "Resize": processor = new ResizeProcessor(m_processorStack, ProcessorInfo.CreateDefault <ResizeProcessorSettings>(name, true)); break; case "Custom Material": processor = new CustomMaterialProcessor(m_processorStack, ProcessorInfo.CreateDefault <CustomMaterialProcessorSettings>(name, true)); break; default: break; } if (processor != null) { m_processorStack.AddProcessor(processor, m_CurrentAsset); m_processorStack.InvalidateAll(); UpdateViewport(); } }