pyunity.files module

Module to load files and scripts. Also manages project structure.

class pyunity.files.Behaviour(transform, is_dummy=False)[source]

Bases: pyunity.core.Component

Base class for behaviours that can be scripted.

gameObject

GameObject that the component belongs to.

Type:GameObject
transform

Transform that the component belongs to.

Type:Transform
AddComponent(component)

Calls AddComponent on the component’s GameObject.

Parameters:component (Component) – Component to add. Must inherit from Component
FixedUpdate(dt)[source]

Called every frame, in each physics step.

Parameters:dt (float) – Length of this physics step
GetComponent(component)

Calls GetComponent on the component’s GameObject.

Parameters:componentClass (Component) – Component to get. Must inherit from Component
GetComponents(component)

Calls GetComponents on the component’s GameObject.

Parameters:componentClass (Component) – Component to get. Must inherit from Component
LateUpdate(dt)[source]

Called every frame, after physics processing.

Parameters:dt (float) – Time since last frame, sent by the scene that the Behaviour is in.
RemoveComponent(component)

Calls RemoveComponent on the component’s GameObject.

Parameters:component (Component) – Component to remove. Must inherit from Component
RemoveComponents(component)

Calls RemoveComponents on the component’s GameObject.

Parameters:component (Component) – Component to remove. Must inherit from Component
Start()[source]

Called every time a scene is loaded up.

Update(dt)[source]

Called every frame.

Parameters:dt (float) – Time since last frame, sent by the scene that the Behaviour is in.
class pyunity.files.Texture2D(path)[source]

Bases: object

Class to represent a texture.

load()[source]

Loads the texture and sets up an OpenGL texture name.

use()[source]

Binds the texture for usage. The texture is reloaded if it hasn’t already been.

pyunity.files.convert(type, list)[source]

Converts a Python array to a C type from ctypes.

Parameters:
  • type (_ctypes.PyCSimpleType) – Type to cast to.
  • list (list) – List to cast
Returns:

A C array

Return type:

Any