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¶
Source code: pyunity/scenes/scene.py
Class to load, render and manage GameObjects and their various components.
You should never use the Scene
class directly, instead, only use
the SceneManager
class.
- class pyunity.scenes.scene.Scene[source]¶
Bases:
Asset
Class to hold all of the GameObjects, and to run the whole scene.
- Parameters:
name (str) – Name of the scene
Notes
Create a scene using the SceneManager, and don’t create a scene directly using this class.
- property rootGameObjects¶
All GameObjects which have no parent
- Add(gameObject)[source]¶
Add a GameObject to the scene.
- Parameters:
gameObject (GameObject) – The GameObject to add.
- AddMultiple(*args)[source]¶
Add GameObjects to the scene.
- Parameters:
*args (list) – A list of GameObjects to add.
- Destroy(gameObject)[source]¶
Remove a GameObject from the scene.
- Parameters:
gameObject (GameObject) – GameObject to remove.
- Raises:
PyUnityException – If the specified GameObject is not part of the Scene.
- Has(gameObject)[source]¶
Check if a GameObject is in the scene.
- Parameters:
gameObject (GameObject) – Query GameObject
- Returns:
If the GameObject exists in the scene
- Return type:
- 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:
- 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:
- Raises:
GameObjectException – If there is no tag with specified index.
- FindComponent(component)[source]¶
Finds the first matching Component that is in the Scene.
- Parameters:
component (type) – Component type
- Returns:
The matching Component
- Return type:
- Raises:
ComponentException – If the component is not found
- insideFrustrum(renderer)[source]¶
Check if the renderer’s mesh can be seen by the main camera.
- Parameters:
renderer (MeshRenderer) – Renderer to test
- Returns:
If the mesh can be seen
- Return type: