Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

AssetImporterEditor.ApplyRevertGUI

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

protected void ApplyRevertGUI();

Description

Adds 'Apply' and 'Revert' buttons to the Editor.

Call this method from the OnInspectorGUI event handler, because this is where the Apply/Revert buttons are placed in the Editor. You can't override this method but you can inject custom behavior by re-implementing OnApplyRevertGUI event handler method.

using UnityEngine;
using UnityEditor;
using UnityEditor.AssetImporters;

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

// Draw custom GUI

serializedObject.ApplyModifiedProperties();

ApplyRevertGUI(); } }

The following example adds Apply and Revert buttons if you're using UI Toolkit to implement AssetImporterEditor:

using UnityEngine;
using UnityEditor;
using UnityEditor.AssetImporters;
using UnityEngine.UIElements;

public class ExampleScript : ScriptedImporterEditor { public override VisualElement CreateInspectorGUI() { var root = new VisualElement();

var applyRevertGUI = new IMGUIContainer(ApplyRevertGUI); root.Add(applyRevertGUI); return root; } }