Ejemplo n.º 1
0
        public ProcessingNode(ProcessingNodeStack processorStack, ProcessorInfo info)
        {
            m_ProcessorInfo       = info;
            m_bEnabled            = m_ProcessorInfo.Enabled;
            m_ProcessingNodeStack = processorStack;
            processor             = m_ProcessorInfo.Settings;
            m_OutputSequence      = new ProcessingFrameSequence(this);

            shader   = AssetDatabase.LoadAssetAtPath <Shader>(processor.shaderPath);
            material = new Material(shader)
            {
                hideFlags = HideFlags.DontSave
            };
            material.hideFlags = HideFlags.DontSave;

            Linear          = true;
            GenerateMipMaps = true;

            processor.AttachTo(this);
        }
        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();
            }
        }
 internal ProcessorDataProvider(ProcessingNodeStack stack, ImageSequence asset)
 {
     m_DataSource          = stack.settingsDefinitions;
     m_ProcessingNodeStack = stack;
     m_CurrentAsset        = asset;
 }