How does "In editor" code work?

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

Basically ive noticed a few of the classes’ functions have inside of them “In-editor” Does thsi only mean they’re accessible if you’re running the game from the editor or…what does it mean exactly? Because when i try to use the functions for them, they work perfectly fine they just dont show up in the index when partially typing it

I am not sure what classes or function you mean. Could you give the name of some of them?

neikeq | 2016-03-25 22:59

polygoncollision2D for example, the documentation for it states it’s ment for ineditor

The_Duskitty | 2016-03-26 19:31

:bust_in_silhouette: Reply From: neikeq

These nodes are not present when running the game. They are just helper nodes to easily edit the collision shapes (Shape2D derived resources) that are going to be added to a CollisionObject2D (or CollisionObject in 3D).
Take for example a CollisionShape2D that is child of a KinematicBody2D. If you set its shape to a RectangleShape2D, the editor will add this shape to the KinematicBody2D, and you would have to call body.get_shape(index) to access it at runtime.
CollisionPolygon2D does the same as CollisionShape2D would do with a ConvexPolygonShape2D (if Build Mode was set to Solids) or ConcavePolygonShape2D (if Build Mode was set to Segments) with the difference that it let’s you add, move and remove the polygon points directly in the canvas editor.