Experimental: this API is experimental and might be changed or removed in the future.

AssetImporterEditor.OnApplyRevertGUI

切换到手册
protected bool OnApplyRevertGUI ();

返回

bool 如果新设置应用成功,则返回 true。

描述

处理“Apply”和“Revert”按钮。

ApplyRevertGUI 调用它来放置和处理“Apply”和“Revert”按钮。

using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;

public class ExampleScript : ScriptedImporterEditor { public override void OnInspectorGUI() { serializedObject.Update();

// Draw custom GUI

serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }

private bool CanApply() { // Add custom checks that make sure the Importer is in a valid state to be applied. return false; }

protected virtual bool OnApplyRevertGUI() { using (new EditorGUI.DisabledScope(!HasModified())) { RevertButton(); using (new EditorGUI.DisabledScope(!CanApply())) { return ApplyButton(); } } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961