Ejemplo n.º 1
0
        public void RemoveAllInputFrames(ImageSequence asset)
        {
            asset.inputFrameGUIDs.Clear();
            m_InputSequence.frames.Clear();

            EditorUtility.SetDirty(asset);
        }
Ejemplo n.º 2
0
        public void RemoveAllProcessors(ImageSequence asset)
        {
            asset.processorInfos.Clear();
            m_ProcessingNodes.Clear();

            EditorUtility.SetDirty(asset);
        }
Ejemplo n.º 3
0
 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();
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        public void RemoveProcessor(int index, ImageSequence asset)
        {
            asset.processorInfos.RemoveAt(index);
            m_ProcessingNodes.RemoveAt(index);

            EditorUtility.SetDirty(asset);
        }
        public static void CleanupAsset(ImageSequence asset)
        {
            var           subAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(asset));
            List <Object> toDelete  = new List <Object>();

            var allSettings = asset.processorInfos.Select(i => i.Settings);

            foreach (var subAsset in subAssets)
            {
                if (subAsset is ProcessorInfo && !asset.processorInfos.Contains(subAsset))
                {
                    toDelete.Add(subAsset);
                }
                else if (subAsset is ProcessorBase && !allSettings.Contains(subAsset))
                {
                    toDelete.Add(subAsset);
                }
            }

            foreach (var o in toDelete)
            {
                AssetDatabase.RemoveObjectFromAsset(o);
            }

            if (toDelete.Count > 0)
            {
                EditorUtility.SetDirty(asset);
            }
        }
        public static ImageSequence CreateImageSequenceAtPath(string path)
        {
            ImageSequence asset = ScriptableObject.CreateInstance <ImageSequence>();

            asset.name = Path.GetFileName(path);
            AssetDatabase.CreateAsset(asset, path);
            return(asset);
        }
Ejemplo n.º 8
0
        public void SortAllInputFrames(ImageSequence asset)
        {
            asset.inputFrameGUIDs.Sort((guidA, guidB) => {
                return(string.Compare(AssetDatabase.GUIDToAssetPath(guidA), AssetDatabase.GUIDToAssetPath(guidB)));
            });

            EditorUtility.SetDirty(asset);
        }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
        public bool OnSidePanelGUI(ImageSequence asset, int ProcessorIndex)
        {
            bool bHasChanged = DrawSidePanelHeader();

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

            return(bHasChanged);
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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 static bool OpenImageSequenceAsset(int instanceID, int line)
        {
            ImageSequence asset = EditorUtility.InstanceIDToObject(instanceID) as ImageSequence;

            if (asset != null) // We opened an image sequence asset, open the editor.
            {
                ImageSequencer.OpenEditor();
                ImageSequencer window = EditorWindow.GetWindow <ImageSequencer>();
                window.Focus();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        private ImageSequence FindSettingsReference(ImageSequence asset, ref List <ImageSequence> dependencyList)
        {
            if (asset.inheritSettingsReference != null)
            {
                if (dependencyList.Contains(asset.inheritSettingsReference))
                {
                    return(null);
                }

                dependencyList.Add(asset.inheritSettingsReference);
                return(FindSettingsReference(asset.inheritSettingsReference, ref dependencyList));
            }
            else
            {
                return(asset);
            }
        }
Ejemplo n.º 15
0
        private void DrawProcessorsPanelContent()
        {
            ImageSequence seq = (ImageSequence)EditorGUILayout.ObjectField(VFXToolboxGUIUtility.Get("Inherit processors from"), m_CurrentAsset.inheritSettingsReference, typeof(ImageSequence), false);

            if (m_IgnoreInheritSettings)
            {
                EditorGUILayout.HelpBox("Warning : Dependency Loop found when inheriting these settings, ignoring...", MessageType.Warning);
            }

            if (seq != m_CurrentAsset.inheritSettingsReference && m_CurrentAsset != seq)
            {
                Undo.RecordObject(m_CurrentAsset, "use processor settings from other ImageSequence");
                m_CurrentAsset.inheritSettingsReference = seq;
                if (seq != null)
                {
                    m_CurrentAsset.editSettings.selectedProcessor = seq.editSettings.selectedProcessor;
                    m_CurrentAsset.editSettings.lockedProcessor   = -1;
                }
                EditorUtility.SetDirty(m_CurrentAsset);
                LoadAsset(m_CurrentAsset);
            }
            GUILayout.Space(10);

            using (new EditorGUI.DisabledScope(m_CurrentAsset.inheritSettingsReference != null))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.Label(VFXToolboxGUIUtility.Get("Frame Processors"), EditorStyles.boldLabel, GUILayout.Width(180));
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(VFXToolboxGUIUtility.Get("Clear"), GUILayout.Width(80)))
                    {
                        // Delete everything
                        Undo.RecordObject(m_CurrentAsset, "Clear All Processors");
                        m_ProcessingNodeStack.RemoveAllProcessors(m_CurrentAsset);
                        // Update UI
                        m_ProcessorsReorderableList.index             = -1;
                        m_CurrentProcessingNode                       = null;
                        m_LockedPreviewProcessor                      = null;
                        m_CurrentAsset.editSettings.lockedProcessor   = -1;
                        m_CurrentAsset.editSettings.selectedProcessor = -1;
                        m_PreviewCanvas.sequence                      = m_ProcessingNodeStack.inputSequence;
                        EditorUtility.SetDirty(m_CurrentAsset);
                        // Request Repaint
                        Invalidate();
                        RefreshCanvas();
                        return;
                    }
                }
                GUILayout.Space(8);
            }

            m_ProcessorsReorderableList.DoLayoutList();

            if (m_IgnoreInheritSettings || m_CurrentAsset.inheritSettingsReference == null)
            {
                GUILayout.Space(10);

                // Draw inspector and Invalidates whatever needs to.
                for (int i = 0; i < m_ProcessingNodeStack.nodes.Count; i++)
                {
                    if (m_ProcessorsReorderableList.index == i)
                    {
                        bool changed = m_ProcessingNodeStack.nodes[i].OnSidePanelGUI(m_CurrentAsset, i);
                        if (changed)
                        {
                            m_ProcessingNodeStack.nodes[i].Invalidate();
                            UpdateViewport();
                        }
                        m_Dirty = m_Dirty || changed;
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Settings cannot be accessed when linked from external Image Sequence", MessageType.Info);
            }


            // Handle final keyboard events (delete)
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete && m_ProcessingNodeStack.nodes.Count > 0)
            {
                MenuRemoveProcessor(m_ProcessorsReorderableList);
                Event.current.Use();
            }
        }
Ejemplo n.º 16
0
 public void AddProcessorInfoObjectToAsset(ImageSequence asset, ProcessorInfo info)
 {
     AssetDatabase.AddObjectToAsset(info, asset);
     info.hideFlags = HideFlags.HideInHierarchy;
 }
Ejemplo n.º 17
0
        private void OnEnable()
        {
            sequence = serializedObject.targetObject as ImageSequence;

            InitializePreview();
        }
        public override void Action(int instanceId, string pathName, string resourceFile)
        {
            ImageSequence asset = ImageSequenceAssetFactory.CreateImageSequenceAtPath(pathName);

            ProjectWindowUtil.ShowCreatedAsset(asset);
        }
Ejemplo n.º 19
0
 public void ReverseAllInputFrames(ImageSequence asset)
 {
     asset.inputFrameGUIDs.Reverse();
     EditorUtility.SetDirty(asset);
 }
Ejemplo n.º 20
0
        public void LoadAsset(ImageSequence asset)
        {
            m_CurrentAsset = asset;

            m_InputFramesReorderableList = null;
            m_ProcessorsReorderableList  = null;
            m_LockedPreviewProcessor     = null;
            m_CurrentProcessingNode      = null;

            // Free resources if any
            if (m_ProcessingNodeStack != null)
            {
                m_ProcessingNodeStack.Dispose();
            }

            InitializeGUI();

            if (m_CurrentAsset != null)
            {
                m_ProcessingNodeStack = new ProcessingNodeStack(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_ProcessingNodeStack.LoadFramesFromAsset(m_CurrentAsset);
                UpdateInputTexturesHash();

                m_InputFramesReorderableList = new ReorderableList(m_ProcessingNodeStack.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_ProcessingNodeStack.LoadProcessorsFromAsset(inheritedSettingReference);
                m_ProcessorDataProvider = new ProcessorDataProvider(m_ProcessingNodeStack, m_CurrentAsset);

                // Construct the RList
                if (m_CurrentAsset.inheritSettingsReference == null)
                {
#if UNITY_2020_1_OR_NEWER
                    m_ProcessorsReorderableList = new ReorderableList(m_CurrentAsset.processorInfos, typeof(ProcessorInfo), true, false, true, true);
#else
                    m_ProcessorsReorderableList = new ReorderableList(m_CurrentAssetSerializedObject, m_CurrentAssetSerializedObject.FindProperty("processorInfos"), true, false, true, true);
#endif
                    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_ProcessingNodeStack.inputSequence;
                if (m_PreviewCanvas.sequence.length > 0)
                {
                    m_PreviewCanvas.currentFrameIndex = 0;
                }
                else
                {
                    m_PreviewCanvas.currentFrameIndex = -1;
                }

                VFXToolboxGUIUtility.DisplayProgressBar("Image Sequencer", "Finalizing...", 1.0f);

                m_ProcessingNodeStack.InvalidateAll();
                RestoreProcessorView();

                EditorUtility.ClearProgressBar();
            }
        }
Ejemplo n.º 21
0
 public void AddSettingsObjectToAsset(ImageSequence asset, ScriptableObject settings)
 {
     AssetDatabase.AddObjectToAsset(settings, asset);
     settings.hideFlags = HideFlags.HideInHierarchy;
 }
 internal ProcessorDataProvider(ProcessingNodeStack stack, ImageSequence asset)
 {
     m_DataSource          = stack.settingsDefinitions;
     m_ProcessingNodeStack = stack;
     m_CurrentAsset        = asset;
 }