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.
Implements
Inherited Members
Namespace: UnityEngine.TestTools
Assembly: UnityEditor.TestRunner.dll
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(bool)
Creates a new instance of the RecompileScripts
yield instruction.
Declaration
public RecompileScripts(bool expectScriptCompilation)
Parameters
Type | Name | Description |
---|---|---|
bool | expectScriptCompilation | This parameter indicates if you expect a script compilation to start (defaults to true). If a script compilation does not start and |
RecompileScripts(bool, bool)
Creates a new instance of the RecompileScripts
yield instruction.
Declaration
public RecompileScripts(bool expectScriptCompilation, bool expectScriptCompilationSuccess)
Parameters
Type | Name | Description |
---|---|---|
bool | expectScriptCompilation | This parameter indicates if you expect a script compilation to start (defaults to true). If a script compilation does not start and |
bool | 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 |
---|---|
bool |
ExpectScriptCompilation
Indicates whether a script compilation is expected.
Declaration
public bool ExpectScriptCompilation { get; }
Property Value
Type | Description |
---|---|
bool |
ExpectScriptCompilationSuccess
Indicates whether the expected script compilation is expected to succeed.
Declaration
public bool ExpectScriptCompilationSuccess { get; }
Property Value
Type | Description |
---|---|
bool |
ExpectedPlaymodeState
Returns true if the instruction expects the Unity Editor to be in Play Mode.
Declaration
public bool ExpectedPlaymodeState { get; }
Property Value
Type | Description |
---|---|
bool |
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. |
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. |