mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
classref: Sync with latest 4.0-dev
This commit is contained in:
@@ -9,20 +9,23 @@
|
||||
EditorScript
|
||||
============
|
||||
|
||||
**Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
||||
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||||
|
||||
Base script that can be used to add extension functions to the editor.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Scripts extending this class and implementing its :ref:`_run<class_EditorScript_method__run>` method can be executed from the Script Editor's **File > Run** menu option (or by pressing ``Ctrl+Shift+X``) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using :ref:`EditorPlugin<class_EditorPlugin>`\ s instead.
|
||||
Scripts extending this class and implementing its :ref:`_run<class_EditorScript_method__run>` method can be executed from the Script Editor's **File > Run** menu option (or by pressing :kbd:`Ctrl + Shift + X`) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using :ref:`EditorPlugin<class_EditorPlugin>`\ s instead.
|
||||
|
||||
**Note:** Extending scripts need to have ``tool`` mode enabled.
|
||||
|
||||
**Example script:**
|
||||
|
||||
::
|
||||
|
||||
.. tabs::
|
||||
|
||||
.. code-tab:: gdscript
|
||||
|
||||
tool
|
||||
extends EditorScript
|
||||
@@ -30,13 +33,29 @@ Scripts extending this class and implementing its :ref:`_run<class_EditorScript_
|
||||
func _run():
|
||||
print("Hello from the Godot Editor!")
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
[Tool]
|
||||
public class HelloEditor : EditorScript
|
||||
{
|
||||
public override void _Run()
|
||||
{
|
||||
GD.Print("Hello from the Godot Editor!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
**Note:** The script is run in the Editor context, which means the output is visible in the console window started with the Editor (stdout) instead of the usual Godot **Output** dock.
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`_run<class_EditorScript_method__run>` **(** **)** virtual |
|
||||
| void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
|
||||
+-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
|
||||
+-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
|
||||
@@ -50,7 +69,7 @@ Method Descriptions
|
||||
|
||||
.. _class_EditorScript_method__run:
|
||||
|
||||
- void **_run** **(** **)** virtual
|
||||
- void **_run** **(** **)** |virtual|
|
||||
|
||||
This method is executed by the Editor when **File > Run** is used.
|
||||
|
||||
@@ -80,3 +99,9 @@ Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
|
||||
|
||||
Returns the Editor's currently active scene.
|
||||
|
||||
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||||
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||||
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
||||
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||||
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
||||
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|
||||
|
||||
Reference in New Issue
Block a user