MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / _emit_uproperty

Function _emit_uproperty

Scripts/codegen/generate_ue_components.py:293–330  ·  view source on GitHub ↗

Emit the toggle + value UPROPERTY pair for a schema-driven attr. ``extra_meta`` appends to the value UPROPERTY's meta=() block — used to inject ``DisplayName``, ``GetOptions``, etc. via per-attr rules in ``codegen_rules.json#element_rules. .property_meta. ``. ``hide_from_d

(prop_name: str, ue_type: str, category_label: str,
                    sub_category: Optional[str] = None,
                    extra_meta: Optional[str] = None,
                    default_override: Optional[str] = None,
                    hide_from_details: bool = False)

Source from the content-addressed store, hash-verified

291
292
293def _emit_uproperty(prop_name: str, ue_type: str, category_label: str,
294 sub_category: Optional[str] = None,
295 extra_meta: Optional[str] = None,
296 default_override: Optional[str] = None,
297 hide_from_details: bool = False) -> str:
298 """Emit the toggle + value UPROPERTY pair for a schema-driven attr.
299
300 ``extra_meta`` appends to the value UPROPERTY's meta=() block — used to
301 inject ``DisplayName``, ``GetOptions``, etc. via per-attr rules in
302 ``codegen_rules.json#element_rules.<cat>.property_meta.<attr>``.
303
304 ``hide_from_details=True`` keeps the field as a C++ member (so codegen
305 import paths can still seed it and BPs can still read/write it) but
306 suppresses the Details-panel widget via
307 ``EditCondition="false", EditConditionHides``. Used for properties whose
308 canonical authoring surface is the UE Transform widget (Pos/Quat ->
309 RelativeLocation/Rotation, size -> RelativeScale3D).
310 """
311 cat = f"MuJoCo|{category_label}"
312 if sub_category:
313 cat = f"{cat}|{sub_category}"
314 toggle = override_toggle_name(prop_name)
315 default = default_override if default_override else _attr_default_value(ue_type)
316 if hide_from_details:
317 # EditConditionHides on the value also collapses the InlineEditConditionToggle
318 # toggle bool above it because UE renders them as a single merged row.
319 meta_inner = 'EditCondition="false", EditConditionHides'
320 else:
321 meta_inner = f'EditCondition="{toggle}"'
322 if extra_meta:
323 meta_inner = f'{meta_inner}, {extra_meta}'
324 return (
325 f' UPROPERTY(EditAnywhere, Category = "{cat}", meta=(InlineEditConditionToggle))\n'
326 f' bool {toggle} = false;\n'
327 f'\n'
328 f' UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{cat}", meta=({meta_inner}))\n'
329 f' {ue_type} {prop_name} = {default};\n\n'
330 )
331
332
333def _emit_import_line(attr: str, prop_name: str, ue_type: str,

Callers 3

_canon_property_blockFunction · 0.85

Calls 2

override_toggle_nameFunction · 0.90
_attr_default_valueFunction · 0.90

Tested by

no test coverage detected