docs.unity.cn
    Show / Hide Table of Contents

    Class RecompileScripts

    RecompileScripts is an IEditModeTestYieldInstruction that you can yield in Edit Mode tests. It lets you trigger a recompilation of scripts in the Unity Editor.

    Inheritance
    Object
    RecompileScripts
    Namespace: UnityEngine.TestTools
    Syntax
    public class RecompileScripts : IEditModeTestYieldInstruction

    Constructors

    RecompileScripts()

    Creates a new instance of the RecompileScripts yield instruction.

    [UnitySetUp]
    public IEnumerator SetUp()
    {
        using (var file = File.CreateText("Assets/temp/myScript.cs"))
        {
            file.Write("public class ATempClass {  }");
        }
        AssetDatabase.Refresh();
        yield return new RecompileScripts();
    }

    Declaration
    public RecompileScripts()

    RecompileScripts(Boolean)

    Creates a new instance of the RecompileScripts yield instruction.

    Declaration
    public RecompileScripts(bool expectScriptCompilation)
    Parameters
    Type Name Description
    Boolean expectScriptCompilation

    This parameter indicates if you expect a script compilation to start (defaults to true). If a script compilation does not start and expectScriptCompilation is true, then it throws an exception.

    RecompileScripts(Boolean, Boolean)

    Creates a new instance of the RecompileScripts yield instruction.

    Declaration
    public RecompileScripts(bool expectScriptCompilation, bool expectScriptCompilationSuccess)
    Parameters
    Type Name Description
    Boolean expectScriptCompilation

    This parameter indicates if you expect a script compilation to start (defaults to true). If a script compilation does not start and expectScriptCompilation is true, then it throws an exception.

    Boolean expectScriptCompilationSuccess

    This parameter indicates if you expect a script compilation to succeed. If not succeeded then an exception will be thrown.

    Properties

    Current

    The current active instance of the RecompileScripts yield instruction.

    Declaration
    public static RecompileScripts Current { get; }
    Property Value
    Type Description
    RecompileScripts

    ExpectDomainReload

    Returns true if the instruction expects a domain reload to occur.

    Declaration
    public bool ExpectDomainReload { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IEditModeTestYieldInstruction.ExpectDomainReload

    ExpectedPlaymodeState

    Returns true if the instruction expects the Unity Editor to be in Play Mode.

    Declaration
    public bool ExpectedPlaymodeState { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IEditModeTestYieldInstruction.ExpectedPlaymodeState

    ExpectScriptCompilation

    Indicates whether a script compilation is expected.

    Declaration
    public bool ExpectScriptCompilation { get; }
    Property Value
    Type Description
    Boolean

    ExpectScriptCompilationSuccess

    Indicates whether the expected script compilation is expected to succeed.

    Declaration
    public bool ExpectScriptCompilationSuccess { get; }
    Property Value
    Type Description
    Boolean

    Methods

    Perform()

    Perform the multi step instruction of triggering a recompilation of scripts and waiting for its completion.

    Declaration
    public IEnumerator Perform()
    Returns
    Type Description
    IEnumerator

    An IEnumerator with the async steps.

    Implements
    IEditModeTestYieldInstruction.Perform()
    Exceptions
    Type Condition
    Exception

    Throws an exception if the editor does not need to recompile scripts or if the script compilation failed when expected to succeed.

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Tuesday, July 19, 2022
    Terms of use