Automators
An Automator is a script for controlling a segment of gameplay. Automators can be recordings, agents, or custom c# scripts.
Please email us at AutomatedTesting@unity3d.com with any questions or suggestions about this feature!
Automated Run
An Automated Run is used to configure a list of Automators to play in sequence.
- The
AutomatedRun
object links together recordings and custom C# scripts to automate gameplay. - Create an AutomatedRun with the
Create > Automated QA > Automated Run
menu - Click
Run
in the inspector for the Automated Run to start playback.
Custom Automators
- Extend the
Automator
class to create a custom automator script. - Extend the
AutomatorConfig
class for your Automator to expose it in theAutomatedRun
inspector.
Example custom Automator:
[Serializable]
public class LoadLevelAutomatorConfig : AutomatorConfig<LoadLevelAutomator>
{
public string scene = "SampleScene";
}
public class LoadLevelAutomator : Automator<LoadLevelAutomatorConfig>
{
public override void BeginAutomation()
{
base.BeginAutomation();
StartCoroutine(LoadLevel());
}
IEnumerator LoadLevel()
{
var op = SceneManager.LoadSceneAsync(config.scene);
while (!op.isDone)
{
yield return null;
}
EndAutomation();
}
}
CentralAutomationController
You can use the CentralAutomationController to automate gameplay programmatically.
An AutomatedRun asset can be passed to the CentralAutomationController to run it:
public AutomatedRun automatedRun;
void Start()
{
CentralAutomationController.Instance.Run(automatedRun.config);
}
The CentralAutomationController can be also be configured programmatically:
CentralAutomationController.Instance.AddAutomator<RecordedPlaybackAutomator>();
CentralAutomationController.Instance.Run();
Config data can also be created programmatically:
var config = new AutomatedRun.RunConfig();
config.automators.AddRange( new List<AutomatorConfig>{
new LoadLevelAutomatorConfig()
{
scene = "SampleScene"
},
new RecordedPlaybackAutomatorConfig()
{
recordingFilePath = "Recordings/recording1.json"
},
});
CentralAutomationController.Instance.Run(config);