Version: Unity 6.1 Alpha (6000.1)
LanguageEnglish
  • C#

EditorAction.Finish

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

public void Finish(Actions.EditorActionResult result);

Parameters

result The state that the EditorAction was finished in.

Description

Finishes an EditorAction with a specific result.

Call this method to forcibly end an active EditorAction with a EditorActionResult. A common use is when implementing atomic actions that do not require interactivity.

using UnityEngine;
using UnityEditor;
using UnityEditor.Actions;

public class SingleFrameActionSample : EditorAction
{
    [MenuItem("Test/Start Single Frame Action")]
    static void StartEditorActionSample()
    {
        Start(new SingleFrameActionSample(4));
    }

    int m_Value;

    public SingleFrameActionSample(int value)
    {
        m_Value = value;
        Finish(EditorActionResult.Success);
    }

    protected override void OnFinish(EditorActionResult result)
    {
        m_Value += 2;
        Debug.Log($"Action Finished [{result}] with value: {m_Value}");
    }
}