//----------------------------------------------------------------------------------------------------------------------

    /// <summary>
    /// StreamingImageSequencePlayableAsset GUI Drawing
    /// </summary>
    public override void OnInspectorGUI() {
        if (null == m_asset)
            return;
        
        Undo.RecordObject(m_asset, "StreamingImageSequencePlayableAssetInspector::OnInspectorGUI");

        using (new EditorGUILayout.VerticalScope (GUI.skin.box))  {

            m_resolutionFoldout = EditorGUILayout.Foldout(m_resolutionFoldout, "Resolution");
            if (m_resolutionFoldout) {
                ImageDimensionInt res = m_asset.GetResolution();
                EditorGUILayout.LabelField("Width",  $"{res.Width } px");
                EditorGUILayout.LabelField("Height",  $"{res.Height } px");
            }
            GUILayout.Space(4f);
        }
        
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            GUILayout.Label("Folder", "BoldLabel");
            GUILayout.Space(4f);
            DrawFolderGUI();
        }
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            int numImages = m_asset.GetNumImages();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Images: " + numImages, "BoldLabel");            
            if (GUILayout.Button("Reload", GUILayout.Width(50))) {
                m_asset.Reload();
            }
            EditorGUILayout.EndHorizontal();
            
            using (new EditorGUI.DisabledScope(0 == numImages)) {
                if (0 == numImages)
                    EditorGUILayout.IntField("FPS", 0);
                else {
                    TimelineClip clip = m_asset.GetBoundTimelineClipSISData().GetOwner();
                    
                    float prevFps = numImages / (float)(clip.duration); 
                    float fps     = EditorGUILayout.FloatField("FPS", prevFps);
                    if (!Mathf.Approximately(fps, prevFps) && !Mathf.Approximately(fps, 0.0f)) {
                        double prevDuration = clip.duration;
                        clip.duration  = numImages / fps;
                        clip.timeScale = (prevDuration * clip.timeScale) / clip.duration;
                    }
                }
            }
            
            GUILayout.Space(4f);
            m_imageListFoldout = EditorGUILayout.Foldout(m_imageListFoldout, "Images");
            if (m_imageListFoldout) {
                DoImageGUI();
            }
        }

        if (null == TimelineEditor.selectedClip) 
            return;
        
        GUILayout.Space(15);
        //Frame markers
        if (TimelineEditor.selectedClip.asset == m_asset) {
            InspectorUtility.ShowFrameMarkersGUI(m_asset);
        }
        GUILayout.Space(15);
        
        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            EditorGUILayout.LabelField("Background Colors");
            ++EditorGUI.indentLevel;
            Color timelineBgColor = m_asset.GetTimelineBGColor();
            m_asset.SetTimelineBGColor(EditorGUILayout.ColorField("In Timeline Window", timelineBgColor));
            --EditorGUI.indentLevel;
            GUILayout.Space(15);
        }

        
        if (GUILayout.Button("Reset Curve (Not Undoable)")) {
            //AnimationClip.SetCurve() doesn't seem to be undoable
            StreamingImageSequencePlayableAsset.ResetTimelineClipCurve(TimelineEditor.selectedClip);
        }
    }
コード例 #2
0
        public IEnumerator UncheckFrameMarkers()
        {
            PlayableDirector director = EditorUtilityTest.NewSceneWithDirector();
            TimelineClip     clip     = EditorUtilityTest.CreateTestTimelineClip(director);
            StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset;

            Assert.IsNotNull(sisAsset);
            TimelineClipSISData timelineClipSISData = sisAsset.GetBoundTimelineClipSISData();

            timelineClipSISData.RequestFrameMarkers(true);
            yield return(null);

            double timePerFrame = TimelineUtility.CalculateTimePerFrame(clip);
            int    numImages    = sisAsset.GetImageFileNames().Count;

            clip.timeScale = 3.75f; //use scaling
            EditorUtilityTest.ResizeSISTimelineClip(clip, (timePerFrame * numImages));
            yield return(null);

            int numFrames = TimelineUtility.CalculateNumFrames(clip);

            Assert.AreEqual(numImages, numFrames);

            //Reset: make sure that the curve is a simple straight line from 0 to 1
            StreamingImageSequencePlayableAsset.ResetTimelineClipCurve(clip);
            yield return(null);

            sisAsset.ResetPlayableFrames();
            yield return(null);

            StreamingImageSequenceTrack track = clip.parentTrack as StreamingImageSequenceTrack;

            Assert.IsNotNull(track);
            List <FrameMarker> frameMarkers = new List <FrameMarker>();

            int i = 0;

            foreach (var m in track.GetMarkers())
            {
                FrameMarker marker = m as FrameMarker;
                Assert.IsNotNull(marker);
                frameMarkers.Add(marker);
                int imageIndex = sisAsset.GlobalTimeToImageIndex(clip, marker.time);
                Assert.AreEqual(i, imageIndex);
                ++i;
            }

            //Uncheck and see if the unchecked images became ignored
            frameMarkers[4].SetFrameUsed(false);
            frameMarkers[5].SetFrameUsed(false);
            Assert.AreEqual(3, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[4].time));
            Assert.AreEqual(3, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[5].time));


            frameMarkers[7].SetFrameUsed(false);
            frameMarkers[8].SetFrameUsed(false);
            Assert.AreEqual(6, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[7].time));
            Assert.AreEqual(6, sisAsset.GlobalTimeToImageIndex(clip, frameMarkers[8].time));

            EditorUtilityTest.DestroyTestTimelineAssets(clip);
            yield return(null);
        }
コード例 #3
0
//----------------------------------------------------------------------------------------------------------------------

    /// <summary>
    /// StreamingImageSequencePlayableAsset GUI Drawing
    /// </summary>
    public override void OnInspectorGUI() {
        if (null == m_asset)
            return;
        
        EditorGUI.BeginChangeCheck();
        serializedObject.Update();
        Undo.RecordObject(m_asset, "StreamingImageSequencePlayableAssetInspector::OnInspectorGUI");

        using (new EditorGUILayout.VerticalScope (GUI.skin.box))  {

            m_resolutionFoldout = EditorGUILayout.Foldout(m_resolutionFoldout, "Resolution");
            if (m_resolutionFoldout) {
                ImageDimensionInt res = m_asset.GetResolution();
                EditorGUILayout.LabelField("Width",  $"{res.Width } px");
                EditorGUILayout.LabelField("Height",  $"{res.Height } px");
            }
            GUILayout.Space(4f);

        }

        
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box))
        {
            GUILayout.Label("Folder", "BoldLabel");
            GUILayout.Space(4f);
            DoFolderGUI();
        }
        GUILayout.Space(4f);

        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            int numImages = 0;
            if (m_asset.HasImages()) {
                numImages = m_asset.GetImageFileNames().Count;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Images: " + numImages, "BoldLabel");            
            if (GUILayout.Button("Reload", GUILayout.Width(50))) {
                m_asset.Reload();
            }
            EditorGUILayout.EndHorizontal();
            
            GUILayout.Space(4f);
            m_imageListFoldout = EditorGUILayout.Foldout(m_imageListFoldout, "Images");
            if (m_imageListFoldout) {
                DoImageGUI();
            }
        }
        
        if (null!= TimelineEditor.selectedClip) {
            

            GUILayout.Space(15);
            //Frame markers
            if (TimelineEditor.selectedClip.asset == m_asset) {
                InspectorUtility.ShowFrameMarkersGUI(m_asset);
            }
            GUILayout.Space(15);
            if (GUILayout.Button("Reset Curve (Not Undoable)")) {
                //AnimationClip.SetCurve() doesn't seem to be undoable
                StreamingImageSequencePlayableAsset.ResetTimelineClipCurve(TimelineEditor.selectedClip);
            }
            
        }

        serializedObject.ApplyModifiedProperties();
        EditorGUI.EndChangeCheck();

    }