Unity commands#
Commands that work with Unity features of the app: PlayerPrefs, scenes, the screen and time scale, and static fields, properties and methods. They are all methods of AltDriver.
Each command shows its signature and an example in every language; pick a language in any tab and the others switch with it.
Commands on this page#
Command |
What it does |
|---|---|
Returns the value stored under a key in PlayerPrefs. |
|
Stores a value under a key in PlayerPrefs, replacing any value the key had. |
|
Removes a key and its value from PlayerPrefs. |
|
Removes every key and value from PlayerPrefs, as on a fresh install of the app. |
|
Returns the name of the active scene. |
|
Loads a scene, by default in place of the scenes already loaded, and waits until it has loaded. |
|
Unloads a scene and waits until it has unloaded. |
|
Returns the names of the scenes loaded at the moment. |
|
Waits until a scene is the active scene, for example after a tap that opens a new level. |
|
Returns the width and height of the app’s screen, in pixels (Unity’s |
|
Returns the app’s time scale (Unity’s |
|
Sets the app’s time scale (Unity’s |
|
Calls a public static method of a class in the app and returns its result. |
|
Returns the value of a static field or property of a class in the app. |
|
Sets the value of a static field or property of a class in the app. |
PlayerPrefs#
Read, write and delete the app’s PlayerPrefs, for example to start a test with a known score or settings.
PlayerPrefKeyType#
A PlayerPrefs value is an int, a float or a string. C# and Java have a method for
each type, such as GetIntKeyPlayerPref. In Python and Robot Framework, one command
takes the type as its key_type parameter:
Type |
Value |
Python |
Robot Framework |
|---|---|---|---|
Int |
1 |
|
|
String |
2 |
|
|
Float |
3 |
|
|
In Python, import it with from alttester import PlayerPrefKeyType.
GetKeyPlayerPref#
Returns the value stored under a key in PlayerPrefs. In C# and Java, call the method for the value’s type; in Python and Robot Framework, pass the type.
int GetIntKeyPlayerPref(string keyName)
float GetFloatKeyPlayerPref(string keyName)
string GetStringKeyPlayerPref(string keyName)
Example
// Read the best score and the player name the game saved.
int bestScore = altDriver.GetIntKeyPlayerPref("BestScore");
string playerName = altDriver.GetStringKeyPlayerPref("PlayerName");
int getIntKeyPlayerPref(String keyName)
float getFloatKeyPlayerPref(String keyName)
String getStringKeyPlayerPref(String keyName)
Example
// Read the best score and the player name the game saved.
int bestScore = altDriver.getIntKeyPlayerPref("BestScore");
String playerName = altDriver.getStringKeyPlayerPref("PlayerName");
alt_driver.get_player_pref_key(key_name, key_type)
Example
from alttester import PlayerPrefKeyType
# Read the best score and the player name the game saved.
best_score = alt_driver.get_player_pref_key("BestScore", PlayerPrefKeyType.Int)
player_name = alt_driver.get_player_pref_key("PlayerName", PlayerPrefKeyType.String)
${value}= Get Player Pref Key key_name key_type
Example
# Read the best score and the player name the game saved.
${best_score}= Get Player Pref Key BestScore Int
${player_name}= Get Player Pref Key PlayerName String
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The key. |
|
Python: |
required |
The type of the value, a PlayerPrefKeyType. In Robot Framework, its name. Only in Python, Robot. |
Returns
int, float or string: The value stored under the key.
Note
If the key doesn’t exist, the command fails with NotFoundException.
See also: SetKeyPlayerPref · DeleteKeyPlayerPref
SetKeyPlayerPref#
Stores a value under a key in PlayerPrefs, replacing any value the key had.
void SetKeyPlayerPref(string keyName, int valueName)
void SetKeyPlayerPref(string keyName, float valueName)
void SetKeyPlayerPref(string keyName, string valueName)
Example
// Start the game with three lives, the music at half volume and a player name.
altDriver.SetKeyPlayerPref("Lives", 3);
altDriver.SetKeyPlayerPref("MusicVolume", 0.5f);
altDriver.SetKeyPlayerPref("PlayerName", "Tester");
altDriver.LoadScene("MainMenu");
void setKeyPlayerPref(String keyName, int valueName)
void setKeyPlayerPref(String keyName, float valueName)
void setKeyPlayerPref(String keyName, String valueName)
Example
// Start the game with three lives, the music at half volume and a player name.
altDriver.setKeyPlayerPref("Lives", 3);
altDriver.setKeyPlayerPref("MusicVolume", 0.5f);
altDriver.setKeyPlayerPref("PlayerName", "Tester");
altDriver.loadScene(new AltLoadSceneParams.Builder("MainMenu").build());
alt_driver.set_player_pref_key(key_name, value, key_type)
Example
from alttester import PlayerPrefKeyType
# Start the game with three lives, the music at half volume and a player name.
alt_driver.set_player_pref_key("Lives", 3, PlayerPrefKeyType.Int)
alt_driver.set_player_pref_key("MusicVolume", 0.5, PlayerPrefKeyType.Float)
alt_driver.set_player_pref_key("PlayerName", "Tester", PlayerPrefKeyType.String)
alt_driver.load_scene("MainMenu")
Set Player Pref Key key_name value key_type
Example
# Start the game with three lives, the music at half volume and a player name.
Set Player Pref Key Lives ${3} Int
Set Player Pref Key MusicVolume ${0.5} Float
Set Player Pref Key PlayerName Tester String
Load Scene MainMenu
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The key. |
|
int, float or string |
required |
The value to store. |
|
Python: |
required |
The type of the value, a PlayerPrefKeyType. In Robot Framework, its name. Only in Python, Robot. |
Returns
Nothing.
Note
In C# and Java, the type of valueName picks the overload, and so the type the value is stored as. Write a float as 0.5f: 0.5 is a double, which no overload takes.
The app sees the new value the next time it reads the key. If it reads PlayerPrefs only when a scene starts, load the scene again with LoadScene.
See also: GetKeyPlayerPref · DeletePlayerPref
DeleteKeyPlayerPref#
Removes a key and its value from PlayerPrefs.
void DeleteKeyPlayerPref(string keyName)
Example
// Show the tutorial again: forget that the player finished it.
altDriver.DeleteKeyPlayerPref("TutorialDone");
altDriver.LoadScene("MainMenu");
void deleteKeyPlayerPref(String keyName)
Example
// Show the tutorial again: forget that the player finished it.
altDriver.deleteKeyPlayerPref("TutorialDone");
altDriver.loadScene(new AltLoadSceneParams.Builder("MainMenu").build());
alt_driver.delete_player_pref_key(key_name)
Example
# Show the tutorial again: forget that the player finished it.
alt_driver.delete_player_pref_key("TutorialDone")
alt_driver.load_scene("MainMenu")
Delete Player Pref Key key_name
Example
# Show the tutorial again: forget that the player finished it.
Delete Player Pref Key TutorialDone
Load Scene MainMenu
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The key to remove. A key that doesn’t exist is ignored. |
Returns
Nothing.
See also: DeletePlayerPref · SetKeyPlayerPref
DeletePlayerPref#
Removes every key and value from PlayerPrefs, as on a fresh install of the app.
void DeletePlayerPref()
Example
// Start the test as on a fresh install, with no saved settings or progress.
altDriver.DeletePlayerPref();
altDriver.LoadScene("MainMenu");
void deletePlayerPref()
Example
// Start the test as on a fresh install, with no saved settings or progress.
altDriver.deletePlayerPref();
altDriver.loadScene(new AltLoadSceneParams.Builder("MainMenu").build());
alt_driver.delete_player_pref()
Example
# Start the test as on a fresh install, with no saved settings or progress.
alt_driver.delete_player_pref()
alt_driver.load_scene("MainMenu")
Delete Player Pref
Example
# Start the test as on a fresh install, with no saved settings or progress.
Delete Player Pref
Load Scene MainMenu
Returns
Nothing.
See also: DeleteKeyPlayerPref
Scenes#
Find out which scenes are loaded, and load or unload them. Scenes are named as in the build’s scene list, without the path or the .unity extension.
GetCurrentScene#
Returns the name of the active scene.
string GetCurrentScene()
Example
// Go to the main menu, unless the game is already there.
if (altDriver.GetCurrentScene() != "MainMenu")
altDriver.LoadScene("MainMenu");
String getCurrentScene()
Example
// Go to the main menu, unless the game is already there.
if (!altDriver.getCurrentScene().equals("MainMenu")) {
altDriver.loadScene(new AltLoadSceneParams.Builder("MainMenu").build());
}
alt_driver.get_current_scene()
Example
# Go to the main menu, unless the game is already there.
if alt_driver.get_current_scene() != "MainMenu":
alt_driver.load_scene("MainMenu")
${scene}= Get Current Scene
Example
# Go to the main menu, unless the game is already there.
${scene}= Get Current Scene
IF $scene != 'MainMenu'
Load Scene MainMenu
END
Returns
string (C#), String (Java), str (Python, Robot): The name of the active scene. When several scenes are loaded, it is the one Unity has set as active, usually the first one loaded.
See also: GetAllLoadedScenes · WaitForCurrentSceneToBe
LoadScene#
Loads a scene, by default in place of the scenes already loaded, and waits until it has loaded.
void LoadScene(string scene, bool loadSingle = true)
Example
// Open the first level, then add the HUD scene on top of it.
altDriver.LoadScene("Level1");
altDriver.LoadScene("HUD", loadSingle: false);
void loadScene(AltLoadSceneParams params)
new AltLoadSceneParams.Builder(String sceneName)
.build()
Example
// Open the first level, then add the HUD scene on top of it.
altDriver.loadScene(new AltLoadSceneParams.Builder("Level1").build());
altDriver.loadScene(new AltLoadSceneParams.Builder("HUD").loadSingle(false).build());
alt_driver.load_scene(scene_name, load_single=True)
Example
# Open the first level, then add the HUD scene on top of it.
alt_driver.load_scene("Level1")
alt_driver.load_scene("HUD", load_single=False)
Load Scene scene_name load_single=True
Example
# Open the first level, then add the HUD scene on top of it.
Load Scene Level1
Load Scene HUD load_single=${False}
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The name of the scene. It must be in the build’s scene list. |
|
|
|
|
Returns
Nothing.
Note
In Java, set loadSingle with the builder’s loadSingle(boolean), which has no with prefix: new AltLoadSceneParams.Builder("HUD").loadSingle(false).build(). It defaults to true.
If the scene isn’t in the build’s scene list, the command fails with SceneNotFoundException.
See also: UnloadScene · WaitForCurrentSceneToBe · GetAllLoadedScenes
UnloadScene#
Unloads a scene and waits until it has unloaded.
void UnloadScene(string scene)
Example
// Open the pause menu on top of the level, then close it.
altDriver.LoadScene("PauseMenu", loadSingle: false);
altDriver.UnloadScene("PauseMenu");
void unloadScene(AltUnloadSceneParams params)
new AltUnloadSceneParams.Builder(String sceneName)
.build()
Example
// Open the pause menu on top of the level, then close it.
altDriver.loadScene(new AltLoadSceneParams.Builder("PauseMenu").loadSingle(false).build());
altDriver.unloadScene(new AltUnloadSceneParams.Builder("PauseMenu").build());
alt_driver.unload_scene(scene_name)
Example
# Open the pause menu on top of the level, then close it.
alt_driver.load_scene("PauseMenu", load_single=False)
alt_driver.unload_scene("PauseMenu")
Unload Scene scene_name
Example
# Open the pause menu on top of the level, then close it.
Load Scene PauseMenu load_single=${False}
Unload Scene PauseMenu
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The name of a loaded scene. |
Returns
Nothing.
Note
If Unity can’t unload the scene, for example because it isn’t loaded or is the only scene loaded, the command fails with CouldNotPerformOperationException.
See also: LoadScene · GetAllLoadedScenes
GetAllLoadedScenes#
Returns the names of the scenes loaded at the moment.
List<string> GetAllLoadedScenes()
Example
// Add the HUD scene, unless it is loaded already.
List<string> scenes = altDriver.GetAllLoadedScenes();
if (!scenes.Contains("HUD"))
altDriver.LoadScene("HUD", loadSingle: false);
String[] getAllLoadedScenes()
Example
// Add the HUD scene, unless it is loaded already.
String[] scenes = altDriver.getAllLoadedScenes();
if (!Arrays.asList(scenes).contains("HUD")) {
altDriver.loadScene(new AltLoadSceneParams.Builder("HUD").loadSingle(false).build());
}
alt_driver.get_all_loaded_scenes()
Example
# Add the HUD scene, unless it is loaded already.
scenes = alt_driver.get_all_loaded_scenes()
if "HUD" not in scenes:
alt_driver.load_scene("HUD", load_single=False)
${scenes}= Get All Loaded Scenes
Example
# Add the HUD scene, unless it is loaded already.
${scenes}= Get All Loaded Scenes
IF 'HUD' not in $scenes
Load Scene HUD load_single=${False}
END
Returns
List<string> (C#), String[] (Java), list of str (Python, Robot): The names of the loaded scenes.
See also: GetCurrentScene · LoadScene · UnloadScene
WaitForCurrentSceneToBe#
Waits until a scene is the active scene, for example after a tap that opens a new level.
void WaitForCurrentSceneToBe(
string sceneName,
double timeout = 20,
double interval = 1)
Example
// Press Play on the main menu and give the first level 10 seconds to open.
altDriver.FindObject(By.NAME, "PlayButton").Tap();
altDriver.WaitForCurrentSceneToBe("Level1", timeout: 10);
void waitForCurrentSceneToBe(AltWaitForCurrentSceneToBeParams params)
new AltWaitForCurrentSceneToBeParams.Builder(String sceneName)
.withTimeout(double timeout) // default 20
.withInterval(double interval) // default 0.5
.build()
Example
// Press Play on the main menu and give the first level 10 seconds to open.
altDriver.findObject(
new AltFindObjectsParams.Builder(AltDriver.By.NAME, "PlayButton").build()).tap();
altDriver.waitForCurrentSceneToBe(
new AltWaitForCurrentSceneToBeParams.Builder("Level1").withTimeout(10).build());
alt_driver.wait_for_current_scene_to_be(
scene_name,
timeout=20,
interval=1)
Example
# Press Play on the main menu and give the first level 10 seconds to open.
alt_driver.find_object(By.NAME, "PlayButton").tap()
alt_driver.wait_for_current_scene_to_be("Level1", timeout=10)
Wait For Current Scene To Be scene_name timeout=30 interval=1
Example
# Press Play on the main menu and give the first level 10 seconds to open.
${button}= Find Object NAME PlayButton
Tap Object ${button}
Wait For Current Scene To Be Level1 timeout=10
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The name of the scene to wait for. |
|
C#, Java: |
|
Seconds to wait. If the scene isn’t active by then, the command fails with |
|
C#, Java: |
|
Seconds between checks of the active scene. |
Returns
Nothing.
Note
In C#, Java and Python, if you set an implicit timeout with SetImplicitTimeout (Timeouts), it replaces a timeout left at its default of 20. The Robot Framework keyword’s default is 30, so it isn’t replaced.
See also: GetCurrentScene · LoadScene
Screen and time scale#
GetApplicationScreenSize#
Returns the width and height of the app’s screen, in pixels (Unity’s Screen.width and Screen.height).
AltVector2 GetApplicationScreenSize()
Example
// Tap the middle of the screen.
AltVector2 size = altDriver.GetApplicationScreenSize();
altDriver.Tap(new AltVector2(size.x / 2, size.y / 2));
int[] getApplicationScreenSize()
Example
// Tap the middle of the screen.
int[] size = altDriver.getApplicationScreenSize();
altDriver.tap(new AltTapClickCoordinatesParams.Builder(
new Vector2(size[0] / 2f, size[1] / 2f)).build());
alt_driver.get_application_screensize()
Example
# Tap the middle of the screen.
width, height = alt_driver.get_application_screensize()
alt_driver.tap([width / 2, height / 2])
${size}= Get Application Screensize
Example
# Tap the middle of the screen.
${width} ${height}= Get Application Screensize
${middle}= Evaluate [${width} / 2, ${height} / 2]
Tap ${middle}
Returns
AltVector2 (C#), int[] (Java), tuple (Python, Robot): The width and the height: x and y in C#, the two items of the array or tuple in the other languages.
Note
The size is in the same pixels as the screen positions that input actions such as Tap take.
GetTimeScale#
Returns the app’s time scale (Unity’s Time.timeScale): 1 is normal speed.
float GetTimeScale()
Example
// Slow the game down for a quick-time event, then restore its speed.
float speed = altDriver.GetTimeScale();
altDriver.SetTimeScale(0.25f);
altDriver.PressKey(AltKeyCode.Space);
altDriver.SetTimeScale(speed);
float getTimeScale()
Example
// Slow the game down for a quick-time event, then restore its speed.
float speed = altDriver.getTimeScale();
altDriver.setTimeScale(new AltSetTimeScaleParams.Builder(0.25f).build());
altDriver.pressKey(new AltPressKeyParams.Builder(AltKeyCode.Space).build());
altDriver.setTimeScale(new AltSetTimeScaleParams.Builder(speed).build());
alt_driver.get_time_scale()
Example
from alttester import AltKeyCode
# Slow the game down for a quick-time event, then restore its speed.
speed = alt_driver.get_time_scale()
alt_driver.set_time_scale(0.25)
alt_driver.press_key(AltKeyCode.Space)
alt_driver.set_time_scale(speed)
${time_scale}= Get Time Scale
Example
# Slow the game down for a quick-time event, then restore its speed.
${speed}= Get Time Scale
Set Time Scale 0.25
Press Key Space
Set Time Scale ${speed}
Returns
float: The time scale.
See also: SetTimeScale
SetTimeScale#
Sets the app’s time scale (Unity’s Time.timeScale), to run the game faster or slower: 2 is twice as fast, 0.5 half as fast, and 0 stops time-based movement.
void SetTimeScale(float timeScale)
Example
// Run the intro four times faster, then go back to normal speed.
altDriver.SetTimeScale(4);
altDriver.WaitForCurrentSceneToBe("MainMenu");
altDriver.SetTimeScale(1);
void setTimeScale(AltSetTimeScaleParams params)
new AltSetTimeScaleParams.Builder(float timeScale)
.build()
Example
// Run the intro four times faster, then go back to normal speed.
altDriver.setTimeScale(new AltSetTimeScaleParams.Builder(4).build());
altDriver.waitForCurrentSceneToBe(
new AltWaitForCurrentSceneToBeParams.Builder("MainMenu").build());
altDriver.setTimeScale(new AltSetTimeScaleParams.Builder(1).build());
alt_driver.set_time_scale(time_scale)
Example
# Run the intro four times faster, then go back to normal speed.
alt_driver.set_time_scale(4)
alt_driver.wait_for_current_scene_to_be("MainMenu")
alt_driver.set_time_scale(1)
Set Time Scale time_scale
Example
# Run the intro four times faster, then go back to normal speed.
Set Time Scale 4
Wait For Current Scene To Be MainMenu
Set Time Scale 1
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The new time scale. 1 is normal speed. |
Returns
Nothing.
Note
The time scale stays as you set it after the test ends. Set it back to 1, or to what GetTimeScale returned before.
See also: GetTimeScale
Static methods and properties#
Call static methods, and read or set static fields and properties, of the app’s classes and of Unity’s. Name a class with its namespace, such as UnityEngine.Screen, and give the assembly that contains it: Assembly-CSharp for your own scripts, UnityEngine.CoreModule for most of Unity’s classes.
CallStaticMethod#
Calls a public static method of a class in the app and returns its result.
T CallStaticMethod<T>(
string typeName,
string methodName,
string assemblyName,
object[] parameters,
string[] typeOfParameters = null)
Example
// Switch the app to a 1280x720 window. SetResolution has several overloads
// with three arguments, so name the argument types.
altDriver.CallStaticMethod<string>(
"UnityEngine.Screen", "SetResolution", "UnityEngine.CoreModule",
new object[] { 1280, 720, false },
new[] { "System.Int32", "System.Int32", "System.Boolean" });
<T> T callStaticMethod(
AltCallStaticMethodParams params,
Class<T> returnType)
new AltCallStaticMethodParams.Builder(
String component,
String method,
String assembly,
Object[] parameters)
.withTypeOfParameters(String[] typeOfParameters) // default null
.build()
Example
// Switch the app to a 1280x720 window. SetResolution has several overloads
// with three arguments, so name the argument types.
altDriver.callStaticMethod(
new AltCallStaticMethodParams.Builder("UnityEngine.Screen", "SetResolution",
"UnityEngine.CoreModule", new Object[] { 1280, 720, false })
.withTypeOfParameters(
new String[] { "System.Int32", "System.Int32", "System.Boolean" })
.build(),
Void.class);
alt_driver.call_static_method(
type_name,
method_name,
assembly,
parameters=None,
type_of_parameters=None)
Example
# Switch the app to a 1280x720 window. SetResolution has several overloads
# with three arguments, so name the argument types.
alt_driver.call_static_method(
"UnityEngine.Screen", "SetResolution", "UnityEngine.CoreModule",
parameters=[1280, 720, False],
type_of_parameters=["System.Int32", "System.Int32", "System.Boolean"])
${result}= Call Static Method type_name method_name assembly parameters=None type_of_parameters=None
Example
# Switch the app to a 1280x720 window. SetResolution has several overloads
# with three arguments, so name the argument types.
${arguments}= Create List ${1280} ${720} ${False}
${types}= Create List System.Int32 System.Int32 System.Boolean
Call Static Method UnityEngine.Screen SetResolution UnityEngine.CoreModule
... parameters=${arguments} type_of_parameters=${types}
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The class, with its namespace, such as |
|
|
required |
The method. For a method of a static field or property, write |
|
|
required |
The assembly that contains the class. |
|
C#: |
required (C#, Java) |
The method’s arguments, in order. Each one is sent as JSON. For a method without arguments, pass an empty array in C# and Java, and leave it out in Python and Robot Framework. |
|
C#: |
|
The .NET type of each argument, such as |
Returns
T (C#, Java), object (Python, Robot): What the method returns. In C#, give its type as T; in Java, pass its class as returnType, such as Integer.class, or Void.class for a void method. In Python and Robot Framework, it is the result decoded from JSON.
See also: GetStaticProperty · SetStaticProperty
GetStaticProperty#
Returns the value of a static field or property of a class in the app.
T GetStaticProperty<T>(
string componentName,
string propertyName,
string assemblyName,
int maxDepth = 2)
Example
// Read the width of the screen's current resolution.
int width = altDriver.GetStaticProperty<int>(
"UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule");
<T> T getStaticProperty(
AltGetComponentPropertyParams params,
Class<T> returnType)
new AltGetComponentPropertyParams.Builder(
String componentName,
String propertyName,
String assembly)
.withMaxDepth(int maxDepth) // default 2
.build()
Example
// Read the width of the screen's current resolution.
int width = altDriver.getStaticProperty(
new AltGetComponentPropertyParams.Builder(
"UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule")
.build(),
Integer.class);
alt_driver.get_static_property(
component_name,
property_name,
assembly,
max_depth=2)
Example
# Read the width of the screen's current resolution.
width = alt_driver.get_static_property(
"UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule")
${value}= Get Static Property component_name property_name assembly max_depth=2
Example
# Read the width of the screen's current resolution.
${width}= Get Static Property
... UnityEngine.Screen currentResolution.width UnityEngine.CoreModule
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The class, with its namespace, such as |
|
|
required |
The static field or property. To read a field of its value, add it after a dot: |
|
|
required |
The assembly that contains the class. |
|
|
|
When the value is an object, how many levels of its fields to return. Deeper fields are left out. |
Returns
T (C#, Java), object (Python, Robot): The value. In C#, give its type as T; in Java, pass its class as returnType, such as Integer.class. In Python and Robot Framework, it is the value decoded from JSON.
See also: SetStaticProperty · CallStaticMethod
SetStaticProperty#
Sets the value of a static field or property of a class in the app.
void SetStaticProperty(
string componentName,
string propertyName,
string assemblyName,
object updatedProperty)
Example
// Cap the frame rate at 30 frames per second.
altDriver.SetStaticProperty(
"UnityEngine.Application", "targetFrameRate", "UnityEngine.CoreModule", 30);
void setStaticProperty(AltSetComponentPropertyParams params)
new AltSetComponentPropertyParams.Builder(
String componentName,
String propertyName,
String assembly,
Object value)
.build()
Example
// Cap the frame rate at 30 frames per second.
altDriver.setStaticProperty(
new AltSetComponentPropertyParams.Builder(
"UnityEngine.Application", "targetFrameRate", "UnityEngine.CoreModule", 30)
.build());
alt_driver.set_static_property(
component_name,
property_name,
assembly,
updated_value)
Example
# Cap the frame rate at 30 frames per second.
alt_driver.set_static_property(
"UnityEngine.Application", "targetFrameRate", "UnityEngine.CoreModule", 30)
Set Static Property component_name property_name assembly updated_value
Example
# Cap the frame rate at 30 frames per second.
Set Static Property
... UnityEngine.Application targetFrameRate UnityEngine.CoreModule 30
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
The class, with its namespace, such as |
|
|
required |
The static field or property. |
|
|
required |
The assembly that contains the class. |
|
C#, Java: |
required |
The new value. |
Returns
Nothing.
Note
C# and Java send the value as JSON. Python and Robot Framework send it as it is, so a number works, but a string must be written as JSON, in double quotes: '"Player 1"' in Python, "Player 1" in Robot Framework.
See also: GetStaticProperty · CallStaticMethod