Version: 2022.3
언어: 한국어

AssetDatabase.IsDirectoryMonitoringEnabled

매뉴얼로 전환
public static bool IsDirectoryMonitoringEnabled ();

반환

bool Returns true when Directory Monitoring is enabled. Returns false otherwise.

설명

Reports whether Directory Monitoring is enabled.

Turn Directory Monitoring on or off in Preferences settings or in script with EditorPrefs.SetBool("DirectoryMonitoring", boolValue).
Directory Monitoring can be disabled with command line flag [[-DisableDirectoryMonitor]] and Directory Monitoring is automatically disabled when Unity detects symlinks in the project.

using UnityEngine;
using UnityEditor;
using UnityEngine.Profiling;
using System.IO;

public class DirectoryMonitoringTest { [MenuItem("AssetDatabase/Directory Monitoring Test")] static void DirectoryMonitoringBenchmark() { var BenchmarkCount = 1;

//Disabling the Directory Monitoring will use a brute force scanning method to evaluate which files in the project have been changed, and is much slower EditorPrefs.SetBool("DirectoryMonitoring", false); Debug.Log("Is Directory Monitoring Enabled? - " + AssetDatabase.IsDirectoryMonitoringEnabled());

Benchmark(BenchmarkCount); BenchmarkCount++;

EditorPrefs.SetBool("DirectoryMonitoring", true); Debug.Log("Is Directory Monitoring Enabled? - " + AssetDatabase.IsDirectoryMonitoringEnabled()); Benchmark(BenchmarkCount); }

//This test will show faster scan time when using Directory Monitoring static void Benchmark(int BenchmarkCount) { var relativePath = "Assets/test_file01.txt"; if (!File.Exists(relativePath)) { using (StreamWriter sw = File.CreateText(relativePath)) { sw.WriteLine("Hello"); sw.WriteLine("And"); sw.WriteLine("Welcome"); } }

Profiler.BeginSample("Benchmark " + BenchmarkCount); ; AssetDatabase.ImportAsset(relativePath); Profiler.EndSample();

AssetDatabase.DeleteAsset(relativePath); AssetDatabase.Refresh(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961