예제 #1
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();

    }
//----------------------------------------------------------------------------------------------------------------------

        internal static string ShowFolderSelectorGUI(string label,
                                                     string dialogTitle,
                                                     string fieldValue,
                                                     Func <string, string> onValidFolderSelected)
        {
            string newDirPath = null;

            using (new EditorGUILayout.HorizontalScope()) {
                if (!string.IsNullOrEmpty(label))
                {
                    EditorGUILayout.PrefixLabel(label);
                }

                EditorGUILayout.SelectableLabel(fieldValue,
                                                EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)
                                                );

                //Drag drop
                Rect folderRect = GUILayoutUtility.GetLastRect();

                Event evt = Event.current;
                switch (evt.type)
                {
                case EventType.DragUpdated:
                case EventType.DragPerform:
                    if (!folderRect.Contains(evt.mousePosition))
                    {
                        return(fieldValue);
                    }

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (evt.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        if (DragAndDrop.paths.Length <= 0)
                        {
                            break;
                        }
                        fieldValue = DragAndDrop.paths[0];
//                            onDragAndDrop(DragAndDrop.paths[0]);
                    }

                    break;

                default:
                    break;
                }


                newDirPath = InspectorUtility.ShowSelectFolderButton(dialogTitle, fieldValue, onValidFolderSelected);

                if (GUILayout.Button("Show", GUILayout.Width(50f), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                {
                    EditorUtility.RevealInFinder(newDirPath);
                }
            }

            using (new EditorGUILayout.HorizontalScope()) {
                GUILayout.FlexibleSpace();
                EditorGUI.BeginDisabledGroup(!AssetDatabase.IsValidFolder(newDirPath));
                if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                {
                    AssetEditorUtility.PingAssetByPath(newDirPath);
                }
                EditorGUI.EndDisabledGroup();
            }

            return(newDirPath);
        }