版本:Unity 6 (6000.0)
语言简体中文
  • C#

SettingsService.NotifySettingsProviderChanged

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们无法接受所有提交,但我们会阅读用户提供的每项建议的更改,并在适用情况下进行更新。

关闭

提交失败

由于某些原因,您的建议的更改无法提交。请在几分钟后<a>重试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

声明

public static void NotifySettingsProviderChanged();

说明

使用此函数通知 SettingsService 有 SettingsProvider 发生更改。

当添加、移除或修改 SettingsProvider 并且需要刷新设置窗口时,管理 SettingsProvider 的客户端应调用此函数。

using System.Linq;
using UnityEditor;

class MyCustomSettingsProcessor : AssetPostprocessor { const string k_MyCustomSettingsPath = "Resources/MyCustomSettings.asset"; static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { var settingsTouched = importedAssets.Any(a => a.Contains(k_MyCustomSettingsPath)); settingsTouched = settingsTouched || deletedAssets.Any(a => a.Contains(k_MyCustomSettingsPath)); settingsTouched = settingsTouched || movedAssets.Any(a => a.Contains(k_MyCustomSettingsPath)); settingsTouched = settingsTouched || movedFromAssetPaths.Any(a => a.Contains(k_MyCustomSettingsPath));

if (settingsTouched) { // Notify the SettingsWindow that MyCustomSettings has been removed or added. This tells the SettingsWindow to Add/Remove // a new Settings section. SettingsService.NotifySettingsProviderChanged(); } } }