pyunity.scene module

class pyunity.scene.Scene(name)[source]

Bases: object

Class to hold all of the GameObjects, and to run the whole scene.

Notes

Create a scene using the SceneManager, and don’t create a scene directly using this class.

Add(gameObject)[source]

Add a GameObject to the scene.

Parameters

gameObject (GameObejct) – The GameObject to add.

FindGameObjectsByName(name)[source]

Finds all GameObjects matching the specified name.

Parameters

name (str) – Name of the GameObject

Returns

List of the matching GameObjects

Return type

list

FindGameObjectsByTagName(name)[source]

Finds all GameObjects with the specified tag name.

Parameters

name (str) – Name of the tag

Returns

List of matching GameObjects

Return type

list

Raises

GameObjectException – When there is no tag named name

FindGameObjectsByTagNumber(num)[source]

Gets all GameObjects with a tag of tag num.

Parameters

num (int) – Index of the tag

Returns

List of matching GameObjects

Return type

list

Raises

GameObjectException – If there is no tag with specified index.

List()[source]

Lists all the GameObjects currently in the scene.

Remove(gameObject)[source]

Remove a GameObject from the scene.

Parameters

gameObject (GameObject) – GameObject to remove.

Raises

PyUnityException – If the specified GameObject is the Main Camera.

Run()[source]

Run the scene and create a window for it.

start_scripts()[source]
transform(transform)[source]

Transform the matrix by a specified transform.

Parameters

transform (Transform) – Transform to move

update()[source]

Updating function to pass to the window provider.

update_scripts()[source]
class pyunity.scene.SceneManager[source]

Bases: object

Class to manage scenes.

scenesByIndex

List of scenes

Type

list

scenesByName

Dictionary of scenes, with the scene names as the keys.

Type

dict

AddScene(sceneName)[source]

Add a scene to the SceneManager. Pass in a scene name to create a scene.

Parameters

sceneName (str) – Name of the scene

Returns

Newly created scene

Return type

Scene

Raises

PyUnityException – If there already exists a scene called sceneName

GetSceneByIndex(index)[source]

Get a scene by its index.

Parameters

index (int) – Index of the scene

Returns

Specified scene at index index

Return type

Scene

Raises

IndexError – If there is no scene at the specified index

GetSceneByName(name)[source]

Get a scene by its name.

Parameters

name (str) – Name of the scene

Returns

Specified scene with name of name

Return type

Scene

Raises

KeyError – If there is no scene called name