How to export a CollisionPolygon2D to inspector?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By The_Black_Chess_King

So, we can do:

export(AudioStreamSample) var Music_Stinger
export(bool) var Trigger_On_Enter

How can I export a CollisionPolygon2D? I have a area2d node saved, which has a child CollisionPolygon2D, it is a trigger for musics and stingers in the game, however, I would like to know if it’s possible to expose in the inspector a CollisionPolygon2D similarly like the above, so I could customize a collision shape for the map,

:bust_in_silhouette: Reply From: Bernard Cloutier

You can save the CollisionPolygon2D node as a scene, and then export a var like this:

export(String, FILE, "*.tscn") var my_collision_polygon_scene

func _ready():

If the collision polygon node is already in the scene tree for some reason, you can export a NodePath and duplicate the node:

export(NodePath) var my_collision_polygon_node_path

func _ready():