Version: 2022.2

SettingsProvider.OnInspectorUpdate

切换到手册
public void OnInspectorUpdate ();

描述

OnInspectorUpdate 以每秒 10 帧的速度调用,以便检视面板有机会进行更新。有关更多详细信息,请参阅 EditorWindow.OnInspectorUpdate

using UnityEditor;
public static class PresetManagerHelper
{
    [SettingsProvider]
    static SettingsProvider CreatePresetManagerProvider()
    {
        var provider = AssetSettingsProvider.CreateProviderFromAssetPath(
            "Project/Preset Manager", "ProjectSettings/PresetManager.asset");
        provider.inspectorUpdateHandler += () =>
        {
            // When PresetManager is updated from the inspector, check to see if we need to update the Preset Settings View.
            if (provider.settingsEditor != null &&
                provider.settingsEditor.serializedObject.UpdateIfRequiredOrScript())
            {
                provider.Repaint();
            }
        };
        return provider;
    }
}