Add "fake user" setting for traits
This commit is contained in:
parent
f3fabd7d7c
commit
403e52109c
|
@ -14,6 +14,7 @@ class TraitNode extends LogicNode {
|
|||
|
||||
var cname = Type.resolveClass(Main.projectPackage + "." + property0);
|
||||
if (cname == null) cname = Type.resolveClass(Main.projectPackage + ".node." + property0);
|
||||
if (cname == null) throw 'No trait with the name "$property0" found, make sure that the trait is exported!';
|
||||
value = Type.createInstance(cname, []);
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -2467,8 +2467,12 @@ class ArmoryExporter:
|
|||
def export_traits(self, bobject, o):
|
||||
if hasattr(bobject, 'arm_traitlist'):
|
||||
for t in bobject.arm_traitlist:
|
||||
if t.enabled_prop == False:
|
||||
# Don't export disabled traits but still export those
|
||||
# with fake user enabled so that nodes like `TraitNode`
|
||||
# still work
|
||||
if not t.enabled_prop and not t.fake_user:
|
||||
continue
|
||||
|
||||
x = {}
|
||||
if t.type_prop == 'Logic Nodes' and t.node_tree_prop != None and t.node_tree_prop.name != '':
|
||||
x['type'] = 'Script'
|
||||
|
|
|
@ -54,6 +54,7 @@ class ArmTraitListItem(bpy.types.PropertyGroup):
|
|||
name: StringProperty(name="Name", description="A name for this item", default="")
|
||||
enabled_prop: BoolProperty(name="", description="A name for this item", default=True, update=trigger_recompile)
|
||||
is_object: BoolProperty(name="", default=True)
|
||||
fake_user: BoolProperty(name="Fake User", description="Export this trait even if it is deactivated", default=False)
|
||||
type_prop: EnumProperty(
|
||||
items = [('Haxe Script', 'Haxe', 'Haxe Script'),
|
||||
('WebAssembly', 'Wasm', 'WebAssembly'),
|
||||
|
@ -88,12 +89,16 @@ class ARM_UL_TraitList(bpy.types.UIList):
|
|||
# Make sure your code supports all 3 layout types
|
||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
layout.prop(item, "enabled_prop")
|
||||
layout.label(text=item.name, icon=custom_icon, icon_value=custom_icon_value)
|
||||
# Display " " for props without a name to right-align the
|
||||
# fake_user button
|
||||
layout.label(text=item.name if item.name != "" else " ", icon=custom_icon, icon_value=custom_icon_value)
|
||||
|
||||
elif self.layout_type in {'GRID'}:
|
||||
layout.alignment = 'CENTER'
|
||||
layout.label(text="", icon=custom_icon, icon_value=custom_icon_value)
|
||||
|
||||
layout.prop(item, "fake_user", text="", icon="FAKE_USER_ON" if item.fake_user else "FAKE_USER_OFF")
|
||||
|
||||
class ArmTraitListNewItem(bpy.types.Operator):
|
||||
# Add a new item to the list
|
||||
bl_idname = "arm_traitlist.new_item"
|
||||
|
|
Loading…
Reference in a new issue