Esempio n. 1
0
        void SetFPSAndCheck(StreamingImageSequencePlayableAsset sisAsset, float newFPS)
        {
            SISClipData sisClipData = sisAsset.GetBoundClipData();

            Assert.IsNotNull(sisClipData);
            TimelineClip clip = sisClipData.GetOwner();

            Assert.IsNotNull(clip);


            float prevFPS          = SISPlayableAssetUtility.CalculateFPS(sisAsset);
            float prevClipDuration = (float)clip.duration;
            float prevTimeScale    = (float)clip.timeScale;

            Assert.Greater(prevFPS, 0);
            float fpsMultiplier = newFPS / prevFPS;

            Assert.Greater(fpsMultiplier, 0);
            float timeMultiplier = 1.0f / fpsMultiplier;

            SISPlayableAssetUtility.SetFPS(sisAsset, newFPS);
            Assert.IsTrue(Mathf.Approximately(prevClipDuration * timeMultiplier, (float)clip.duration));
            Assert.IsTrue(Mathf.Approximately(prevTimeScale * fpsMultiplier, (float)clip.timeScale));
        }
Esempio n. 2
0
//----------------------------------------------------------------------------------------------------------------------

    /// <summary>
    /// StreamingImageSequencePlayableAsset GUI Drawing
    /// </summary>
    public override void OnInspectorGUI() {
        if (null == m_asset)
            return;
        

        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.GetBoundClipData()?.GetOwner();
                    //There is no assigned clip if the playableAsset is not loaded in TimelineWindow
                    if (null != clip) {                         
                                                
                        EditorGUIDrawerUtility.DrawUndoableGUI(clip.GetParentTrack(), "Change FPS", 
                            /*guiFunc=*/ ()=> {
                                float fps = SISPlayableAssetUtility.CalculateFPS(m_asset);
                                float val = EditorGUILayout.FloatField("FPS", fps); 
                                return Mathf.Max(0.1f, val);
                            }, 
                            /*updateFunc=*/ (float newFPS) => {
                                SISPlayableAssetUtility.SetFPS(m_asset, newFPS);                                
                            }
                        );
                    }                    
                }
            }
            
            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) {
            using (new EditorGUILayout.HorizontalScope()) {
                InspectorUtility.DrawFrameMarkersGUI(m_asset);
                if (GUILayout.Button("Reset", GUILayout.Width(50f))) {
                    m_asset.ResetPlayableFrames();
                }
            }
        }
        GUILayout.Space(15);
        
        using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
            EditorGUILayout.LabelField("Background Colors");
            ++EditorGUI.indentLevel;
            
            EditorGUIDrawerUtility.DrawUndoableGUI(m_asset, "Change BG Color", 
                /*guiFunc=*/ ()=> EditorGUILayout.ColorField("In Timeline Window", m_asset.GetTimelineBGColor()), 
                /*updateFunc=*/ (Color newColor) => {                               
                    m_asset.SetTimelineBGColor(newColor);                                
                }
            );
            
            --EditorGUI.indentLevel;
            GUILayout.Space(15);
        }

        
        if (GUILayout.Button("Reset Curve (Not Undoable)")) {
            //AnimationUtility.SetEditorCurve(), which is called below, doesn't seem to be undoable
            EditorCurveBinding curveBinding = StreamingImageSequencePlayableAsset.GetTimeCurveBinding();                 
            ExtendedClipEditorUtility.ResetClipDataCurve(m_asset, curveBinding);
        }
    }