Пример #1
0
    static void LockAndEditFrame(ShortcutArguments args) {
        
        foreach (Object obj in Selection.objects) {
            FrameMarker frameMarker = obj as FrameMarker;
            if (null == frameMarker) {
                continue;
            }
            SISPlayableFrame playableFrame       = frameMarker.GetOwner();
            RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset<RenderCachePlayableAsset>();            
            if (null == playableAsset)
                return;
        
            FrameMarkerInspector.LockAndEditPlayableFrame(playableFrame, playableAsset);

        }        
                        
    }    
//----------------------------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            ShortcutBinding useFrameShortcut
                = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_TOGGLE_FRAME_MARKER);
            bool prevUseFrame = m_assets[0].IsFrameUsed();
            bool useFrame     = EditorGUILayout.Toggle($"Use Frame ({useFrameShortcut})", prevUseFrame);

            if (useFrame != prevUseFrame)
            {
                //Set all selected objects
                foreach (FrameMarker m in m_assets)
                {
                    SetMarkerValueByContext(m, useFrame);
                }
            }

            //Only show lock and edit for RenderCachePlayableAsset
            foreach (FrameMarker frameMarker in m_assets)
            {
                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return;
                }
            }

            //m_assets only contain RenderCachePlayableAsset at this point
            ShortcutBinding lockAndEditShortcut
                = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_LOCK_AND_EDIT_FRAME);

            if (GUILayout.Button($"Lock and Edit ({lockAndEditShortcut})"))
            {
                foreach (FrameMarker frameMarker in m_assets)
                {
                    SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                    RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                    Assert.IsNotNull(playableAsset);
                    LockAndEditPlayableFrame(playableFrame, playableAsset);
                }
            }
        }
//----------------------------------------------------------------------------------------------------------------------
        ///<inheritdoc />
        public override ActionValidity Validate(IEnumerable <IMarker> markers)
        {
            foreach (IMarker marker in markers)
            {
                FrameMarker frameMarker = marker as FrameMarker;
                if (null == frameMarker)
                {
                    return(ActionValidity.NotApplicable);
                }


                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return(ActionValidity.NotApplicable);
                }
            }
            return(ActionValidity.Valid);
        }
        ///<inheritdoc />
        public override bool Execute(IEnumerable <IMarker> markers)
        {
            foreach (IMarker marker in markers)
            {
                FrameMarker frameMarker = marker as FrameMarker;
                if (null == frameMarker)
                {
                    return(false);
                }

                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return(false);
                }

                FrameMarkerInspector.LockAndEditPlayableFrame(playableFrame, playableAsset);
            }

            return(true);
        }
Пример #5
0
//----------------------------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            ShortcutBinding useFrameShortcut
                = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_TOGGLE_FRAME_MARKER);
            bool prevUseFrame = m_assets[0].IsFrameUsed();
            bool useFrame     = EditorGUILayout.Toggle($"Use Frame ({useFrameShortcut})", prevUseFrame);

            if (useFrame != prevUseFrame)
            {
                //Set all selected objects
                foreach (FrameMarker m in m_assets)
                {
                    SetMarkerValueByContext(m, useFrame);
                }
            }

            if (1 == m_assets.Length)
            {
                SISPlayableFrame playableFrame = m_assets[0].GetOwner();
                string           prevNote      = playableFrame?.GetUserNote();
                DrawNoteGUI(prevNote);
            }
            else
            {
                int numSelectedAssets = m_assets.Length;
                Assert.IsTrue(numSelectedAssets > 1);
                SISPlayableFrame firstPlayableFrame = m_assets[0].GetOwner();
                //Check invalid PlayableFrame. Perhaps because of unsupported Duplicate operation ?
                if (null == firstPlayableFrame)
                {
                    return;
                }
                string prevNote = firstPlayableFrame.GetUserNote();
                for (int i = 1; i < numSelectedAssets; ++i)
                {
                    SISPlayableFrame playableFrame = m_assets[i].GetOwner();
                    if (playableFrame.GetUserNote() != prevNote)
                    {
                        prevNote = "<different notes>";
                    }
                }

                DrawNoteGUI(prevNote);
            }



            //Only show lock and edit for RenderCachePlayableAsset
            //[TODO-Sin: 2020-8-24]: Define capabilities in RenderCachePlayableAsset that defines what is visible
            foreach (FrameMarker frameMarker in m_assets)
            {
                SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                if (null == playableAsset)
                {
                    return;
                }
            }

            GUILayout.Space(15);

            //m_assets only contain RenderCachePlayableAsset at this point
            ShortcutBinding lockAndEditShortcut
                = ShortcutManager.instance.GetShortcutBinding(SISEditorConstants.SHORTCUT_LOCK_AND_EDIT_FRAME);

            if (GUILayout.Button($"Lock and Edit ({lockAndEditShortcut})"))
            {
                foreach (FrameMarker frameMarker in m_assets)
                {
                    SISPlayableFrame         playableFrame = frameMarker.GetOwner();
                    RenderCachePlayableAsset playableAsset = playableFrame.GetTimelineClipAsset <RenderCachePlayableAsset>();
                    Assert.IsNotNull(playableAsset);
                    LockAndEditPlayableFrame(playableFrame, playableAsset);
                }
            }
        }