UnityEditor.EditorUtility.OpenFolderPanel C# (CSharp) Method

OpenFolderPanel() private method

private OpenFolderPanel ( string title, string folder, string defaultName ) : string
title string
folder string
defaultName string
return string
        public static extern string OpenFolderPanel(string title, string folder, string defaultName);
        [MethodImpl(MethodImplOptions.InternalCall)]

Usage Example

示例#1
0
        /// <summary>
        /// Make a folder field.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="filePath">The file path.</param>
        /// <param name="title">The title.</param>
        /// <param name="folder">The folder.</param>
        /// <param name="defaultName">The default name.</param>
        /// <param name="labelWidth">Width of the label.</param>
        /// <returns>The path of the folder.</returns>
        public static string FolderField(GUIContent label, string filePath, string title, string folder = "", string defaultName = "", float labelWidth = 0f)
        {
            var text = filePath;

            using (new EditorGUIFieldScope(labelWidth))
            {
                EditorGUILayout.LabelField(label, new GUIContent(text), Styles.PathFieldStyle);
                var buttonClicked = GUILayout.Button("Browse...", Styles.BrowseButtonStyle);

                if (!buttonClicked)
                {
                    return(text);
                }

                var newPath = UnityEditorUtility.OpenFolderPanel(title, folder, defaultName);
                if (!string.IsNullOrEmpty(newPath))
                {
                    text = newPath;
                }
            }

            return(text);
        }
EditorUtility