Exemplo n.º 1
0
 def test_variable(self):
     new_blueprint = ue.create_blueprint(Character, '/Game/Tests/Blueprints/Test2_' + self.random_string)
     ue.blueprint_add_member_variable(new_blueprint, 'TestValue', 'int')
     ue.compile_blueprint(new_blueprint)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     new_actor.TestValue = 17
     self.assertEqual(new_actor.get_property('TestValue'), 17)
Exemplo n.º 2
0
    def create_blueprint_from_mesh(self):
        new_blueprint = ue.find_asset(self.path_to_output_asset + '/main_mesh')
        if new_blueprint is None:
            ue.log("blueprint class doesn't exists")
            new_blueprint = ue.create_blueprint(
                Character, self.path_to_output_asset + '/main_mesh')
        else:
            ue.log("blueprint class exists")
            new_blueprint = ue.find_asset(self.path_to_output_asset +
                                          '/main_mesh')
        # new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeLocation = FVector(0, -200, 150)
        # new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeRotation = FRotator(0, 0, 0)
        # add empty static mesh component to blueprint class
        new_blueprint.GeneratedClass.get_cdo(
        ).CapsuleComponent.CapsuleHalfHeight = 150
        new_blueprint.GeneratedClass.get_cdo(
        ).CapsuleComponent.CapsuleRadius = 50
        st_component = ue.add_component_to_blueprint(new_blueprint,
                                                     StaticMeshComponent,
                                                     'dicom_mesh')
        ue.log("self.mesh.get_name() = " + self.mesh.get_name())
        st_component.StaticMesh = ue.load_object(
            StaticMesh, self.path_to_output_asset + "/test_test")

        ue.compile_blueprint(new_blueprint)

        # saves uasset on the hard disk
        new_blueprint.save_package()

        world = ue.get_editor_world()
        new_actor = world.actor_spawn(new_blueprint.GeneratedClass,
                                      FVector(0, 0, 150))
Exemplo n.º 3
0
 def test_variable(self):
     new_blueprint = ue.create_blueprint(
         Character, '/Game/Tests/Blueprints/Test2_' + self.random_string)
     ue.blueprint_add_member_variable(new_blueprint, 'TestValue', 'int')
     ue.compile_blueprint(new_blueprint)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     new_actor.TestValue = 17
     self.assertEqual(new_actor.get_property('TestValue'), 17)
Exemplo n.º 4
0
 def test_event(self):
     new_blueprint = ue.create_blueprint(Character, '/Game/Tests/Blueprints/Test3_' + self.random_string)
     uber_page = new_blueprint.UberGraphPages[0]
     x, y = uber_page.graph_get_good_place_for_new_node()
     test_event = uber_page.graph_add_node_custom_event('TestEvent', x, y)
     x, y = uber_page.graph_get_good_place_for_new_node()
     node_set_actor_location = uber_page.graph_add_node_call_function(Actor.K2_SetActorLocation, x, y)
     test_event.node_find_pin('then').make_link_to(node_set_actor_location.node_find_pin('execute'))
     node_set_actor_location.node_find_pin('NewLocation').default_value = '17,30,22'
     ue.compile_blueprint(new_blueprint)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     self.assertEqual(new_actor.get_actor_location(), FVector(0, 0, 0))
     ue.allow_actor_script_execution_in_editor(True)
     new_actor.TestEvent()
     self.assertEqual(new_actor.get_actor_location(), FVector(17, 30, 22))
Exemplo n.º 5
0
 def test_event(self):
     new_blueprint = ue.create_blueprint(
         Character, '/Game/Tests/Blueprints/Test3_' + self.random_string)
     uber_page = new_blueprint.UberGraphPages[0]
     x, y = uber_page.graph_get_good_place_for_new_node()
     test_event = uber_page.graph_add_node_custom_event('TestEvent', x, y)
     x, y = uber_page.graph_get_good_place_for_new_node()
     node_set_actor_location = uber_page.graph_add_node_call_function(
         Actor.K2_SetActorLocation, x, y)
     test_event.node_find_pin('then').make_link_to(
         node_set_actor_location.node_find_pin('execute'))
     node_set_actor_location.node_find_pin(
         'NewLocation').default_value = '17,30,22'
     ue.compile_blueprint(new_blueprint)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     self.assertEqual(new_actor.get_actor_location(), FVector(0, 0, 0))
     ue.allow_actor_script_execution_in_editor(True)
     new_actor.TestEvent()
     self.assertEqual(new_actor.get_actor_location(), FVector(17, 30, 22))
import unreal_engine as ue
from unreal_engine.classes import K2Node_InputKey, K2Node_SpawnActorFromClass, Actor, Character, KismetMathLibrary
from unreal_engine.structs import Key

# create  a new blueprint
new_blueprint = ue.create_blueprint(Actor, '/Game/StrangeBlueprint')

# add a member float variable
ue.blueprint_add_member_variable(new_blueprint, 'Speed', 'float')

# get a reference to the first graph page
uber_page = new_blueprint.UberGraphPages[0]

# get good coordinates for a new node
x, y = uber_page.graph_get_good_place_for_new_node()
# add the Speed variable to the graph
uber_page.graph_add_node_variable_get('Speed', None, x, y)

x, y = uber_page.graph_get_good_place_for_new_node()
# add a custom event to the graph
hello_world = uber_page.graph_add_node_custom_event('Hello World', x, y)

# get a reference to the 'then' pin
hello_world_then = hello_world.node_find_pin('then')

x, y = uber_page.graph_get_good_place_for_new_node()
# add a 'Spawn Actor From Class' node
spawn_actor_node = uber_page.graph_add_node(K2Node_SpawnActorFromClass, x, y)

# set its Class pin
pin_class = spawn_actor_node.node_find_pin('Class')
Exemplo n.º 7
0
 def test_spawn(self):
     new_blueprint = ue.create_blueprint(
         Character, '/Game/Tests/Blueprints/Test1_' + self.random_string)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     self.assertTrue(new_actor.is_a(Character))
Exemplo n.º 8
0
 def test_creation(self):
     new_blueprint = ue.create_blueprint(
         Actor, '/Game/Tests/Blueprints/Test0_' + self.random_string)
     ue.log(new_blueprint.ParentClass)
     self.assertEqual(new_blueprint.ParentClass, Actor)
     self.assertNotEqual(new_blueprint.ParentClass, Character)
Exemplo n.º 9
0
# add a cone
cone = world.actor_spawn(Actor)
cone.set_actor_label('A Cone')
cone_mesh = cone.add_actor_component(StaticMeshComponent, 'Cone')
cone_mesh.StaticMesh = ue.load_object(StaticMesh, '/Engine/BasicShapes/Cone')
cone.InitialLifeSpan = 30.0

# add a better cone
cone2 = world.actor_spawn(StaticMeshActor)
cone2.StaticMeshComponent.StaticMesh = ue.load_object(
    StaticMesh, '/Engine/BasicShapes/Cone')
cone2.set_actor_label('A Better Cone')

# create a new bleprint
bp = ue.create_blueprint(Pawn, '/Game/SuperEvilPawn')
ue.add_component_to_blueprint(bp, PawnSensingComponent, 'Eyes')
point_light = ue.add_component_to_blueprint(bp, PointLightComponent, 'Light')
point_light.Intensity = 9999.9
ue.blueprint_add_member_variable(bp, 'SightPower', 'float')
ue.blueprint_set_variable_visibility(bp, 'SightPower', False)

ue.compile_blueprint(bp)

# instantiate a new actor using the previously created blueprint
super_evil_pawn = world.actor_spawn(bp.GeneratedClass)
super_evil_pawn.set_actor_label('Super Evil Pawn')
super_evil_pawn.SightPower = 2217.30

# save them all
ue.editor_save_all()
Exemplo n.º 10
0
import unreal_engine as ue

from unreal_engine.classes import Material, BlueprintFactory, Blueprint, Actor, Texture2D, SkeletalMesh
from unreal_engine.structs import EdGraphPinType, Vector, Rotator, EdGraphTerminalType
from unreal_engine.enums import EPinContainerType

import time

bp = ue.create_blueprint(Actor, '/Game/FooActor' + str(int(time.time())))

pin = EdGraphPinType(PinCategory='object', PinSubCategoryObject=Material)
ue.blueprint_add_member_variable(
    bp, 'TestMat', pin, None,
    '/Engine/MapTemplates/Materials/BasicAsset03.BasicAsset03')

pin = EdGraphPinType(PinCategory='class', PinSubCategoryObject=Texture2D)
ue.blueprint_add_member_variable(bp, 'TestTextureClass', pin)

pin = EdGraphPinType(PinCategory='struct', PinSubCategoryObject=Vector)
ue.blueprint_add_member_variable(bp, 'TestVector', pin, None, '17,22,30')

pin = EdGraphPinType(PinCategory='struct',
                     PinSubCategoryObject=Rotator,
                     ContainerType=EPinContainerType.Array)
ue.blueprint_add_member_variable(
    bp, 'TestRotator', pin, None,
    '((Pitch=0.000000,Yaw=3.000000,Roll=0.000000),(Pitch=1.000000,Yaw=0.000000,Roll=0.000000))'
)

pin = EdGraphPinType(PinCategory='string',
                     ContainerType=EPinContainerType.Map,
Exemplo n.º 11
0
# re-save it
mat.save_package()


# import the animation

anim_factory = PyFbxFactory()
anim_factory.ImportUI.Skeleton = mesh.Skeleton
anim_factory.ImportUI.bImportMesh = False
anim_factory.ImportUI.bImportMaterials = False
anim_factory.ImportUI.bImportTextures = False
anim_factory.ImportUI.AnimSequenceImportData.ImportUniformScale = 0.1;

animation = anim_factory.factory_import_object(os.path.join(kaiju_source, kaiju_animation), kaiju_destination)

new_blueprint = ue.create_blueprint(Character, kaiju_destination + '/Kaiju_BP')

new_blueprint.GeneratedClass.get_cdo().Mesh.SkeletalMesh = mesh
new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeLocation = FVector(0, 0, -140)
new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeRotation = FRotator(0, 0, -90)
new_blueprint.GeneratedClass.get_cdo().CapsuleComponent.CapsuleHalfHeight = 150
new_blueprint.GeneratedClass.get_cdo().CapsuleComponent.CapsuleRadius = 50

new_blueprint.GeneratedClass.get_cdo().Mesh.OverrideMaterials = [None, mat]

new_blueprint.GeneratedClass.get_cdo().Mesh.AnimationMode = EAnimationMode.AnimationSingleNode
new_blueprint.GeneratedClass.get_cdo().Mesh.AnimationData = SingleAnimationPlayData(AnimToPlay=animation)

# move forward
tick = new_blueprint.UberGraphPages[0].graph_add_node_event(Actor, 'ReceiveTick')
add_movement_input = new_blueprint.UberGraphPages[0].graph_add_node_call_function(Character.AddMovementInput)
Exemplo n.º 12
0
import unreal_engine as ue
from unreal_engine.classes import K2Node_InputKey, K2Node_SpawnActorFromClass, Actor, Character, KismetMathLibrary

# create  a new blueprint
new_blueprint = ue.create_blueprint(Actor, '/Game/StrangeBlueprint')

# add a member float variable
ue.blueprint_add_member_variable(new_blueprint, 'Speed', 'float')

# get a reference to the first graph page
uber_page = new_blueprint.UberGraphPages[0]

# get good coordinates for a new node
x, y = uber_page.graph_get_good_place_for_new_node()
# add the Speed variable to the graph
uber_page.graph_add_node_variable_get('Speed', None, x, y)

x, y = uber_page.graph_get_good_place_for_new_node()
# add a custom event to the graph
hello_world = uber_page.graph_add_node_custom_event('Hello World', x, y)

# get a reference to the 'then' pin
hello_world_then = hello_world.node_find_pin('then')

x, y = uber_page.graph_get_good_place_for_new_node()
# add a 'Spawn Actor From Class' node
spawn_actor_node = uber_page.graph_add_node(K2Node_SpawnActorFromClass, x, y)

# set its Class pin
pin_class = spawn_actor_node.node_find_pin('Class')
pin_class.default_object = Character
Exemplo n.º 13
0
 def test_spawn(self):
     new_blueprint = ue.create_blueprint(Character, '/Game/Tests/Blueprints/Test1_' + self.random_string)
     new_actor = self.world.actor_spawn(new_blueprint.GeneratedClass)
     self.assertTrue(new_actor.is_a(Character))
Exemplo n.º 14
0
 def test_creation(self):
     new_blueprint = ue.create_blueprint(Actor, '/Game/Tests/Blueprints/Test0_' + self.random_string)
     ue.log(new_blueprint.ParentClass)
     self.assertEqual(new_blueprint.ParentClass, Actor)
     self.assertNotEqual(new_blueprint.ParentClass, Character)
Exemplo n.º 15
0
	sensing = new_character.add_actor_component(PawnSensingComponent, 'Ears')

# add a cone
cone = world.actor_spawn(Actor)
cone.set_actor_label('A Cone')
cone_mesh = cone.add_actor_component(StaticMeshComponent, 'Cone')
cone_mesh.StaticMesh = ue.load_object(StaticMesh, '/Engine/BasicShapes/Cone')
cone.InitialLifeSpan = 30.0

# add a better cone
cone2 = world.actor_spawn(StaticMeshActor)
cone2.StaticMeshComponent.StaticMesh = ue.load_object(StaticMesh, '/Engine/BasicShapes/Cone')
cone2.set_actor_label('A Better Cone')

# create a new bleprint
bp = ue.create_blueprint(Pawn, '/Game/SuperEvilPawn')
ue.add_component_to_blueprint(bp, PawnSensingComponent, 'Eyes')
point_light = ue.add_component_to_blueprint(bp, PointLightComponent, 'Light')
point_light.Intensity = 9999.9
ue.blueprint_add_member_variable(bp, 'SightPower', 'float')
ue.blueprint_set_variable_visibility(bp, 'SightPower', False)

ue.compile_blueprint(bp)

# instantiate a new actor using the previously created blueprint
super_evil_pawn = world.actor_spawn(bp.GeneratedClass)
super_evil_pawn.set_actor_label('Super Evil Pawn')
super_evil_pawn.SightPower = 2217.30

# save them all
ue.editor_save_all()
Exemplo n.º 16
0
import unreal_engine as ue

from unreal_engine.classes import Material, BlueprintFactory, Blueprint, Actor, Texture2D, SkeletalMesh
from unreal_engine.structs import EdGraphPinType, Vector, Rotator, EdGraphTerminalType
from unreal_engine.enums import EPinContainerType

import time

bp = ue.create_blueprint(Actor, '/Game/FooActor' + str(int(time.time())))

pin = EdGraphPinType(PinCategory='object', PinSubCategoryObject=Material)
ue.blueprint_add_member_variable(bp, 'TestMat', pin, None, '/Engine/MapTemplates/Materials/BasicAsset03.BasicAsset03')

pin = EdGraphPinType(PinCategory='class', PinSubCategoryObject=Texture2D)
ue.blueprint_add_member_variable(bp, 'TestTextureClass', pin)

pin = EdGraphPinType(PinCategory='struct',PinSubCategoryObject=Vector)
ue.blueprint_add_member_variable(bp, 'TestVector', pin, None, '17,22,30')

pin = EdGraphPinType(PinCategory='struct',PinSubCategoryObject=Rotator,ContainerType=EPinContainerType.Array)
ue.blueprint_add_member_variable(bp, 'TestRotator', pin, None, '((Pitch=0.000000,Yaw=3.000000,Roll=0.000000),(Pitch=1.000000,Yaw=0.000000,Roll=0.000000))')

pin = EdGraphPinType(PinCategory='string',ContainerType=EPinContainerType.Map,PinValueType=EdGraphTerminalType(TerminalCategory='object',TerminalSubCategoryObject=SkeletalMesh))
ue.blueprint_add_member_variable(bp, 'TestMap', pin, None, '(("firstKey", SkeletalMesh\'"/Game/Skel001"\'),("secondKey", SkeletalMesh\'"/Game/Skel002"\'))')

ue.compile_blueprint(bp)

ue.open_editor_for_asset(bp)