feat(blenvy): now passing levels path to the experimental "export asset ron files" operator

This commit is contained in:
kaosat.dev 2024-05-19 11:27:25 +02:00
parent 70bdd489a1
commit 7ac0c5bca9
2 changed files with 3 additions and 17 deletions

View File

@ -166,7 +166,7 @@ class OT_Add_asset_filebrowser(Operator, ImportHelper):
from types import SimpleNamespace from types import SimpleNamespace
def write_ron_assets_file(level_name, assets_hierarchy, internal_only=False): def write_ron_assets_file(level_name, assets_hierarchy, internal_only=False, levels_path_full="."):
# just for testing, this uses the format of bevy_asset_loader's asset files # just for testing, this uses the format of bevy_asset_loader's asset files
''' '''
({ ({
@ -187,7 +187,7 @@ def write_ron_assets_file(level_name, assets_hierarchy, internal_only=False):
if asset["internal"] or not internal_only: if asset["internal"] or not internal_only:
bla = f'\n "{asset["name"]}": File ( path: "{asset["path"]}" ),' bla = f'\n "{asset["name"]}": File ( path: "{asset["path"]}" ),'
formated_assets.append(bla) formated_assets.append(bla)
with open(f"testing/bevy_example/assets/assets_{level_name}.assets.ron", "w") as assets_file: with open(f"{levels_path_full}/{level_name}.assets.ron", "w") as assets_file:
assets_file.write("({") assets_file.write("({")
assets_file.writelines(formated_assets) assets_file.writelines(formated_assets)
assets_file.write("\n})") assets_file.write("\n})")
@ -209,6 +209,6 @@ class OT_test_bevy_assets(Operator):
for scene in blenvy.main_scenes: for scene in blenvy.main_scenes:
assets_hierarchy = get_main_scene_assets_tree(scene, blueprints_data, settings) assets_hierarchy = get_main_scene_assets_tree(scene, blueprints_data, settings)
scene["assets"] = json.dumps(assets_hierarchy) scene["assets"] = json.dumps(assets_hierarchy)
write_ron_assets_file(scene.name, assets_hierarchy, internal_only=False) write_ron_assets_file(scene.name, assets_hierarchy, internal_only = False, levels_path_full = blenvy.levels_path_full)
return {'FINISHED'} return {'FINISHED'}

View File

@ -49,17 +49,6 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
print("BLA", blenvy.levels_path_full) print("BLA", blenvy.levels_path_full)
print("BLA", blenvy.materials_path_full) print("BLA", blenvy.materials_path_full)
"""current_auto_settings = load_settings(".gltf_auto_export_settings")
current_gltf_settings = load_settings(".gltf_auto_export_gltf_settings")
if current_auto_settings is not None:
#print("current_auto_settings", current_auto_settings)
main_scene_names = current_auto_settings["main_scene_names"]
library_scene_names = current_auto_settings["library_scene_names"]
world_scene_active = context.scene.name in main_scene_names
library_scene_active = context.scene.name in library_scene_names"""
# Now to actual drawing of the UI # Now to actual drawing of the UI
target = row.box() if active_mode == 'COMPONENTS' else row target = row.box() if active_mode == 'COMPONENTS' else row
tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="PROPERTIES") tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="PROPERTIES")
@ -103,8 +92,6 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
draw_folder_browser(layout=row, label="Materials Folder", prop_origin=blenvy, target_property="materials_path") draw_folder_browser(layout=row, label="Materials Folder", prop_origin=blenvy, target_property="materials_path")
panel.separator() panel.separator()
# scenes selection # scenes selection
if len(blenvy.main_scenes) == 0 and len(blenvy.library_scenes) == 0: if len(blenvy.main_scenes) == 0 and len(blenvy.library_scenes) == 0:
row = panel.row() row = panel.row()
@ -114,7 +101,6 @@ class BLENVY_PT_SidePanel(bpy.types.Panel):
row = panel.row() row = panel.row()
row.label(text="Please select and add one using the UI below") row.label(text="Please select and add one using the UI below")
section = panel section = panel
rows = 2 rows = 2
row = section.row() row = section.row()