Skip to content
0.2.0-dev Download ZIP
68 lines ·2.4 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="ScenePaint2DEditor" inherits="Control" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Class for interacting with the 2D editor's Scene Paint Mode.
5 </brief_description>
6 <description>
7 This class is available only in the editor and cannot be instantiated. Access it using [method EditorInterface.get_scene_paint_2d].
8 It provides methods for editor plugins to interact with the scene painting tool.
9 Plugins can register custom scene providers, and set the scene to be painted.
10 </description>
11 <tutorials>
12 </tutorials>
13 <methods>
14 <method name="get_painted_scene" qualifiers="const">
15 <return type="Node2D" />
16 <description>
17 Returns the painted scene, or [code]null[/code] if none is selected. The returned scene's properties can be edited.
18 [b]Warning:[/b] Removing and freeing this node will render the editor useless and may cause a crash.
19 </description>
20 </method>
21 <method name="register_scene_provider">
22 <return type="void" />
23 <param index="0" name="control" type="Control" />
24 <param index="1" name="callback" type="Callable" />
25 <description>
26 Registers a custom scene provider.
27 When the scene picker tool is active and the user clicks on [param control], the [param callback] is invoked and must return a [Node2D].
28 The returned scene becomes the new painting sample.
29 </description>
30 </method>
31 <method name="set_painted_scene">
32 <return type="void" />
33 <param index="0" name="scene" type="Node2D" />
34 <description>
35 Sets the scene sample to be painted.
36 </description>
37 </method>
38 <method name="unregister_scene_provider">
39 <return type="void" />
40 <param index="0" name="control" type="Control" />
41 <description>
42 Removes a previously registered scene provider.
43 </description>
44 </method>
45 </methods>
46 <signals>
47 <signal name="scene_painted">
48 <param index="0" name="node" type="Node2D" />
49 <description>
50 Emitted for each new node created during drawing.
51 [b]Example:[/b]
52 [codeblocks]
53 [gdscript]
54 @tool
55 extends EditorPlugin
56
57 func _enter_tree():
58 EditorInterface.get_scene_paint_2d().scene_painted.connect(_on_scene_painted)
59
60 func _on_scene_painted(node: Node2D):
61 # Set random rotation when drawing nodes.
62 node.rotation = randf_range(0, 360)
63 [/gdscript]
64 [/codeblocks]
65 </description>
66 </signal>
67 </signals>
68</class>