Sfoglia il codice sorgente

Document GDScript `@export_tool_button` (#10338)

* Add @export_tool_button to the documention
52SW 8 mesi fa
parent
commit
e05cebecdb
1 ha cambiato i file con 18 aggiunte e 0 eliminazioni
  1. 18 0
      tutorials/scripting/gdscript/gdscript_exports.rst

+ 18 - 0
tutorials/scripting/gdscript/gdscript_exports.rst

@@ -480,6 +480,24 @@ for a list of parameters and their allowed values.
     When using ``@export_custom``, GDScript does not perform any validation on
     When using ``@export_custom``, GDScript does not perform any validation on
     the syntax. Invalid syntax may have unexpected behavior in the inspector.
     the syntax. Invalid syntax may have unexpected behavior in the inspector.
 
 
+``@export_tool_button``
+-----------------------
+
+If you need to create a clickable inspector button, you can use ``@export_tool_button``.
+This exports a ``Callable`` property as a clickable button. When the button is pressed, the callable is called.
+
+Export a button with label ``"Hello"`` and icon ``"Callable"``. When you press it, it will print ``"Hello world!"``.
+
+::
+
+    @tool
+    extends Node
+
+    @export_tool_button("Hello", "Callable") var hello_action = hello
+
+    func hello():
+        print("Hello world!")
+
 Setting exported variables from a tool script
 Setting exported variables from a tool script
 ---------------------------------------------
 ---------------------------------------------