heygleeson / godot-ldtk-importer

LDTK Importer for Godot 4
MIT License
135 stars 13 forks source link

enable customize resolve ref destination property #28

Closed KarryCharon closed 1 month ago

KarryCharon commented 1 month ago

For resolve reference to custom property. For example, I have a node, it has two fields ref_id and 'ref_data'. 'ref_id' is the source node identifier referenced by the node above, and 'ref_data' as the final data container.

Or destination node only has ref_data filed, this way I can pass ref_id manually.

var node = ... # has ref_data  and ref_id
var ref_data = ...
var iid = ...
entity_layer.add_child(node)
LDTKUtil.update_instance_reference(iid, ref_data)
if "SomeTraceld" in entity.fields:
    var ref_id = entity.fields.SomeTraceld
    if ref_id != null:
        LDTKUtil.add_unresolved_reference(node, "ref_data", stair, node.ref_id)
        # or LDTKUtil.add_unresolved_reference(node, "ref_data", stair, "My Custom Ref ID")