Copy array edited in editor

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tran Hoang Nhat
:warning: Old Version Published before Godot 3 was released.

Is it possible to copy an array created by ArrayPropertyEdit as code? I’m looking for a way to create CollisionPolygon2D dynamically, since now I have to edit it in the editor, type the polygon points array by hand, and then create a ConvexPolygonShape2D from that array, which is very cumbersome. Thanks.

:bust_in_silhouette: Reply From: DriNeo

You may try get_polygon() and set_polygon(Vector2Array polygon) of the CollisionPolygon2D node.

Can I access CollisionPolygon2D in the game? In the doc it said This is not present when running the game. so I’m a little confused. And I can’t copy text from the console neither. So many thing is not copyable in Godot.

Tran Hoang Nhat | 2016-10-06 03:11

Figured it out. I have to launch Godot from Terminal to get properly console output. Now I can copy those values!

Tran Hoang Nhat | 2016-10-06 10:54

:bust_in_silhouette: Reply From: jospic

You may use “Copy Params” and “Paste Params” from Inspector panel after selecting your CollisionPoligon2D → ArrayPropertyEdit

enter image description here
enter image description here

-j

Well, I need to copy the array as code to paste it in a script so this won’t do. But somebody might want this, too.

Tran Hoang Nhat | 2016-10-06 10:53

:bust_in_silhouette: Reply From: st_phan

I also just found about EditorScripts which (among many things) can be used to add shapes generated via code to the scene, check out SVG2Godot as an example.

(I procedurally create shapes and use an EditorScript to add them as 2D Polygons to the scene so I can tweak them manually if needed)