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.files module¶
Source code: pyunity/files.py
Module to load files and scripts. Also manages project structure.
- class pyunity.files.Behaviour[source]¶
Bases:
Component
Base class for behaviours that can be scripted.
- Awake()[source]¶
Called every time a scene is loaded up, regardless whether the Behaviour is enabled or not. Cannot be an
async
function.
- async Start()[source]¶
Called every time a scene is loaded up. Only called when the Behaviour is enabled. Can be either a normal function or an
async
function.
- async Update(dt)[source]¶
Called every frame. Can be either a normal function or an
async
function.- Parameters
dt (float) – Time since last frame, sent by the scene that the Behaviour is in.
- async FixedUpdate(dt)[source]¶
Called every frame, in each physics step. Can be either a normal function or an
async
function.- Parameters
dt (float) – Length of this physics step
- async LateUpdate(dt)[source]¶
Called every frame, after physics processing. Can be either a normal function or an
async
function.- Parameters
dt (float) – Time since last frame, sent by the scene that the Behaviour is in.
- async OnPreRender()[source]¶
Called before rendering happens. Can be either a normal function or an
async
function.
- class pyunity.files.Scripts[source]¶
Bases:
object
Utility class for loading scripts in a folder.
- static CheckScript(text)[source]¶
Check if
text
is a valid script for PyUnity.Notes
This function checks each line to see if it matches at least one of these criteria:
The line is an
import
statementThe line is just whitespace or blank
The line is just a comment preceded by whitespace or nothing
The line is a class definition
The line has an indentation at the beginning
These checks are essential to ensure no malicious code is run to break the PyUnity engine.
- static LoadScript(path)[source]¶
Loads a PyUnity script by path.
- Parameters
path (Pathlike) – A path to a PyUnity script
- Returns
The module that contains all the imported scripts
- Return type
ModuleType
Notes
This function will add a module to
sys.modules
that is calledPyUnityScripts
, and can be imported like any other module. The module will also have a variable called__pyunity__
which shows that it is from PyUnity and not a real module. If an existing module namedPyUnityScripts
is present and does not have the__pyunity__
variable set, then a warning will be issued and it will be replaced.
- class pyunity.files.Asset[source]¶
Bases:
SavesProjectID
- class pyunity.files.Skybox[source]¶
Bases:
object
Skybox model consisting of 6 images
- points = [-1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1]¶
Type:
list