pyunity.loader module

Utility functions related to loading and saving PyUnity meshes and scenes.

This will be imported as pyunity.Loader.

pyunity.loader.LoadMesh(filename)[source]

Loads a .mesh file generated by SaveMesh. It is optimized for faster loading.

Parameters:filename (str) – Name of file relative to the cwd
Returns:Generated mesh
Return type:Mesh
pyunity.loader.LoadObj(filename)[source]

Loads a .obj file to a PyUnity mesh.

Parameters:filename (str) – Name of file
Returns:A mesh of the object file
Return type:Mesh
pyunity.loader.LoadScene(sceneName, filePath=None)[source]

Load a scene from a file. Uses pickle.

Parameters:sceneName (str) – Name of the scene, without the .scene extension
Returns:Loaded scene
Return type:Scene

Notes

If there already is a scene called sceneName, then no scene will be added.

pyunity.loader.SaveMesh(mesh, name, filePath=None)[source]

Saves a mesh to a .mesh file for faster loading.

Parameters:
  • mesh (Mesh) – Mesh to save
  • name (str) – Name of the mesh
  • filePath (str, optional) – Pass in __file__ to save in directory of script, otherwise pass in the path of where you want to save the file. For example, if you want to save in C:Downloads, then give “C:Downloadsmesh.mesh”. If not specified, then the mesh is saved in the cwd.
pyunity.loader.SaveScene(scene, filePath=None)[source]

Save a scene to a file. Uses pickle.

Parameters:
  • scene (Scene) – Scene to save
  • filePath (str, optional) – Pass in __file__ to save in directory of script, otherwise pass in a directory. If not specified, then the scene is saved in the cwd.