class_editorinterface.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorInterface.xml.
  6. .. _class_EditorInterface:
  7. EditorInterface
  8. ===============
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Godot editor's interface.
  11. Description
  12. -----------
  13. EditorInterface gives you control over Godot editor's window. It allows customizing the window, saving and (re-)loading scenes, rendering mesh previews, inspecting and editing resources and objects, and provides access to :ref:`EditorSettings<class_EditorSettings>`, :ref:`EditorFileSystem<class_EditorFileSystem>`, :ref:`EditorResourcePreview<class_EditorResourcePreview>`, :ref:`ScriptEditor<class_ScriptEditor>`, the editor viewport, and information about scenes.
  14. \ **Note:** This class shouldn't be instantiated directly. Instead, access the singleton using :ref:`EditorPlugin.get_editor_interface<class_EditorPlugin_method_get_editor_interface>`.
  15. Properties
  16. ----------
  17. +-------------------------+------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`distraction_free_mode<class_EditorInterface_property_distraction_free_mode>` |
  19. +-------------------------+------------------------------------------------------------------------------------+
  20. Methods
  21. -------
  22. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`edit_node<class_EditorInterface_method_edit_node>` **(** :ref:`Node<class_Node>` node **)** |
  24. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`edit_resource<class_EditorInterface_method_edit_resource>` **(** :ref:`Resource<class_Resource>` resource **)** |
  26. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`edit_script<class_EditorInterface_method_edit_script>` **(** :ref:`Script<class_Script>` script, :ref:`int<class_int>` line=-1, :ref:`int<class_int>` column=0, :ref:`bool<class_bool>` grab_focus=true **)** |
  28. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Control<class_Control>` | :ref:`get_base_control<class_EditorInterface_method_get_base_control>` **(** **)** |
  30. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`EditorCommandPalette<class_EditorCommandPalette>` | :ref:`get_command_palette<class_EditorInterface_method_get_command_palette>` **(** **)** |const| |
  32. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`get_current_path<class_EditorInterface_method_get_current_path>` **(** **)** |const| |
  34. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Node<class_Node>` | :ref:`get_edited_scene_root<class_EditorInterface_method_get_edited_scene_root>` **(** **)** |
  36. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Control<class_Control>` | :ref:`get_editor_main_control<class_EditorInterface_method_get_editor_main_control>` **(** **)** |
  38. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`EditorPaths<class_EditorPaths>` | :ref:`get_editor_paths<class_EditorInterface_method_get_editor_paths>` **(** **)** |
  40. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`get_editor_scale<class_EditorInterface_method_get_editor_scale>` **(** **)** |const| |
  42. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`EditorSettings<class_EditorSettings>` | :ref:`get_editor_settings<class_EditorInterface_method_get_editor_settings>` **(** **)** |
  44. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`FileSystemDock<class_FileSystemDock>` | :ref:`get_file_system_dock<class_EditorInterface_method_get_file_system_dock>` **(** **)** |
  46. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`EditorInspector<class_EditorInspector>` | :ref:`get_inspector<class_EditorInterface_method_get_inspector>` **(** **)** |const| |
  48. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Array<class_Array>` | :ref:`get_open_scenes<class_EditorInterface_method_get_open_scenes>` **(** **)** |const| |
  50. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`String<class_String>` | :ref:`get_playing_scene<class_EditorInterface_method_get_playing_scene>` **(** **)** |const| |
  52. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`EditorFileSystem<class_EditorFileSystem>` | :ref:`get_resource_filesystem<class_EditorInterface_method_get_resource_filesystem>` **(** **)** |
  54. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`EditorResourcePreview<class_EditorResourcePreview>` | :ref:`get_resource_previewer<class_EditorInterface_method_get_resource_previewer>` **(** **)** |
  56. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`ScriptEditor<class_ScriptEditor>` | :ref:`get_script_editor<class_EditorInterface_method_get_script_editor>` **(** **)** |
  58. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`String<class_String>` | :ref:`get_selected_path<class_EditorInterface_method_get_selected_path>` **(** **)** |const| |
  60. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`EditorSelection<class_EditorSelection>` | :ref:`get_selection<class_EditorInterface_method_get_selection>` **(** **)** |
  62. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`inspect_object<class_EditorInterface_method_inspect_object>` **(** :ref:`Object<class_Object>` object, :ref:`String<class_String>` for_property="", :ref:`bool<class_bool>` inspector_only=false **)** |
  64. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`is_playing_scene<class_EditorInterface_method_is_playing_scene>` **(** **)** |const| |
  66. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`is_plugin_enabled<class_EditorInterface_method_is_plugin_enabled>` **(** :ref:`String<class_String>` plugin **)** |const| |
  68. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Array<class_Array>` | :ref:`make_mesh_previews<class_EditorInterface_method_make_mesh_previews>` **(** :ref:`Array<class_Array>` meshes, :ref:`int<class_int>` preview_size **)** |
  70. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`open_scene_from_path<class_EditorInterface_method_open_scene_from_path>` **(** :ref:`String<class_String>` scene_filepath **)** |
  72. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`play_current_scene<class_EditorInterface_method_play_current_scene>` **(** **)** |
  74. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`play_custom_scene<class_EditorInterface_method_play_custom_scene>` **(** :ref:`String<class_String>` scene_filepath **)** |
  76. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`play_main_scene<class_EditorInterface_method_play_main_scene>` **(** **)** |
  78. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`reload_scene_from_path<class_EditorInterface_method_reload_scene_from_path>` **(** :ref:`String<class_String>` scene_filepath **)** |
  80. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_scene<class_EditorInterface_method_save_scene>` **(** **)** |
  82. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`save_scene_as<class_EditorInterface_method_save_scene_as>` **(** :ref:`String<class_String>` path, :ref:`bool<class_bool>` with_preview=true **)** |
  84. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`select_file<class_EditorInterface_method_select_file>` **(** :ref:`String<class_String>` file **)** |
  86. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`set_main_screen_editor<class_EditorInterface_method_set_main_screen_editor>` **(** :ref:`String<class_String>` name **)** |
  88. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_plugin_enabled<class_EditorInterface_method_set_plugin_enabled>` **(** :ref:`String<class_String>` plugin, :ref:`bool<class_bool>` enabled **)** |
  90. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`stop_playing_scene<class_EditorInterface_method_stop_playing_scene>` **(** **)** |
  92. +-----------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. Property Descriptions
  94. ---------------------
  95. .. _class_EditorInterface_property_distraction_free_mode:
  96. - :ref:`bool<class_bool>` **distraction_free_mode**
  97. +----------+------------------------------------+
  98. | *Setter* | set_distraction_free_mode(value) |
  99. +----------+------------------------------------+
  100. | *Getter* | is_distraction_free_mode_enabled() |
  101. +----------+------------------------------------+
  102. If ``true``, enables distraction-free mode which hides side docks to increase the space available for the main view.
  103. Method Descriptions
  104. -------------------
  105. .. _class_EditorInterface_method_edit_node:
  106. - void **edit_node** **(** :ref:`Node<class_Node>` node **)**
  107. Edits the given :ref:`Node<class_Node>`. The node will be also selected if it's inside the scene tree.
  108. ----
  109. .. _class_EditorInterface_method_edit_resource:
  110. - void **edit_resource** **(** :ref:`Resource<class_Resource>` resource **)**
  111. Edits the given :ref:`Resource<class_Resource>`. If the resource is a :ref:`Script<class_Script>` you can also edit it with :ref:`edit_script<class_EditorInterface_method_edit_script>` to specify the line and column position.
  112. ----
  113. .. _class_EditorInterface_method_edit_script:
  114. - void **edit_script** **(** :ref:`Script<class_Script>` script, :ref:`int<class_int>` line=-1, :ref:`int<class_int>` column=0, :ref:`bool<class_bool>` grab_focus=true **)**
  115. Edits the given :ref:`Script<class_Script>`. The line and column on which to open the script can also be specified. The script will be open with the user-configured editor for the script's language which may be an external editor.
  116. ----
  117. .. _class_EditorInterface_method_get_base_control:
  118. - :ref:`Control<class_Control>` **get_base_control** **(** **)**
  119. Returns the main container of Godot editor's window. For example, you can use it to retrieve the size of the container and place your controls accordingly.
  120. \ **Warning:** Removing and freeing this node will render the editor useless and may cause a crash.
  121. ----
  122. .. _class_EditorInterface_method_get_command_palette:
  123. - :ref:`EditorCommandPalette<class_EditorCommandPalette>` **get_command_palette** **(** **)** |const|
  124. Returns the editor's :ref:`EditorCommandPalette<class_EditorCommandPalette>` instance.
  125. \ **Warning:** Removing and freeing this node will render a part of the editor useless and may cause a crash.
  126. ----
  127. .. _class_EditorInterface_method_get_current_path:
  128. - :ref:`String<class_String>` **get_current_path** **(** **)** |const|
  129. Returns the current path being viewed in the :ref:`FileSystemDock<class_FileSystemDock>`.
  130. ----
  131. .. _class_EditorInterface_method_get_edited_scene_root:
  132. - :ref:`Node<class_Node>` **get_edited_scene_root** **(** **)**
  133. Returns the edited (current) scene's root :ref:`Node<class_Node>`.
  134. ----
  135. .. _class_EditorInterface_method_get_editor_main_control:
  136. - :ref:`Control<class_Control>` **get_editor_main_control** **(** **)**
  137. Returns the main editor control. Use this as a parent for main screens.
  138. \ **Note:** This returns the main editor control containing the whole editor, not the 2D or 3D viewports specifically.
  139. \ **Warning:** Removing and freeing this node will render a part of the editor useless and may cause a crash.
  140. ----
  141. .. _class_EditorInterface_method_get_editor_paths:
  142. - :ref:`EditorPaths<class_EditorPaths>` **get_editor_paths** **(** **)**
  143. ----
  144. .. _class_EditorInterface_method_get_editor_scale:
  145. - :ref:`float<class_float>` **get_editor_scale** **(** **)** |const|
  146. Returns the actual scale of the editor UI (``1.0`` being 100% scale). This can be used to adjust position and dimensions of the UI added by plugins.
  147. \ **Note:** This value is set via the ``interface/editor/display_scale`` and ``interface/editor/custom_display_scale`` editor settings. Editor must be restarted for changes to be properly applied.
  148. ----
  149. .. _class_EditorInterface_method_get_editor_settings:
  150. - :ref:`EditorSettings<class_EditorSettings>` **get_editor_settings** **(** **)**
  151. Returns the editor's :ref:`EditorSettings<class_EditorSettings>` instance.
  152. ----
  153. .. _class_EditorInterface_method_get_file_system_dock:
  154. - :ref:`FileSystemDock<class_FileSystemDock>` **get_file_system_dock** **(** **)**
  155. Returns the editor's :ref:`FileSystemDock<class_FileSystemDock>` instance.
  156. \ **Warning:** Removing and freeing this node will render a part of the editor useless and may cause a crash.
  157. ----
  158. .. _class_EditorInterface_method_get_inspector:
  159. - :ref:`EditorInspector<class_EditorInspector>` **get_inspector** **(** **)** |const|
  160. Returns the editor's :ref:`EditorInspector<class_EditorInspector>` instance.
  161. \ **Warning:** Removing and freeing this node will render a part of the editor useless and may cause a crash.
  162. ----
  163. .. _class_EditorInterface_method_get_open_scenes:
  164. - :ref:`Array<class_Array>` **get_open_scenes** **(** **)** |const|
  165. Returns an :ref:`Array<class_Array>` with the file paths of the currently opened scenes.
  166. ----
  167. .. _class_EditorInterface_method_get_playing_scene:
  168. - :ref:`String<class_String>` **get_playing_scene** **(** **)** |const|
  169. Returns the name of the scene that is being played. If no scene is currently being played, returns an empty string.
  170. ----
  171. .. _class_EditorInterface_method_get_resource_filesystem:
  172. - :ref:`EditorFileSystem<class_EditorFileSystem>` **get_resource_filesystem** **(** **)**
  173. Returns the editor's :ref:`EditorFileSystem<class_EditorFileSystem>` instance.
  174. ----
  175. .. _class_EditorInterface_method_get_resource_previewer:
  176. - :ref:`EditorResourcePreview<class_EditorResourcePreview>` **get_resource_previewer** **(** **)**
  177. Returns the editor's :ref:`EditorResourcePreview<class_EditorResourcePreview>` instance.
  178. ----
  179. .. _class_EditorInterface_method_get_script_editor:
  180. - :ref:`ScriptEditor<class_ScriptEditor>` **get_script_editor** **(** **)**
  181. Returns the editor's :ref:`ScriptEditor<class_ScriptEditor>` instance.
  182. \ **Warning:** Removing and freeing this node will render a part of the editor useless and may cause a crash.
  183. ----
  184. .. _class_EditorInterface_method_get_selected_path:
  185. - :ref:`String<class_String>` **get_selected_path** **(** **)** |const|
  186. Returns the path of the directory currently selected in the :ref:`FileSystemDock<class_FileSystemDock>`. If a file is selected, its base directory will be returned using :ref:`String.get_base_dir<class_String_method_get_base_dir>` instead.
  187. ----
  188. .. _class_EditorInterface_method_get_selection:
  189. - :ref:`EditorSelection<class_EditorSelection>` **get_selection** **(** **)**
  190. Returns the editor's :ref:`EditorSelection<class_EditorSelection>` instance.
  191. ----
  192. .. _class_EditorInterface_method_inspect_object:
  193. - void **inspect_object** **(** :ref:`Object<class_Object>` object, :ref:`String<class_String>` for_property="", :ref:`bool<class_bool>` inspector_only=false **)**
  194. Shows the given property on the given ``object`` in the editor's Inspector dock. If ``inspector_only`` is ``true``, plugins will not attempt to edit ``object``.
  195. ----
  196. .. _class_EditorInterface_method_is_playing_scene:
  197. - :ref:`bool<class_bool>` **is_playing_scene** **(** **)** |const|
  198. Returns ``true`` if a scene is currently being played, ``false`` otherwise. Paused scenes are considered as being played.
  199. ----
  200. .. _class_EditorInterface_method_is_plugin_enabled:
  201. - :ref:`bool<class_bool>` **is_plugin_enabled** **(** :ref:`String<class_String>` plugin **)** |const|
  202. Returns ``true`` if the specified ``plugin`` is enabled. The plugin name is the same as its directory name.
  203. ----
  204. .. _class_EditorInterface_method_make_mesh_previews:
  205. - :ref:`Array<class_Array>` **make_mesh_previews** **(** :ref:`Array<class_Array>` meshes, :ref:`int<class_int>` preview_size **)**
  206. Returns mesh previews rendered at the given size as an :ref:`Array<class_Array>` of :ref:`Texture2D<class_Texture2D>`\ s.
  207. ----
  208. .. _class_EditorInterface_method_open_scene_from_path:
  209. - void **open_scene_from_path** **(** :ref:`String<class_String>` scene_filepath **)**
  210. Opens the scene at the given path.
  211. ----
  212. .. _class_EditorInterface_method_play_current_scene:
  213. - void **play_current_scene** **(** **)**
  214. Plays the currently active scene.
  215. ----
  216. .. _class_EditorInterface_method_play_custom_scene:
  217. - void **play_custom_scene** **(** :ref:`String<class_String>` scene_filepath **)**
  218. Plays the scene specified by its filepath.
  219. ----
  220. .. _class_EditorInterface_method_play_main_scene:
  221. - void **play_main_scene** **(** **)**
  222. Plays the main scene.
  223. ----
  224. .. _class_EditorInterface_method_reload_scene_from_path:
  225. - void **reload_scene_from_path** **(** :ref:`String<class_String>` scene_filepath **)**
  226. Reloads the scene at the given path.
  227. ----
  228. .. _class_EditorInterface_method_save_scene:
  229. - :ref:`Error<enum_@GlobalScope_Error>` **save_scene** **(** **)**
  230. Saves the scene. Returns either ``OK`` or ``ERR_CANT_CREATE`` (see :ref:`@GlobalScope<class_@GlobalScope>` constants).
  231. ----
  232. .. _class_EditorInterface_method_save_scene_as:
  233. - void **save_scene_as** **(** :ref:`String<class_String>` path, :ref:`bool<class_bool>` with_preview=true **)**
  234. Saves the scene as a file at ``path``.
  235. ----
  236. .. _class_EditorInterface_method_select_file:
  237. - void **select_file** **(** :ref:`String<class_String>` file **)**
  238. Selects the file, with the path provided by ``file``, in the FileSystem dock.
  239. ----
  240. .. _class_EditorInterface_method_set_main_screen_editor:
  241. - void **set_main_screen_editor** **(** :ref:`String<class_String>` name **)**
  242. Sets the editor's current main screen to the one specified in ``name``. ``name`` must match the text of the tab in question exactly (``2D``, ``3D``, ``Script``, ``AssetLib``).
  243. ----
  244. .. _class_EditorInterface_method_set_plugin_enabled:
  245. - void **set_plugin_enabled** **(** :ref:`String<class_String>` plugin, :ref:`bool<class_bool>` enabled **)**
  246. Sets the enabled status of a plugin. The plugin name is the same as its directory name.
  247. ----
  248. .. _class_EditorInterface_method_stop_playing_scene:
  249. - void **stop_playing_scene** **(** **)**
  250. Stops the scene that is currently playing.
  251. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  252. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  253. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  254. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  255. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  256. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`