Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

# pyunity.scenes.scene module¶

Class to load, render and manage GameObjects and their various components.

You should never use the class directly, instead, only use the SceneManager class.

class pyunity.scenes.scene.Scene[source]

Bases:

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

Parameters

name () – Name of the scene

Notes

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

GetAssetFile(gameObject)[source]
SaveAsset(ctx)[source]
static Bare(name)[source]

Create a bare scene.

Parameters

name () – Name of the scene

Returns

A bare scene with no GameObjects

Return type

property rootGameObjects

All GameObjects which have no parent

Add a GameObject to the scene.

Parameters

gameObject () – The GameObject to add.

Parameters

*args () – A list of GameObjects to add.

Destroy(gameObject)[source]

Remove a GameObject from the scene.

Parameters

gameObject () – GameObject to remove.

Raises

– If the specified GameObject is not part of the Scene.

Has(gameObject)[source]

Check if a GameObject is in the scene.

Parameters

gameObject () – Query GameObject

Returns

If the GameObject exists in the scene

Return type

List()[source]

Lists all the GameObjects currently in the scene.

FindGameObjectsByName(name)[source]

Finds all GameObjects matching the specified name.

Parameters

name () – Name of the GameObject

Returns

List of the matching GameObjects

Return type

FindGameObjectsByTagName(name)[source]

Finds all GameObjects with the specified tag name.

Parameters

name () – Name of the tag

Returns

List of matching GameObjects

Return type

Raises

– When there is no tag named name

FindGameObjectsByTagNumber(num)[source]

Gets all GameObjects with a tag of tag num.

Parameters

num () – Index of the tag

Returns

List of matching GameObjects

Return type

Raises

– If there is no tag with specified index.

FindComponent(component)[source]

Finds the first matching Component that is in the Scene.

Parameters

component () – Component type

Returns

The matching Component

Return type

Raises

FindComponents(component)[source]

Finds all matching Components that are in the Scene.

Parameters

component () – Component type

Returns

List of the matching Components

Return type

insideFrustrum(renderer)[source]

Check if the renderer’s mesh can be seen by the main camera.

Parameters

renderer () – Renderer to test

Returns

If the mesh can be seen

Return type

startOpenGL()[source]
startScripts()[source]
startLoop()[source]
Start()[source]

Start the internal parts of the Scene. Deprecated in 0.9.0.

Updates all scripts in the scene.

updateFixed(loop)[source]
Render(loop=None)[source]

Call the appropriate rendering functions of the Main Camera.

Parameters

loop () – Event loop to run Behaviour.OnPreRender() and Behaviour.OnPostRender() in. If None, the above methods will not be called.

cleanUp()[source]

Called when the scene finishes running, or stops running.