Auto enable ui lib
This commit is contained in:
parent
f1e3114b82
commit
f786924587
|
@ -2660,6 +2660,7 @@ class ArmoryExporter:
|
|||
ArmoryExporter.export_all_flag = True
|
||||
ArmoryExporter.export_physics = False # Indicates whether rigid body is exported
|
||||
ArmoryExporter.export_navigation = False
|
||||
ArmoryExporter.export_ui = False
|
||||
if not hasattr(ArmoryExporter, 'compress_enabled'):
|
||||
ArmoryExporter.compress_enabled = False
|
||||
if not hasattr(ArmoryExporter, 'in_viewport'):
|
||||
|
@ -2768,6 +2769,7 @@ class ArmoryExporter:
|
|||
f.write(bpy.data.texts[t.jsscript_prop].as_string())
|
||||
assets.add(assetpath)
|
||||
elif t.type_prop == 'UI Canvas':
|
||||
ArmoryExporter.export_ui = True
|
||||
x['type'] = 'Script'
|
||||
x['class_name'] = 'armory.trait.internal.CanvasScript'
|
||||
x['parameters'] = ["'" + t.canvas_name_prop + "'"]
|
||||
|
@ -2899,6 +2901,7 @@ class ArmoryExporter:
|
|||
if type == NodeTypeCamera:
|
||||
# Debug console enabled, attach console overlay to each camera
|
||||
if bpy.data.worlds['Arm'].arm_play_console:
|
||||
ArmoryExporter.export_ui = True
|
||||
console_trait = {}
|
||||
console_trait['type'] = 'Script'
|
||||
console_trait['class_name'] = 'armory.trait.internal.DebugConsole'
|
||||
|
|
|
@ -65,6 +65,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
|
|||
assets_path = sdk_path + 'armory/Assets/'
|
||||
export_physics = bpy.data.worlds['Arm'].arm_physics != 'Disabled'
|
||||
export_navigation = bpy.data.worlds['Arm'].arm_navigation != 'Disabled'
|
||||
export_ui = bpy.data.worlds['Arm'].arm_ui != 'Disabled'
|
||||
assets.reset()
|
||||
|
||||
# Build node trees
|
||||
|
@ -83,6 +84,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
|
|||
assets.embedded_data = sorted(list(set(assets.embedded_data)))
|
||||
physics_found = False
|
||||
navigation_found = False
|
||||
ui_found = False
|
||||
ArmoryExporter.compress_enabled = is_publish
|
||||
ArmoryExporter.in_viewport = in_viewport
|
||||
for scene in bpy.data.scenes:
|
||||
|
@ -90,18 +92,26 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
|
|||
ext = '.zip' if (scene.data_compressed and is_publish) else '.arm'
|
||||
asset_path = arm.utils.build_dir() + '/compiled/Assets/' + arm.utils.safestr(scene.name) + ext
|
||||
exporter.execute(bpy.context, asset_path, scene=scene)
|
||||
if physics_found == False and ArmoryExporter.export_physics:
|
||||
if ArmoryExporter.export_physics:
|
||||
physics_found = True
|
||||
if navigation_found == False and ArmoryExporter.export_navigation:
|
||||
if ArmoryExporter.export_navigation:
|
||||
navigation_found = True
|
||||
if ArmoryExporter.export_ui:
|
||||
ui_found = True
|
||||
assets.add(asset_path)
|
||||
|
||||
if physics_found == False: # Disable physics anyway if no rigid body exported
|
||||
if physics_found == False: # Disable physics if no rigid body is exported
|
||||
export_physics = False
|
||||
|
||||
if navigation_found == False:
|
||||
export_navigation = False
|
||||
|
||||
if ui_found == False:
|
||||
export_ui = False
|
||||
|
||||
if wrd.arm_ui == 'Enabled':
|
||||
export_ui = True
|
||||
|
||||
# Write referenced shader variants
|
||||
for ref in assets.shader_datas:
|
||||
# Data does not exist yet
|
||||
|
@ -125,7 +135,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
|
|||
write_data.write_compiledglsl()
|
||||
|
||||
# Write khafile.js
|
||||
write_data.write_khafilejs(is_play, export_physics, export_navigation, is_publish)
|
||||
write_data.write_khafilejs(is_play, export_physics, export_navigation, export_ui, is_publish)
|
||||
|
||||
# Write Main.hx - depends on write_khafilejs for writing number of assets
|
||||
resx, resy = arm.utils.get_render_resolution(arm.utils.get_active_scene())
|
||||
|
|
|
@ -133,7 +133,11 @@ def init_properties():
|
|||
items = [('Disabled', 'Disabled', 'Disabled'),
|
||||
('Recast', 'Recast', 'Recast')],
|
||||
name = "Navigation", default='Recast')
|
||||
bpy.types.World.arm_ui = BoolProperty(name="UI Library", description="Include UI library", default=False)
|
||||
bpy.types.World.arm_ui = EnumProperty(
|
||||
items = [('Disabled', 'Disabled', 'Disabled'),
|
||||
('Enabled', 'Enabled', 'Enabled'),
|
||||
('Auto', 'Auto', 'Auto')],
|
||||
name = "UI Library", default='Auto', description="Include UI library")
|
||||
bpy.types.World.arm_hscript = BoolProperty(name="hscript", description="Include hscript library", default=False)
|
||||
bpy.types.World.arm_engine_on = bpy.props.BoolProperty(name="Armory On", description="Armory engine enabled", default=True)
|
||||
bpy.types.World.arm_khafile = StringProperty(name="Khafile", description="Source appended to khafile.js")
|
||||
|
|
|
@ -425,9 +425,8 @@ class ArmoryPlayerPanel(bpy.types.Panel):
|
|||
layout.label('Libraries')
|
||||
layout.prop(wrd, 'arm_physics')
|
||||
layout.prop(wrd, 'arm_navigation')
|
||||
row = layout.row(align=True)
|
||||
row.prop(wrd, 'arm_ui')
|
||||
row.prop(wrd, 'arm_hscript')
|
||||
layout.prop(wrd, 'arm_ui')
|
||||
layout.prop(wrd, 'arm_hscript')
|
||||
|
||||
class ArmoryProjectPanel(bpy.types.Panel):
|
||||
bl_label = "Armory Project"
|
||||
|
|
|
@ -23,7 +23,7 @@ def add_assets(path):
|
|||
return 'project.addAssets("' + path + '");\n'
|
||||
|
||||
# Write khafile.js
|
||||
def write_khafilejs(is_play, export_physics, export_navigation, is_publish):
|
||||
def write_khafilejs(is_play, export_physics, export_navigation, export_ui, is_publish):
|
||||
global check_dot_path
|
||||
|
||||
sdk_path = arm.utils.get_sdk_path()
|
||||
|
@ -108,7 +108,7 @@ project.addSources('Sources');
|
|||
if wrd.arm_play_console:
|
||||
assets.add_khafile_def('arm_profile')
|
||||
|
||||
if wrd.arm_play_console or wrd.arm_ui:
|
||||
if export_ui:
|
||||
f.write(add_armory_library(sdk_path, 'lib/zui'))
|
||||
p = sdk_path + '/armory/Assets/droid_sans.ttf'
|
||||
f.write(add_assets(p.replace('\\', '/')))
|
||||
|
|
Loading…
Reference in a new issue