def Spawn(cls, world=None, select=False, nuke=False): '''General purpose spawn function - spawns an actor and returns it. If no world is provided, finds one using GetWorld. cls can be: - the name of the class as a string, in which case it will be imported from unreal_engine.classes - a class previously imported from unreal_engine.classes - a Python class created via the fm.subclassing module If the current world is the editor world and select=True, then the newly spawned actor will be selected before returning. ''' world = world or GetWorld() if isinstance(cls, str): import unreal_engine.classes as c cls = getattr(c, cls) if nuke: for obj in ue.get_editor_world().all_objects()[:]: try: if obj.is_a(cls) and obj.is_valid(): obj.actor_destroy() except: pass #logTB() # TODO: grr, there is some mystery object that is in an invalid state that logs an error - it'd be nice to find it and handle it better if select: ue.editor_deselect_actors() try: ue.allow_actor_script_execution_in_editor(True) newObj = world.actor_spawn(cls) finally: ue.allow_actor_script_execution_in_editor(False) if select: ue.editor_select_actor(newObj) return newObj
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))
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))
def setUp(self): ue.allow_actor_script_execution_in_editor(True) ue.begin_transaction('test') self.world = ue.get_editor_world() self.blueprint = ue.load_object( Blueprint, '/Game/PlotterPlatforms.PlotterPlatforms')
def tearDown(self): ue.end_transaction() ue.editor_undo() ue.allow_actor_script_execution_in_editor(False)
def setUp(self): ue.allow_actor_script_execution_in_editor(True) ue.begin_transaction('test') self.world = ue.get_editor_world() self.blueprint = ue.load_object(Blueprint, '/Game/PlotterPlatforms.PlotterPlatforms')
def tearDown(self): ue.end_transaction() ue.editor_undo() ue.allow_actor_script_execution_in_editor(False)
def tearDown(self): ue.allow_actor_script_execution_in_editor(False)
def tearDown(self): ue.allow_actor_script_execution_in_editor(False)