def SpawnSurroundingActor(ActorToSpawn, Core, CenterObject, Distance=10, NumberOfWalls=0) : if NumberOfWalls <= 0 : NumberOfWalls = Distance spawningActorAsset = unreal.EditorAssetLibrary().find_asset_data(ActorToSpawn) spawningActorObject = spawningActorAsset.get_asset() level_actor_list = unreal.EditorLevelLibrary().get_all_level_actors() for a in level_actor_list: if a.get_name() == Core : core_object = a if a.get_name() == CenterObject : center_object = a ForwardVector = center_object.get_actor_forward_vector() PerpendicularVector = unreal.Vector(1, 1, ((ForwardVector.x + ForwardVector.y) * -1) / ForwardVector.z ) PerpendicularVector = PerpendicularVector * Distance NewPosition = PerpendicularVector + center_object.get_actor_location() RotationAxis = center_object.get_actor_location() - core_object.get_actor_location() with unreal.ScopedEditorTransaction("Spawn Surrounding Actors") as trans: for i in range(0, NumberOfWalls, 2) : ResultPosition = unreal.MathLibrary().rotate_angle_axis(NewPosition, i * 360 / Distance, RotationAxis) unit_direction = unreal.MathLibrary().get_direction_unit_vector(core_object.get_actor_location(), ResultPosition) ResultLocation = (unit_direction * 590) + core_object.get_actor_location() spawned_actor = unreal.EditorLevelLibrary().spawn_actor_from_object(spawningActorObject, ResultLocation) spawned_actor.set_actor_relative_scale3d(unreal.Vector(0.1, 0.1, 2.0)) spawned_actor.set_actor_rotation(GetCoreBasedRotation(core_object.get_actor_location(), spawned_actor), True)
def imprint(node, data): loaded_asset = unreal.EditorAssetLibrary.load_asset(node) for key, value in data.items(): # Support values evaluated at imprint if callable(value): value = value() # Unreal doesn't support NoneType in metadata values if value is None: value = "" unreal.EditorAssetLibrary.set_metadata_tag(loaded_asset, key, str(value)) with unreal.ScopedEditorTransaction("Avalon containerising"): unreal.EditorAssetLibrary.save_asset(node)
def process(self): nodes = list() with unreal.ScopedEditorTransaction("Avalon Creating Instance"): if (self.options or {}).get("useSelection"): self.log.info("setting ...") print("settings ...") nodes = unreal.EditorUtilityLibrary.get_selected_assets() asset_paths = [a.get_path_name() for a in nodes] self.name = move_assets_to_path("/Game", self.name, asset_paths) instance = create_publish_instance("/Game", self.name) imprint(instance, self.data) return instance
def execute(self): search_path = "/Game/" try: search_path += sys.argv[1] except IndexError: pass if unreal.EditorAssetLibrary.does_directory_exist(search_path) != True: unreal.log_warning( 'search directory is not found: {}'.format(search_path)) return with unreal.ScopedEditorTransaction("validating texture properties"): ProcessSlotTask.execute( 'checking texture assets', lambda x: self.check_asset_data(x), AssetStatics.filter_by_class( unreal.Texture2D, unreal.AssetRegistryHelpers.get_asset_registry(). get_assets_by_path( unreal.Paths.normalize_directory_name(search_path), True), True, False))
import unreal obj = unreal.MediaPlayer() with unreal.ScopedEditorTransaction("My Transaction Test") as trans: obj.set_editor_property("play_on_open", True) obj.set_editor_property("vertical_field_of_view", 60)