Demo project for Replay for Unity - A VR testing framework for Unity.
Tested on:
- VRTK 3.2.1, 3.3.0
- HTC Vive (on SteamVR 1.2.3 for Unity), VRTK Simulator (also tested recording on HTC Vive and played on simulator)
- Oculus Rift (using Oculus Integration for Unity)
Currently, the recording is supported only in Unity Editor.
The project demo comes with both VRTK and SteamVR (versions supported above).
Getting started:
- Get the ReplayVR asset from Unity Asset Store (https://assetstore.unity.com/packages/tools/gui/replayvr-150493) and put it inside a Plugins folder and set platforms for the libraries (ReplayVR.dll for all platforms, ReplayVR.Editor.dll only for Editor).
- Add VRTK ReplayVR components to Controllers and Camera using Add Component in UnityEditor (see ReplayVR section); for camera you also need to add Tracked Pose Driver from XR Legacy Input Helpers (see Package Manager under Window).
- Create a Tests/Recorder game objects and assign it the ScenarioRecorder component from ReplayVR; enter a scenario name and enter the recorders (controllers and camera).
- Play the app.
- Enable "Can record" from Tests/Recorder object.
- Do your app flow.
- Quit the app - the objects movements and actions will be stored in Application.physicalPath location.
- Add the Tests/Asserts game object and assign it a new MonoBehavior that inherits from AssertBehaviour from ReplayVR; implement HandleCurrentState. Add the runners and scenario name same as the recorder.
- Set the conditions to the assert component.
- Enable "Can execute" of the assert component.
- Restart the app.
- See the app flow replayed.
If you want to change the record/replay functions, choose Execution method on both recorder and runner: Update, FixedUpdate, LateUpdate.
SteamVR:
- Controllers - see LeftController(ScriptAlias)/RightController(ScriptAlias) VRTK objects (see [VRTK_Scripts])
- Camera - see Camera (eye) under [VRTK_SDKManager]-SteamVR
Oculus (untested):
- Controllers - see LeftController(ScriptAlias)/RightController(ScriptAlias) VRTK objects (see [VRTK_Scripts])
- Camera - see CenterEyeAnchor under [VRTK_SDKManager]-Oculus(VR)
To view the recording go to Window -> ReplayVR -> Scenario recordings and select the scenario and object you recoreded. The window will output all actions and the corresponding indexes.
Running a test at runtime (can be used in CI environments):
- Add the RuntimeTestRunner from ReplayVR.Scripts to the root TestObject (provided by the asset)
- Build the app for Standalone player
- Run the command from Command Prompt "start /wait .exe replayTestObject:Unity_test_object & echo %errorlevel%" => you should see 0 if test is successful, -1 if not.
Remarks: a. Unity_test_object is the name of the object in Unity that has the AssertBehaviour component attached to it. b. For other platforms, see the corresponding commands to start and app and get it's exit code.
Set ReplayVR.dll available for all platforms and ReplayVR.Editor.dll only for Editor platform.
Copy the files to Application.physicalPath: e.g.: C:\Users<user>\AppData\LocalLow\ReplayVR\ReplayVR-Demo\ReplayVR\Recordings