pyunity.loader module

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

This will be imported as pyunity.Loader.


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.SaveObj(mesh, name, filePath=None)[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.SaveMesh(mesh, name, filePath=None)[source]

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

  • 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.SaveSceneToProject(scene, filePath=None, name=None)[source]
pyunity.loader.SaveAllScenes(name, filePath=None)[source]
pyunity.loader.GetId(ids, obj)[source]
pyunity.loader.SaveScene(scene, project)[source]
class pyunity.loader.ObjectInfo(uuid, type, attrs)[source]

Bases: object

pyunity.loader.components = {'AABBoxCollider': <class 'pyunity.physics.core.AABBoxCollider'>, 'AudioListener': <class ''>, 'AudioSource': <class ''>, 'Camera': <class 'pyunity.render.Camera'>, 'Light': <class 'pyunity.core.Light'>, 'MeshRenderer': <class 'pyunity.core.MeshRenderer'>, 'Rigidbody': <class 'pyunity.physics.core.Rigidbody'>, 'SphereCollider': <class 'pyunity.physics.core.SphereCollider'>, 'Transform': <class 'pyunity.core.Transform'>}

List of all components by name

class pyunity.loader.Primitives[source]

Bases: object

Primitive preloaded meshes. Do not instantiate this class.