예제 #1
0
        /// <summary>
        /// 绘制一个目录选择窗口
        /// </summary>
        /// <param name="label">提示名</param>
        /// <param name="folderPath">目录路径</param>
        /// <returns></returns>
        public static string FolderPath(string label, string folderPath)
        {
            EditorGUILayout.BeginHorizontal();
            folderPath = EditorGUILayout.TextField(label, folderPath);
            Rect        rect = GUILayoutUtility.GetLastRect();
            UnityObject uObj = GUIExtension.DragDropAreaSingle(rect, DragAndDropVisualMode.Copy);

            if (uObj != null && AssetDatabase.IsMainAsset(uObj))
            {
                string p = AssetDatabase.GetAssetPath(uObj);
                if (AssetDatabase.IsValidFolder(p))
                {
                    folderPath = p;
                }
            }
            if (GUILayout.Button(EditorGUIUtility.FindTexture("FolderEmpty Icon"), EditorStylesExtension.OnlyIconButtonStyle, GUILayout.Width(18), GUILayout.Height(18)))
            {
                folderPath = EditorUtility.OpenFolderPanel($"{label}目录选择", Application.dataPath, string.Empty);
                if (!string.IsNullOrEmpty(folderPath))
                {
                    folderPath = folderPath.Substring(folderPath.IndexOf("Assets"));
                }
            }
            EditorGUILayout.EndHorizontal();
            return(folderPath);
        }
예제 #2
0
        /// <summary>
        /// 绘制一个可接收一个拖拽资源的区域
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static UnityObject DragDropAreaSingle(DragAndDropVisualMode dropVisualMode, Color hightlightColor, params GUILayoutOption[] options)
        {
            Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.label, options);

            return(GUIExtension.DragDropAreaSingle(rect, dropVisualMode, hightlightColor));
        }
예제 #3
0
        /// <summary>
        /// 绘制一个可接收一个拖拽资源的区域
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static UnityObject DragDropAreaSingle(params GUILayoutOption[] options)
        {
            Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.label, options);

            return(GUIExtension.DragDropAreaSingle(rect));
        }