Skip to content

create_camera

CreateCamera

Bases: UnrealAssetCreator

Create Camera.

Source code in client/ayon_unreal/plugins/create/create_camera.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class CreateCamera(UnrealAssetCreator):
    """Create Camera."""

    identifier = "io.ayon.creators.unreal.camera"
    label = "Camera"
    product_type = "camera"
    icon = "fa.camera"

    def create(self, product_name, instance_data, pre_create_data):
        if pre_create_data.get("use_selection"):
            sel_objects = unreal.EditorUtilityLibrary.get_selected_assets()
            selection = [a.get_path_name() for a in sel_objects]

            if len(selection) != 1:
                raise CreatorError("Please select only one object.")

        # Add the current level path to the metadata
        if UNREAL_VERSION.major == 5:
            world = unreal.UnrealEditorSubsystem().get_editor_world()
        else:
            world = unreal.EditorLevelLibrary.get_editor_world()

        instance_data["level"] = world.get_path_name()

        super(CreateCamera, self).create(
            product_name,
            instance_data,
            pre_create_data)