bool 如果新设置成功应用,则返回 true。
处理“应用”和“恢复”按钮。
ApplyRevertGUI 调用此方法来放置和处理“应用”和“恢复”按钮。
using UnityEngine; using UnityEditor; using UnityEditor.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(); } } } }