导入任何已更改的资源。
这将导入任何已更改其内容修改数据或已添加或删除到项目文件夹中的资源。
此方法隐式触发资源垃圾回收(请参阅 Resources.UnloadUnusedAssets)。
其他资源:ImportAssetOptions。
using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Refresh Example")] public static void RefreshExample() { var folderList = new List<string>{"Textures", "Models", "Sounds"}; foreach (var folder in folderList) { Directory.CreateDirectory($"Assets/{folder}"); }
foreach (var folder in folderList) { //Output will be false Debug.Log(AssetDatabase.IsValidFolder($"Assets/{folder}")); }
AssetDatabase.Refresh(); foreach (var folder in folderList) { //Output will be true Debug.Log(AssetDatabase.IsValidFolder($"Assets/{folder}")); } } }