path | 文件夹的路径。 |
bool 如果文件夹存在则返回 true。
给定文件夹的路径,如果它存在则返回 true,否则返回 false。
给定的路径相对于项目文件夹。
using System.Collections.Generic; using UnityEngine; using UnityEditor;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Create Folder Structure")] 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); } } }