path | 文件夹的路径。 |
bool 如果文件夹存在,则返回 true。
给定文件夹的路径,如果存在,则返回 true;否则,返回 false。
给定路径是相对于项目文件夹的路径。
using System.Collections.Generic; using UnityEngine; using UnityEditor;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/CreateFolderStructure")] static void CreateFolderStructure() { var folderList = new List<string> {"Animations", "Textures", "Materials", "Prefabs", "Resources", "Scripts"};
//Check if folder exists with IsValidFolder if it doesn't create it foreach (var folder in folderList) { if (AssetDatabase.IsValidFolder($"Assets/{folder}")) continue; AssetDatabase.CreateFolder("Assets", folder); } } }