Skip to content

Commit

Permalink
fix terrain magic bug
Browse files Browse the repository at this point in the history
  • Loading branch information
delebash committed Nov 11, 2022
1 parent 811a8af commit 8b39313
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Content/Blueprints/ImportMap/Mapbox_BP.uasset
Git LFS file not shown
30 changes: 17 additions & 13 deletions Resources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
alpha_brush_path = sys.argv[1]
alpha_brush_name = sys.argv[2]
heightmap_directory = sys.argv[3]
alpha_textures_path = alpha_brush_path + "Textures/"

# Duplicate stamp brush
brush_template = "/Game/Brushes/PEAKS/Peak_10_brush"
unreal.EditorAssetLibrary.duplicate_asset(brush_template, alpha_brush_path + alpha_brush_name)
alpha_brush_template_path = sys.argv[4]
alpha_textures = sys.argv[5]
heightmap_property = sys.argv[6]
stamp_tool = sys.argv[7]
alpha_textures_path = alpha_brush_path + alpha_textures

# Import known images as a list of Texture2D objects
alpha_texture_png = heightmap_directory + "\\" + alpha_brush_name + ".png"
Expand All @@ -18,13 +18,17 @@
data.set_editor_property('filenames', [alpha_texture_png])
lst_texture2D = unreal.AssetToolsHelpers.get_asset_tools().import_assets_automated(data)

# Load texture
blueprint_generated = unreal.EditorAssetLibrary.load_blueprint_class(alpha_brush_path + alpha_brush_name)
texture = unreal.EditorAssetLibrary.load_asset(alpha_textures_path + alpha_brush_name)
if stamp_tool == 'Unreal Stamp Brush Plugin':
# Duplicate stamp brush
unreal.EditorAssetLibrary.duplicate_asset(alpha_brush_template_path, alpha_brush_path + alpha_brush_name)

# Load texture
blueprint_generated = unreal.EditorAssetLibrary.load_blueprint_class(alpha_brush_path + alpha_brush_name)
texture = unreal.EditorAssetLibrary.load_asset(alpha_textures_path + alpha_brush_name)

# from that, get the class default object ( the actual template for the blueprint )
blueprint_class_default = unreal.get_default_object(blueprint_generated)
# from that, get the class default object ( the actual template for the blueprint )
blueprint_class_default = unreal.get_default_object(blueprint_generated)

# set or get properties
blueprint_class_default.set_editor_property("HeightMap", texture)
unreal.EditorAssetLibrary.save_asset(alpha_brush_path + alpha_brush_name)
# set or get properties
blueprint_class_default.set_editor_property(heightmap_property, texture)
unreal.EditorAssetLibrary.save_asset(alpha_brush_path + alpha_brush_name)

0 comments on commit 8b39313

Please sign in to comment.