id
stringlengths 6
6
| text
stringlengths 20
17.2k
| title
stringclasses 1
value |
|---|---|---|
124675
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CollisionShape2D" inherits="Node2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A node that provides a [Shape2D] to a [CollisionObject2D] parent.
</brief_description>
<description>
A node that provides a [Shape2D] to a [CollisionObject2D] parent and allows to edit it. This can give a detection shape to an [Area2D] or turn a [PhysicsBody2D] into a solid object.
</description>
<tutorials>
<link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
<link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/2712</link>
<link title="2D Pong Demo">https://godotengine.org/asset-library/asset/2728</link>
<link title="2D Kinematic Character Demo">https://godotengine.org/asset-library/asset/2719</link>
</tutorials>
<members>
<member name="debug_color" type="Color" setter="set_debug_color" getter="get_debug_color" default="Color(0, 0, 0, 1)">
The collision shape debug color.
[b]Note:[/b] The default value is [member ProjectSettings.debug/shapes/collision/shape_color]. The [code]Color(0, 0, 0, 1)[/code] value documented here is a placeholder, and not the actual default debug color.
</member>
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false" keywords="enabled">
A disabled collision shape has no effect in the world. This property should be changed with [method Object.set_deferred].
</member>
<member name="one_way_collision" type="bool" setter="set_one_way_collision" getter="is_one_way_collision_enabled" default="false">
Sets whether this collision shape should only detect collision on one side (top or bottom).
[b]Note:[/b] This property has no effect if this [CollisionShape2D] is a child of an [Area2D] node.
</member>
<member name="one_way_collision_margin" type="float" setter="set_one_way_collision_margin" getter="get_one_way_collision_margin" default="1.0">
The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the shape at a high velocity.
</member>
<member name="shape" type="Shape2D" setter="set_shape" getter="get_shape">
The actual shape owned by this collision shape.
</member>
</members>
</class>
| |
124678
|
<methods>
<method name="_input_event" qualifiers="virtual">
<return type="void" />
<param index="0" name="camera" type="Camera3D" />
<param index="1" name="event" type="InputEvent" />
<param index="2" name="event_position" type="Vector3" />
<param index="3" name="normal" type="Vector3" />
<param index="4" name="shape_idx" type="int" />
<description>
Receives unhandled [InputEvent]s. [param event_position] is the location in world space of the mouse pointer on the surface of the shape with index [param shape_idx] and [param normal] is the normal vector of the surface at that point. Connect to the [signal input_event] signal to easily pick up these events.
[b]Note:[/b] [method _input_event] requires [member input_ray_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
</description>
</method>
<method name="_mouse_enter" qualifiers="virtual">
<return type="void" />
<description>
Called when the mouse pointer enters any of this object's shapes. Requires [member input_ray_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject3D] won't cause this function to be called.
</description>
</method>
<method name="_mouse_exit" qualifiers="virtual">
<return type="void" />
<description>
Called when the mouse pointer exits all this object's shapes. Requires [member input_ray_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject3D] won't cause this function to be called.
</description>
</method>
<method name="create_shape_owner">
<return type="int" />
<param index="0" name="owner" type="Object" />
<description>
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
</description>
</method>
<method name="get_collision_layer_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the object's [RID].
</description>
</method>
<method name="get_shape_owners">
<return type="PackedInt32Array" />
<description>
Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument.
</description>
</method>
<method name="is_shape_owner_disabled" qualifiers="const">
<return type="bool" />
<param index="0" name="owner_id" type="int" />
<description>
If [code]true[/code], the shape owner and its shapes are disabled.
</description>
</method>
<method name="remove_shape_owner">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<description>
Removes the given shape owner.
</description>
</method>
<method name="set_collision_layer_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="shape_find_owner" qualifiers="const">
<return type="int" />
<param index="0" name="shape_index" type="int" />
<description>
Returns the [code]owner_id[/code] of the given shape.
</description>
</method>
<method name="shape_owner_add_shape">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape" type="Shape3D" />
<description>
Adds a [Shape3D] to the shape owner.
</description>
</method>
<method name="shape_owner_clear_shapes">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<description>
Removes all shapes from the shape owner.
</description>
</method>
<method name="shape_owner_get_owner" qualifiers="const">
<return type="Object" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the parent object of the given shape owner.
</description>
</method>
<method name="shape_owner_get_shape" qualifiers="const">
<return type="Shape3D" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Returns the [Shape3D] with the given ID from the given shape owner.
</description>
</method>
<method name="shape_owner_get_shape_count" qualifiers="const">
<return type="int" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the number of shapes the given shape owner contains.
</description>
</method>
<method name="shape_owner_get_shape_index" qualifiers="const">
<return type="int" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Returns the child index of the [Shape3D] with the given ID from the given shape owner.
</description>
</method>
<method name="shape_owner_get_transform" qualifiers="const">
<return type="Transform3D" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the shape owner's [Transform3D].
</description>
</method>
<method name="shape_owner_remove_shape">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Removes a shape from the given shape owner.
</description>
</method>
| |
124679
|
<method name="shape_owner_set_disabled">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="disabled" type="bool" />
<description>
If [code]true[/code], disables the given shape owner.
</description>
</method>
<method name="shape_owner_set_transform">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="transform" type="Transform3D" />
<description>
Sets the [Transform3D] of the given shape owner.
</description>
</method>
</methods>
<members>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this CollisionObject3D [b]is in[/b]. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this CollisionObject3D [b]scans[/b]. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0">
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
</member>
<member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="CollisionObject3D.DisableMode" default="0">
Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes.
</member>
<member name="input_capture_on_drag" type="bool" setter="set_capture_input_on_drag" getter="get_capture_input_on_drag" default="false">
If [code]true[/code], the [CollisionObject3D] will continue to receive input events as the mouse is dragged across its shapes.
</member>
<member name="input_ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="true">
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [member collision_layer] bit to be set.
</member>
</members>
<signals>
<signal name="input_event">
<param index="0" name="camera" type="Node" />
<param index="1" name="event" type="InputEvent" />
<param index="2" name="event_position" type="Vector3" />
<param index="3" name="normal" type="Vector3" />
<param index="4" name="shape_idx" type="int" />
<description>
Emitted when the object receives an unhandled [InputEvent]. [param event_position] is the location in world space of the mouse pointer on the surface of the shape with index [param shape_idx] and [param normal] is the normal vector of the surface at that point.
</description>
</signal>
<signal name="mouse_entered">
<description>
Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_ray_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
[b]Note:[/b] Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the [CollisionObject3D]'s area is small. This signal may also not be emitted if another [CollisionObject3D] is overlapping the [CollisionObject3D] in question.
</description>
</signal>
<signal name="mouse_exited">
<description>
Emitted when the mouse pointer exits all this object's shapes. Requires [member input_ray_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
[b]Note:[/b] Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the [CollisionObject3D]'s area is small. This signal may also not be emitted if another [CollisionObject3D] is overlapping the [CollisionObject3D] in question.
</description>
</signal>
</signals>
<constants>
<constant name="DISABLE_MODE_REMOVE" value="0" enum="DisableMode">
When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], remove from the physics simulation to stop all physics interactions with this [CollisionObject3D].
Automatically re-added to the physics simulation when the [Node] is processed again.
</constant>
<constant name="DISABLE_MODE_MAKE_STATIC" value="1" enum="DisableMode">
When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], make the body static. Doesn't affect [Area3D]. [PhysicsBody3D] can't be affected by forces or other bodies while static.
Automatically set [PhysicsBody3D] back to its original mode when the [Node] is processed again.
</constant>
<constant name="DISABLE_MODE_KEEP_ACTIVE" value="2" enum="DisableMode">
When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], do not affect the physics simulation.
</constant>
</constants>
</class>
| |
124684
|
<method name="get_theme_default_font_size" qualifiers="const">
<return type="int" />
<description>
Returns the default font size value from the first matching [Theme] in the tree if that [Theme] has a valid [member Theme.default_font_size] value.
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="get_theme_font" qualifiers="const">
<return type="Font" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns a [Font] from the first matching [Theme] in the tree if that [Theme] has a font item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="get_theme_font_size" qualifiers="const">
<return type="int" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns a font size from the first matching [Theme] in the tree if that [Theme] has a font size item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="get_theme_icon" qualifiers="const">
<return type="Texture2D" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns an icon from the first matching [Theme] in the tree if that [Theme] has an icon item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="get_theme_stylebox" qualifiers="const">
<return type="StyleBox" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns a [StyleBox] from the first matching [Theme] in the tree if that [Theme] has a stylebox item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="get_window_id" qualifiers="const">
<return type="int" />
<description>
Returns the ID of the window.
</description>
</method>
<method name="grab_focus">
<return type="void" />
<description>
Causes the window to grab focus, allowing it to receive user input.
</description>
</method>
<method name="has_focus" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the window is focused.
</description>
</method>
<method name="has_theme_color" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns [code]true[/code] if there is a matching [Theme] in the tree that has a color item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="has_theme_color_override" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme [Color] with the specified [param name] in this [Control] node.
See [method add_theme_color_override].
</description>
</method>
<method name="has_theme_constant" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns [code]true[/code] if there is a matching [Theme] in the tree that has a constant item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="has_theme_constant_override" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme constant with the specified [param name] in this [Control] node.
See [method add_theme_constant_override].
</description>
</method>
<method name="has_theme_font" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="has_theme_font_override" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme [Font] with the specified [param name] in this [Control] node.
See [method add_theme_font_override].
</description>
</method>
<method name="has_theme_font_size" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns [code]true[/code] if there is a matching [Theme] in the tree that has a font size item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="has_theme_font_size_override" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme font size with the specified [param name] in this [Control] node.
See [method add_theme_font_size_override].
</description>
</method>
<method name="has_theme_icon" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<param index="1" name="theme_type" type="StringName" default="&""" />
<description>
Returns [code]true[/code] if there is a matching [Theme] in the tree that has an icon item with the specified [param name] and [param theme_type].
See [method Control.get_theme_color] for details.
</description>
</method>
<method name="has_theme_icon_override" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns [code]true[/code] if there is a local override for a theme icon with the specified [param name] in this [Control] node.
See [method add_theme_icon_override].
</description>
</method>
| |
124687
|
<members>
<member name="always_on_top" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the window will be on top of all other windows. Does not work if [member transient] is enabled.
</member>
<member name="auto_translate" type="bool" setter="set_auto_translate" getter="is_auto_translating" default="true" deprecated="Use [member Node.auto_translate_mode] instead.">
Toggles if any text should automatically change to its translated version depending on the current locale.
</member>
<member name="borderless" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the window will have no borders.
</member>
<member name="content_scale_aspect" type="int" setter="set_content_scale_aspect" getter="get_content_scale_aspect" enum="Window.ContentScaleAspect" default="0">
Specifies how the content's aspect behaves when the [Window] is resized. The base aspect is determined by [member content_scale_size].
</member>
<member name="content_scale_factor" type="float" setter="set_content_scale_factor" getter="get_content_scale_factor" default="1.0">
Specifies the base scale of [Window]'s content when its [member size] is equal to [member content_scale_size].
</member>
<member name="content_scale_mode" type="int" setter="set_content_scale_mode" getter="get_content_scale_mode" enum="Window.ContentScaleMode" default="0">
Specifies how the content is scaled when the [Window] is resized.
</member>
<member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i(0, 0)">
Base size of the content (i.e. nodes that are drawn inside the window). If non-zero, [Window]'s content will be scaled when the window is resized to a different size.
</member>
<member name="content_scale_stretch" type="int" setter="set_content_scale_stretch" getter="get_content_scale_stretch" enum="Window.ContentScaleStretch" default="0">
The policy to use to determine the final scale factor for 2D elements. This affects how [member content_scale_factor] is applied, in addition to the automatic scale factor determined by [member content_scale_size].
</member>
<member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen">
The screen the window is currently on.
</member>
<member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false">
If [code]true[/code], the [Window] will be in exclusive mode. Exclusive windows are always on top of their parent and will block all input going to the parent [Window].
Needs [member transient] enabled to work.
</member>
<member name="extend_to_title" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the [Window] contents is expanded to the full size of the window, window title bar is transparent.
[b]Note:[/b] This property is implemented only on macOS.
[b]Note:[/b] This property only works with native windows.
</member>
<member name="force_native" type="bool" setter="set_force_native" getter="get_force_native" default="false">
If [code]true[/code], native window will be used regardless of parent viewport and project settings.
</member>
<member name="initial_position" type="int" setter="set_initial_position" getter="get_initial_position" enum="Window.WindowInitialPosition" default="0">
Specifies the initial type of position for the [Window]. See [enum WindowInitialPosition] constants.
</member>
<member name="keep_title_visible" type="bool" setter="set_keep_title_visible" getter="get_keep_title_visible" default="false">
If [code]true[/code], the [Window] width is expanded to keep the title bar text fully visible.
</member>
<member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i(0, 0)">
If non-zero, the [Window] can't be resized to be bigger than this size.
[b]Note:[/b] This property will be ignored if the value is lower than [member min_size].
</member>
<member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i(0, 0)">
If non-zero, the [Window] can't be resized to be smaller than this size.
[b]Note:[/b] This property will be ignored in favor of [method get_contents_minimum_size] if [member wrap_controls] is enabled and if its size is bigger.
</member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Window.Mode" default="0">
Set's the window's current mode.
[b]Note:[/b] Fullscreen mode is not exclusive full screen on Windows and Linux.
[b]Note:[/b] This method only works with native windows, i.e. the main window and [Window]-derived nodes when [member Viewport.gui_embed_subwindows] is disabled in the main viewport.
</member>
<member name="mouse_passthrough" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], all mouse events will be passed to the underlying window of the same application. See also [member mouse_passthrough_polygon].
[b]Note:[/b] This property is implemented on Linux (X11), macOS and Windows.
[b]Note:[/b] This property only works with native windows.
</member>
<member name="mouse_passthrough_polygon" type="PackedVector2Array" setter="set_mouse_passthrough_polygon" getter="get_mouse_passthrough_polygon" default="PackedVector2Array()">
Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through.
Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior).
[codeblocks]
[gdscript]
# Set region, using Path2D node.
$Window.mouse_passthrough_polygon = $Path2D.curve.get_baked_points()
# Set region, using Polygon2D node.
$Window.mouse_passthrough_polygon = $Polygon2D.polygon
# Reset region to default.
$Window.mouse_passthrough_polygon = []
[/gdscript]
[csharp]
// Set region, using Path2D node.
GetNode<Window>("Window").MousePassthrough = GetNode<Path2D>("Path2D").Curve.GetBakedPoints();
// Set region, using Polygon2D node.
GetNode<Window>("Window").MousePassthrough = GetNode<Polygon2D>("Polygon2D").Polygon;
// Reset region to default.
GetNode<Window>("Window").MousePassthrough = new Vector2[] {};
[/csharp]
[/codeblocks]
[b]Note:[/b] This property is ignored if [member mouse_passthrough] is set to [code]true[/code].
[b]Note:[/b] On Windows, the portion of a window that lies outside the region is not drawn, while on Linux (X11) and macOS it is.
[b]Note:[/b] This property is implemented on Linux (X11), macOS and Windows.
</member>
<member name="popup_window" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the [Window] will be considered a popup. Popups are sub-windows that don't show as separate windows in system's window manager's window list and will send close request when anything is clicked outside of them (unless [member exclusive] is enabled).
</member>
| |
124689
|
<signals>
<signal name="about_to_popup">
<description>
Emitted right after [method popup] call, before the [Window] appears or does anything.
</description>
</signal>
<signal name="close_requested">
<description>
Emitted when the [Window]'s close button is pressed or when [member popup_window] is enabled and user clicks outside the window.
This signal can be used to handle window closing, e.g. by connecting it to [method hide].
</description>
</signal>
<signal name="dpi_changed">
<description>
Emitted when the [Window]'s DPI changes as a result of OS-level changes (e.g. moving the window from a Retina display to a lower resolution one).
[b]Note:[/b] Only implemented on macOS.
</description>
</signal>
<signal name="files_dropped">
<param index="0" name="files" type="PackedStringArray" />
<description>
Emitted when files are dragged from the OS file manager and dropped in the game window. The argument is a list of file paths.
Note that this method only works with native windows, i.e. the main window and [Window]-derived nodes when [member Viewport.gui_embed_subwindows] is disabled in the main viewport.
Example usage:
[codeblock]
func _ready():
get_viewport().files_dropped.connect(on_files_dropped)
func on_files_dropped(files):
print(files)
[/codeblock]
</description>
</signal>
<signal name="focus_entered">
<description>
Emitted when the [Window] gains focus.
</description>
</signal>
<signal name="focus_exited">
<description>
Emitted when the [Window] loses its focus.
</description>
</signal>
<signal name="go_back_requested">
<description>
Emitted when a go back request is sent (e.g. pressing the "Back" button on Android), right after [constant Node.NOTIFICATION_WM_GO_BACK_REQUEST].
</description>
</signal>
<signal name="mouse_entered">
<description>
Emitted when the mouse cursor enters the [Window]'s visible area, that is not occluded behind other [Control]s or windows, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not.
</description>
</signal>
<signal name="mouse_exited">
<description>
Emitted when the mouse cursor leaves the [Window]'s visible area, that is not occluded behind other [Control]s or windows, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not.
</description>
</signal>
<signal name="theme_changed">
<description>
Emitted when the [constant NOTIFICATION_THEME_CHANGED] notification is sent.
</description>
</signal>
<signal name="titlebar_changed">
<description>
Emitted when window title bar decorations are changed, e.g. macOS window enter/exit full screen mode, or extend-to-title flag is changed.
</description>
</signal>
<signal name="visibility_changed">
<description>
Emitted when [Window] is made visible or disappears.
</description>
</signal>
<signal name="window_input">
<param index="0" name="event" type="InputEvent" />
<description>
Emitted when the [Window] is currently focused and receives any input, passing the received event as an argument. The event's position, if present, is in the embedder's coordinate system.
</description>
</signal>
</signals>
| |
124700
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="InputEventMouse" inherits="InputEventWithModifiers" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Base input event type for mouse events.
</brief_description>
<description>
Stores general information about mouse events.
</description>
<tutorials>
<link title="Using InputEvent">$DOCS_URL/tutorials/inputs/inputevent.html</link>
</tutorials>
<members>
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" enum="MouseButtonMask" is_bitfield="true" default="0">
The mouse button mask identifier, one of or a bitwise combination of the [enum MouseButton] button masks.
</member>
<member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2(0, 0)">
When received in [method Node._input] or [method Node._unhandled_input], returns the mouse's position in the root [Viewport] using the coordinate system of the root [Viewport].
When received in [method Control._gui_input], returns the mouse's position in the [CanvasLayer] that the [Control] is in using the coordinate system of the [CanvasLayer].
</member>
<member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)">
When received in [method Node._input] or [method Node._unhandled_input], returns the mouse's position in the [Viewport] this [Node] is in using the coordinate system of this [Viewport].
When received in [method Control._gui_input], returns the mouse's position in the [Control] using the local coordinate system of the [Control].
</member>
</members>
</class>
| |
124709
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CollisionObject2D" inherits="Node2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Abstract base class for 2D physics objects.
</brief_description>
<description>
Abstract base class for 2D physics objects. [CollisionObject2D] can hold any number of [Shape2D]s for collision. Each shape must be assigned to a [i]shape owner[/i]. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods.
[b]Note:[/b] Only collisions between objects within the same canvas ([Viewport] canvas or [CanvasLayer]) are supported. The behavior of collisions between objects in different canvases is undefined.
</description>
<tutorials>
</tutorials>
| |
124710
|
<methods>
<method name="_input_event" qualifiers="virtual">
<return type="void" />
<param index="0" name="viewport" type="Viewport" />
<param index="1" name="event" type="InputEvent" />
<param index="2" name="shape_idx" type="int" />
<description>
Accepts unhandled [InputEvent]s. [param shape_idx] is the child index of the clicked [Shape2D]. Connect to [signal input_event] to easily pick up these events.
[b]Note:[/b] [method _input_event] requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
</description>
</method>
<method name="_mouse_enter" qualifiers="virtual">
<return type="void" />
<description>
Called when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this function to be called.
</description>
</method>
<method name="_mouse_exit" qualifiers="virtual">
<return type="void" />
<description>
Called when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this function to be called.
</description>
</method>
<method name="_mouse_shape_enter" qualifiers="virtual">
<return type="void" />
<param index="0" name="shape_idx" type="int" />
<description>
Called when the mouse pointer enters any of this object's shapes or moves from one shape to another. [param shape_idx] is the child index of the newly entered [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be called.
</description>
</method>
<method name="_mouse_shape_exit" qualifiers="virtual">
<return type="void" />
<param index="0" name="shape_idx" type="int" />
<description>
Called when the mouse pointer exits any of this object's shapes. [param shape_idx] is the child index of the exited [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be called.
</description>
</method>
<method name="create_shape_owner">
<return type="int" />
<param index="0" name="owner" type="Object" />
<description>
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
</description>
</method>
<method name="get_collision_layer_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the object's [RID].
</description>
</method>
<method name="get_shape_owner_one_way_collision_margin" qualifiers="const">
<return type="float" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [param owner_id].
</description>
</method>
<method name="get_shape_owners">
<return type="PackedInt32Array" />
<description>
Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument.
</description>
</method>
<method name="is_shape_owner_disabled" qualifiers="const">
<return type="bool" />
<param index="0" name="owner_id" type="int" />
<description>
If [code]true[/code], the shape owner and its shapes are disabled.
</description>
</method>
<method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
<return type="bool" />
<param index="0" name="owner_id" type="int" />
<description>
Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
</description>
</method>
<method name="remove_shape_owner">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<description>
Removes the given shape owner.
</description>
</method>
<method name="set_collision_layer_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="shape_find_owner" qualifiers="const">
<return type="int" />
<param index="0" name="shape_index" type="int" />
<description>
Returns the [code]owner_id[/code] of the given shape.
</description>
</method>
<method name="shape_owner_add_shape">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape" type="Shape2D" />
<description>
Adds a [Shape2D] to the shape owner.
</description>
</method>
<method name="shape_owner_clear_shapes">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<description>
Removes all shapes from the shape owner.
</description>
</method>
<method name="shape_owner_get_owner" qualifiers="const">
<return type="Object" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the parent object of the given shape owner.
</description>
</method>
<method name="shape_owner_get_shape" qualifiers="const">
<return type="Shape2D" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Returns the [Shape2D] with the given ID from the given shape owner.
</description>
</method>
| |
124711
|
<method name="shape_owner_get_shape_count" qualifiers="const">
<return type="int" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the number of shapes the given shape owner contains.
</description>
</method>
<method name="shape_owner_get_shape_index" qualifiers="const">
<return type="int" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Returns the child index of the [Shape2D] with the given ID from the given shape owner.
</description>
</method>
<method name="shape_owner_get_transform" qualifiers="const">
<return type="Transform2D" />
<param index="0" name="owner_id" type="int" />
<description>
Returns the shape owner's [Transform2D].
</description>
</method>
<method name="shape_owner_remove_shape">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="shape_id" type="int" />
<description>
Removes a shape from the given shape owner.
</description>
</method>
<method name="shape_owner_set_disabled">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="disabled" type="bool" />
<description>
If [code]true[/code], disables the given shape owner.
</description>
</method>
<method name="shape_owner_set_one_way_collision">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="enable" type="bool" />
<description>
If [param enable] is [code]true[/code], collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
</description>
</method>
<method name="shape_owner_set_one_way_collision_margin">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="margin" type="float" />
<description>
Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [param owner_id] to [param margin] pixels.
</description>
</method>
<method name="shape_owner_set_transform">
<return type="void" />
<param index="0" name="owner_id" type="int" />
<param index="1" name="transform" type="Transform2D" />
<description>
Sets the [Transform2D] of the given shape owner.
</description>
</method>
</methods>
<members>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0">
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
</member>
<member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="CollisionObject2D.DisableMode" default="0">
Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes.
</member>
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [member collision_layer] bit to be set.
</member>
</members>
<signals>
<signal name="input_event">
<param index="0" name="viewport" type="Node" />
<param index="1" name="event" type="InputEvent" />
<param index="2" name="shape_idx" type="int" />
<description>
Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. See [method _input_event] for details.
</description>
</signal>
<signal name="mouse_entered">
<description>
Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this signal to be emitted.
[b]Note:[/b] Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the [CollisionObject2D]'s area is small. This signal may also not be emitted if another [CollisionObject2D] is overlapping the [CollisionObject2D] in question.
</description>
</signal>
<signal name="mouse_exited">
<description>
Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set. Note that moving between different shapes within a single [CollisionObject2D] won't cause this signal to be emitted.
[b]Note:[/b] Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the [CollisionObject2D]'s area is small. This signal may also not be emitted if another [CollisionObject2D] is overlapping the [CollisionObject2D] in question.
</description>
</signal>
<signal name="mouse_shape_entered">
<param index="0" name="shape_idx" type="int" />
<description>
Emitted when the mouse pointer enters any of this object's shapes or moves from one shape to another. [param shape_idx] is the child index of the newly entered [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
</description>
</signal>
<signal name="mouse_shape_exited">
<param index="0" name="shape_idx" type="int" />
<description>
Emitted when the mouse pointer exits any of this object's shapes. [param shape_idx] is the child index of the exited [Shape2D]. Requires [member input_pickable] to be [code]true[/code] and at least one [member collision_layer] bit to be set.
</description>
</signal>
</signals>
| |
124716
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CollisionShape3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A node that provides a [Shape3D] to a [CollisionObject3D] parent.
</brief_description>
<description>
A node that provides a [Shape3D] to a [CollisionObject3D] parent and allows to edit it. This can give a detection shape to an [Area3D] or turn a [PhysicsBody3D] into a solid object.
[b]Warning:[/b] A non-uniformly scaled [CollisionShape3D] will likely not behave as expected. Make sure to keep its scale the same on all axes and adjust its [member shape] resource instead.
</description>
<tutorials>
<link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
<link title="3D Kinematic Character Demo">https://godotengine.org/asset-library/asset/2739</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/2748</link>
<link title="Third Person Shooter (TPS) Demo">https://godotengine.org/asset-library/asset/2710</link>
</tutorials>
<methods>
<method name="make_convex_from_siblings">
<return type="void" />
<description>
Sets the collision shape's shape to the addition of all its convexed [MeshInstance3D] siblings geometry.
</description>
</method>
<method name="resource_changed" deprecated="Use [signal Resource.changed] instead.">
<return type="void" />
<param index="0" name="resource" type="Resource" />
<description>
This method does nothing.
</description>
</method>
</methods>
<members>
<member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false" keywords="enabled">
A disabled collision shape has no effect in the world.
</member>
<member name="shape" type="Shape3D" setter="set_shape" getter="get_shape">
The actual shape owned by this collision shape.
</member>
</members>
</class>
| |
124740
|
<method name="area_set_area_monitor_callback">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="callback" type="Callable" />
<description>
Sets the area's area monitor callback. This callback will be called when any other (shape of an) area enters or exits (a shape of) the given area, and must take the following five parameters:
1. an integer [code]status[/code]: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other area's shape entered or exited the area,
2. an [RID] [code]area_rid[/code]: the [RID] of the other area that entered or exited the area,
3. an integer [code]instance_id[/code]: the [code]ObjectID[/code] attached to the other area,
4. an integer [code]area_shape_idx[/code]: the index of the shape of the other area that entered or exited the area,
5. an integer [code]self_shape_idx[/code]: the index of the shape of the area where the other area entered or exited.
By counting (or keeping track of) the shapes that enter and exit, it can be determined if an area (with all its shapes) is entering for the first time or exiting for the last time.
</description>
</method>
<method name="area_set_collision_layer">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="layer" type="int" />
<description>
Assigns the area to one or many physics layers, via a bitmask.
</description>
</method>
<method name="area_set_collision_mask">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="mask" type="int" />
<description>
Sets which physics layers the area will monitor, via a bitmask.
</description>
</method>
<method name="area_set_monitor_callback">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="callback" type="Callable" />
<description>
Sets the area's body monitor callback. This callback will be called when any other (shape of a) body enters or exits (a shape of) the given area, and must take the following five parameters:
1. an integer [code]status[/code]: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other body shape entered or exited the area,
2. an [RID] [code]body_rid[/code]: the [RID] of the body that entered or exited the area,
3. an integer [code]instance_id[/code]: the [code]ObjectID[/code] attached to the body,
4. an integer [code]body_shape_idx[/code]: the index of the shape of the body that entered or exited the area,
5. an integer [code]self_shape_idx[/code]: the index of the shape of the area where the body entered or exited.
By counting (or keeping track of) the shapes that enter and exit, it can be determined if a body (with all its shapes) is entering for the first time or exiting for the last time.
</description>
</method>
<method name="area_set_monitorable">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="monitorable" type="bool" />
<description>
Sets whether the area is monitorable or not. If [param monitorable] is [code]true[/code], the area monitoring callback of other areas will be called when this area enters or exits them.
</description>
</method>
<method name="area_set_param">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" />
<param index="2" name="value" type="Variant" />
<description>
Sets the value of the given area parameter. See [enum AreaParameter] for the list of available parameters.
</description>
</method>
<method name="area_set_shape">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="shape" type="RID" />
<description>
Replaces the area's shape at the given index by another shape, while not affecting the [code]transform[/code] and [code]disabled[/code] properties at the same index.
</description>
</method>
<method name="area_set_shape_disabled">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="disabled" type="bool" />
<description>
Sets the disabled property of the area's shape with the given index. If [param disabled] is [code]true[/code], then the shape will not detect any other shapes entering or exiting it.
</description>
</method>
<method name="area_set_shape_transform">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="transform" type="Transform2D" />
<description>
Sets the local transform matrix of the area's shape with the given index.
</description>
</method>
<method name="area_set_space">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="space" type="RID" />
<description>
Adds the area to the given space, after removing the area from the previously assigned space (if any).
[b]Note:[/b] To remove an area from a space without immediately adding it back elsewhere, use [code]PhysicsServer2D.area_set_space(area, RID())[/code].
</description>
</method>
<method name="area_set_transform">
<return type="void" />
<param index="0" name="area" type="RID" />
<param index="1" name="transform" type="Transform2D" />
<description>
Sets the transform matrix of the area.
</description>
</method>
<method name="body_add_collision_exception">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="excepted_body" type="RID" />
<description>
Adds [param excepted_body] to the body's list of collision exceptions, so that collisions with it are ignored.
</description>
</method>
<method name="body_add_constant_central_force">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="force" type="Vector2" />
<description>
Adds a constant directional force to the body. The force does not affect rotation. The force remains applied over time until cleared with [code]PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))[/code].
This is equivalent to using [method body_add_constant_force] at the body's center of mass.
</description>
</method>
| |
124743
|
<method name="body_set_collision_layer">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="layer" type="int" />
<description>
Sets the physics layer or layers the body belongs to, via a bitmask.
</description>
</method>
<method name="body_set_collision_mask">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="mask" type="int" />
<description>
Sets the physics layer or layers the body can collide with, via a bitmask.
</description>
</method>
<method name="body_set_collision_priority">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="priority" type="float" />
<description>
Sets the body's collision priority. This is used in the depenetration phase of [method body_test_motion]. The higher the priority is, the lower the penetration into the body will be.
</description>
</method>
<method name="body_set_constant_force">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="force" type="Vector2" />
<description>
Sets the body's total constant positional force applied during each physics update.
See [method body_add_constant_force] and [method body_add_constant_central_force].
</description>
</method>
<method name="body_set_constant_torque">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="torque" type="float" />
<description>
Sets the body's total constant rotational force applied during each physics update.
See [method body_add_constant_torque].
</description>
</method>
<method name="body_set_continuous_collision_detection_mode">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode" />
<description>
Sets the continuous collision detection mode using one of the [enum CCDMode] constants.
Continuous collision detection tries to predict where a moving body would collide in between physics updates, instead of moving it and correcting its movement if it collided.
</description>
</method>
<method name="body_set_force_integration_callback">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="callable" type="Callable" />
<param index="2" name="userdata" type="Variant" default="null" />
<description>
Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the custom callback.
The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
If [param userdata] is not [code]null[/code], the function [param callable] must take the following two parameters:
1. [code]state[/code]: a [PhysicsDirectBodyState2D] used to retrieve and modify the body's state,
2. [code skip-lint]userdata[/code]: a [Variant]; its value will be the [param userdata] passed into this method.
If [param userdata] is [code]null[/code], then [param callable] must take only the [code]state[/code] parameter.
</description>
</method>
<method name="body_set_max_contacts_reported">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="amount" type="int" />
<description>
Sets the maximum number of contacts that the body can report. If [param amount] is greater than zero, then the body will keep track of at most this many contacts with other bodies.
</description>
</method>
<method name="body_set_mode">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode" />
<description>
Sets the body's mode. See [enum BodyMode] for the list of available modes.
</description>
</method>
<method name="body_set_omit_force_integration">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="enable" type="bool" />
<description>
Sets whether the body omits the standard force integration. If [param enable] is [code]true[/code], the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
This method is called when the property [member RigidBody2D.custom_integrator] is set.
</description>
</method>
<method name="body_set_param">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" />
<param index="2" name="value" type="Variant" />
<description>
Sets the value of the given body parameter. See [enum BodyParameter] for the list of available parameters.
</description>
</method>
<method name="body_set_shape">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="shape" type="RID" />
<description>
Replaces the body's shape at the given index by another shape, while not affecting the [code]transform[/code], [code]disabled[/code], and one-way collision properties at the same index.
</description>
</method>
<method name="body_set_shape_as_one_way_collision">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="enable" type="bool" />
<param index="3" name="margin" type="float" />
<description>
Sets the one-way collision properties of the body's shape with the given index. If [param enable] is [code]true[/code], the one-way collision direction given by the shape's local upward axis [code]body_get_shape_transform(body, shape_idx).y[/code] will be used to ignore collisions with the shape in the opposite direction, and to ensure depenetration of kinematic bodies happens in this direction.
</description>
</method>
<method name="body_set_shape_disabled">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="shape_idx" type="int" />
<param index="2" name="disabled" type="bool" />
<description>
Sets the disabled property of the body's shape with the given index. If [param disabled] is [code]true[/code], then the shape will be ignored in all collision detection.
</description>
</method>
| |
124754
|
<members>
<member name="collide_with_areas" type="bool" setter="set_collide_with_areas" getter="is_collide_with_areas_enabled" default="false">
If [code]true[/code], collisions with [Area2D]s will be reported.
</member>
<member name="collide_with_bodies" type="bool" setter="set_collide_with_bodies" getter="is_collide_with_bodies_enabled" default="true">
If [code]true[/code], collisions with [PhysicsBody2D]s will be reported.
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_result" type="Array" setter="" getter="get_collision_result" default="[]">
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState2D.get_rest_info] method.
</member>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
If [code]true[/code], collisions will be reported.
</member>
<member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true">
If [code]true[/code], the parent node will be excluded from collision detection.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0">
The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision.
</member>
<member name="max_results" type="int" setter="set_max_results" getter="get_max_results" default="32">
The number of intersections can be limited with this parameter, to reduce the processing time.
</member>
<member name="shape" type="Shape2D" setter="set_shape" getter="get_shape">
The shape to be used for collision queries.
</member>
<member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2(0, 50)">
The shape's destination point, relative to this node's [member Node2D.position].
</member>
</members>
</class>
| |
124780
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="HBoxContainer" inherits="BoxContainer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A container that arranges its child controls horizontally.
</brief_description>
<description>
A variant of [BoxContainer] that can only arrange its child controls horizontally. Child controls are rearranged automatically when their minimum size changes.
</description>
<tutorials>
<link title="Using Containers">$DOCS_URL/tutorials/ui/gui_containers.html</link>
</tutorials>
</class>
| |
124903
|
<method name="get_video_adapter_driver_info" qualifiers="const">
<return type="PackedStringArray" />
<description>
Returns the video adapter driver name and version for the user's currently active graphics card, as a [PackedStringArray]. See also [method RenderingServer.get_video_adapter_api_version].
The first element holds the driver name, such as [code]nvidia[/code], [code]amdgpu[/code], etc.
The second element holds the driver version. For example, on the [code]nvidia[/code] driver on a Linux/BSD platform, the version is in the format [code]510.85.02[/code]. For Windows, the driver's format is [code]31.0.15.1659[/code].
[b]Note:[/b] This method is only supported on Linux/BSD and Windows when not running in headless mode. On other platforms, it returns an empty array.
</description>
</method>
<method name="has_environment" qualifiers="const">
<return type="bool" />
<param index="0" name="variable" type="String" />
<description>
Returns [code]true[/code] if the environment variable with the name [param variable] exists.
[b]Note:[/b] Double-check the casing of [param variable]. Environment variable names are case-sensitive on all platforms except Windows.
</description>
</method>
<method name="has_feature" qualifiers="const">
<return type="bool" />
<param index="0" name="tag_name" type="String" />
<description>
Returns [code]true[/code] if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build, etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the [url=$DOCS_URL/tutorials/export/feature_tags.html]Feature Tags[/url] documentation for more details.
[b]Note:[/b] Tag names are case-sensitive.
[b]Note:[/b] On the Web platform, one of the following additional tags is defined to indicate the host platform: [code]web_android[/code], [code]web_ios[/code], [code]web_linuxbsd[/code], [code]web_macos[/code], or [code]web_windows[/code].
</description>
</method>
<method name="is_debug_build" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the Godot binary used to run the project is a [i]debug[/i] export template, or when running in the editor.
Returns [code]false[/code] if the Godot binary used to run the project is a [i]release[/i] export template.
[b]Note:[/b] To check whether the Godot binary used to run the project is an export template (debug or release), use [code]OS.has_feature("template")[/code] instead.
</description>
</method>
<method name="is_keycode_unicode" qualifiers="const">
<return type="bool" />
<param index="0" name="code" type="int" />
<description>
Returns [code]true[/code] if the input keycode corresponds to a Unicode character. For a list of codes, see the [enum Key] constants.
[codeblocks]
[gdscript]
print(OS.is_keycode_unicode(KEY_G)) # Prints true
print(OS.is_keycode_unicode(KEY_KP_4)) # Prints true
print(OS.is_keycode_unicode(KEY_TAB)) # Prints false
print(OS.is_keycode_unicode(KEY_ESCAPE)) # Prints false
[/gdscript]
[csharp]
GD.Print(OS.IsKeycodeUnicode((long)Key.G)); // Prints true
GD.Print(OS.IsKeycodeUnicode((long)Key.Kp4)); // Prints true
GD.Print(OS.IsKeycodeUnicode((long)Key.Tab)); // Prints false
GD.Print(OS.IsKeycodeUnicode((long)Key.Escape)); // Prints false
[/csharp]
[/codeblocks]
</description>
</method>
<method name="is_process_running" qualifiers="const">
<return type="bool" />
<param index="0" name="pid" type="int" />
<description>
Returns [code]true[/code] if the child process ID ([param pid]) is still running or [code]false[/code] if it has terminated. [param pid] must be a valid ID generated from [method create_process].
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS, and Windows.
</description>
</method>
<method name="is_restart_on_exit_set" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the project will automatically restart when it exits for any reason, [code]false[/code] otherwise. See also [method set_restart_on_exit] and [method get_restart_on_exit_arguments].
</description>
</method>
<method name="is_sandboxed" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the application is running in the sandbox.
[b]Note:[/b] This method is only implemented on macOS and Linux.
</description>
</method>
<method name="is_stdout_verbose" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the engine was executed with the [code]--verbose[/code] or [code]-v[/code] command line argument, or if [member ProjectSettings.debug/settings/stdout/verbose_stdout] is [code]true[/code]. See also [method @GlobalScope.print_verbose].
</description>
</method>
<method name="is_userfs_persistent" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the [code]user://[/code] file system is persistent, that is, its state is the same after a player quits and starts the game again. Relevant to the Web platform, where this persistence may be unavailable.
</description>
</method>
<method name="kill">
<return type="int" enum="Error" />
<param index="0" name="pid" type="int" />
<description>
Kill (terminate) the process identified by the given process ID ([param pid]), such as the ID returned by [method execute] in non-blocking mode. See also [method crash].
[b]Note:[/b] This method can also be used to kill processes that were not spawned by the engine.
[b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
</description>
</method>
<method name="move_to_trash" qualifiers="const">
<return type="int" enum="Error" />
<param index="0" name="path" type="String" />
<description>
Moves the file or directory at the given [param path] to the system's recycle bin. See also [method DirAccess.remove].
The method takes only global paths, so you may need to use [method ProjectSettings.globalize_path]. Do not use it for files in [code]res://[/code] as it will not work in exported projects.
Returns [constant FAILED] if the file or directory cannot be found, or the system does not support this method.
[codeblocks]
[gdscript]
var file_to_remove = "user://slot1.save"
OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
[/gdscript]
[csharp]
var fileToRemove = "user://slot1.save";
OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
[/csharp]
[/codeblocks]
[b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
[b]Note:[/b] If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
</description>
</method>
| |
124910
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Basis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A 3×3 matrix for representing 3D rotation and scale.
</brief_description>
<description>
The [Basis] built-in [Variant] type is a 3×3 [url=https://en.wikipedia.org/wiki/Matrix_(mathematics)]matrix[/url] used to represent 3D rotation, scale, and shear. It is frequently used within a [Transform3D].
A [Basis] is composed by 3 axis vectors, each representing a column of the matrix: [member x], [member y], and [member z]. The length of each axis ([method Vector3.length]) influences the basis's scale, while the direction of all axes influence the rotation. Usually, these axes are perpendicular to one another. However, when you rotate any axis individually, the basis becomes sheared. Applying a sheared basis to a 3D model will make the model appear distorted.
A [Basis] is [b]orthogonal[/b] if its axes are perpendicular to each other. A basis is [b]normalized[/b] if the length of every axis is [code]1[/code]. A basis is [b]uniform[/b] if all axes share the same length (see [method get_scale]). A basis is [b]orthonormal[/b] if it is both orthogonal and normalized, which allows it to only represent rotations. A basis is [b]conformal[/b] if it is both orthogonal and uniform, which ensures it is not distorted.
For a general introduction, see the [url=$DOCS_URL/tutorials/math/matrices_and_transforms.html]Matrices and transforms[/url] tutorial.
[b]Note:[/b] Godot uses a [url=https://en.wikipedia.org/wiki/Right-hand_rule]right-handed coordinate system[/url], which is a common standard. For directions, the convention for built-in types like [Camera3D] is for -Z to point forward (+X is right, +Y is up, and +Z is back). Other objects may use different direction conventions. For more information, see the [url=$DOCS_URL/tutorials/assets_pipeline/importing_3d_scenes/model_export_considerations.html#d-asset-direction-conventions]3D asset direction conventions[/url] tutorial.
[b]Note:[/b] The basis matrices are exposed as [url=https://www.mindcontrol.org/~hplus/graphics/matrix-layout.html]column-major[/url] order, which is the same as OpenGL. However, they are stored internally in row-major order, which is the same as DirectX.
</description>
<tutorials>
<link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link>
<link title="Matrices and transforms">$DOCS_URL/tutorials/math/matrices_and_transforms.html</link>
<link title="Using 3D transforms">$DOCS_URL/tutorials/3d/using_transforms.html</link>
<link title="Matrix Transform Demo">https://godotengine.org/asset-library/asset/2787</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/2748</link>
<link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/2755</link>
<link title="2.5D Game Demo">https://godotengine.org/asset-library/asset/2783</link>
</tutorials>
<constructors>
<constructor name="Basis">
<return type="Basis" />
<description>
Constructs a [Basis] identical to the [constant IDENTITY].
</description>
</constructor>
<constructor name="Basis">
<return type="Basis" />
<param index="0" name="from" type="Basis" />
<description>
Constructs a [Basis] as a copy of the given [Basis].
</description>
</constructor>
<constructor name="Basis">
<return type="Basis" />
<param index="0" name="axis" type="Vector3" />
<param index="1" name="angle" type="float" />
<description>
Constructs a [Basis] that only represents rotation, rotated around the [param axis] by the given [param angle], in radians. The axis must be a normalized vector.
[b]Note:[/b] This is the same as using [method rotated] on the [constant IDENTITY] basis. With more than one angle consider using [method from_euler], instead.
</description>
</constructor>
<constructor name="Basis">
<return type="Basis" />
<param index="0" name="from" type="Quaternion" />
<description>
Constructs a [Basis] that only represents rotation from the given [Quaternion].
[b]Note:[/b] Quaternions [i]only[/i] store rotation, not scale. Because of this, conversions from [Basis] to [Quaternion] cannot always be reversed.
</description>
</constructor>
<constructor name="Basis">
<return type="Basis" />
<param index="0" name="x_axis" type="Vector3" />
<param index="1" name="y_axis" type="Vector3" />
<param index="2" name="z_axis" type="Vector3" />
<description>
Constructs a [Basis] from 3 axis vectors. These are the columns of the basis matrix.
</description>
</constructor>
</constructors>
<m
| |
124911
|
ethods>
<method name="determinant" qualifiers="const">
<return type="float" />
<description>
Returns the [url=https://en.wikipedia.org/wiki/Determinant]determinant[/url] of this basis's matrix. For advanced math, this number can be used to determine a few attributes:
- If the determinant is exactly [code]0[/code], the basis is not invertible (see [method inverse]).
- If the determinant is a negative number, the basis represents a negative scale.
[b]Note:[/b] If the basis's scale is the same for every axis, its determinant is always that scale by the power of 2.
</description>
</method>
<method name="from_euler" qualifiers="static">
<return type="Basis" />
<param index="0" name="euler" type="Vector3" />
<param index="1" name="order" type="int" default="2" />
<description>
Constructs a new [Basis] that only represents rotation from the given [Vector3] of [url=https://en.wikipedia.org/wiki/Euler_angles]Euler angles[/url], in radians.
- The [member Vector3.x] should contain the angle around the [member x] axis (pitch).
- The [member Vector3.y] should contain the angle around the [member y] axis (yaw).
- The [member Vector3.z] should contain the angle around the [member z] axis (roll).
[codeblocks]
[gdscript]
# Creates a Basis whose z axis points down.
var my_basis = Basis.from_euler(Vector3(TAU / 4, 0, 0))
print(my_basis.z) # Prints (0, -1, 0).
[/gdscript]
[csharp]
// Creates a Basis whose z axis points down.
var myBasis = Basis.FromEuler(new Vector3(Mathf.Tau / 4.0f, 0.0f, 0.0f));
GD.Print(myBasis.Z); // Prints (0, -1, 0).
[/csharp]
[/codeblocks]
The order of each consecutive rotation can be changed with [param order] (see [enum EulerOrder] constants). By default, the YXZ convention is used ([constant EULER_ORDER_YXZ]): the basis rotates first around the Y axis (yaw), then X (pitch), and lastly Z (roll). When using the opposite method [method get_euler], this order is reversed.
</description>
</method>
<method name="from_scale" qualifiers="static">
<return type="Basis" />
<param index="0" name="scale" type="Vector3" />
<description>
Constructs a new [Basis] that only represents scale, with no rotation or shear, from the given [param scale] vector.
[codeblocks]
[gdscript]
var my_basis = Basis.from_scale(Vector3(2, 4, 8))
print(my_basis.x) # Prints (2, 0, 0).
print(my_basis.y) # Prints (0, 4, 0).
print(my_basis.z) # Prints (0, 0, 8).
[/gdscript]
[csharp]
var myBasis = Basis.FromScale(new Vector3(2.0f, 4.0f, 8.0f));
GD.Print(myBasis.X); // Prints (2, 0, 0).
GD.Print(myBasis.Y); // Prints (0, 4, 0).
GD.Print(myBasis.Z); // Prints (0, 0, 8).
[/csharp]
[/codeblocks]
[b]Note:[/b] In linear algebra, the matrix of this basis is also known as a [url=https://en.wikipedia.org/wiki/Diagonal_matrix]diagonal matrix[/url].
</description>
</method>
<method name="get_euler" qualifiers="const">
<return type="Vector3" />
<param index="0" name="order" type="int" default="2" />
<description>
Returns this basis's rotation as a [Vector3] of [url=https://en.wikipedia.org/wiki/Euler_angles]Euler angles[/url], in radians.
- The [member Vector3.x] contains the angle around the [member x] axis (pitch);
- The [member Vector3.y] contains the angle around the [member y] axis (yaw);
- The [member Vector3.z] contains the angle around the [member z] axis (roll).
The order of each consecutive rotation can be changed with [param order] (see [enum EulerOrder] constants). By default, the YXZ convention is used ([constant EULER_ORDER_YXZ]): Z (roll) is calculated first, then X (pitch), and lastly Y (yaw). When using the opposite method [method from_euler], this order is reversed.
[b]Note:[/b] Euler angles are much more intuitive but are not suitable for 3D math. Because of this, consider using the [method get_rotation_quaternion] method instead, which returns a [Quaternion].
[b]Note:[/b] In the Inspector dock, a basis's rotation is often displayed in Euler angles (in degrees), as is the case with the [member Node3D.rotation] property.
</description>
</method>
<method name="get_rotation_quaternion" qualifiers="const">
<return type="Quaternion" />
<description>
Returns this basis's rotation as a [Quaternion].
[b]Note:[/b] Quatenions are much more suitable for 3D math but are less intuitive. For user interfaces, consider using the [method get_euler] method, which returns Euler angles.
</description>
</method>
<method name="get_scale" qualifiers="const">
<return type="Vector3" />
<description>
Returns the length of each axis of this basis, as a [Vector3]. If the basis is not sheared, this is the scaling factor. It is not affected by rotation.
[codeblocks]
[gdscript]
var my_basis = Basis(
Vector3(2, 0, 0),
Vector3(0, 4, 0),
Vector3(0, 0, 8)
)
# Rotating the Basis in any way preserves its scale.
my_basis = my_basis.rotated(Vector3.UP, TAU / 2)
my_basis = my_basis.rotated(Vector3.RIGHT, TAU / 4)
print(my_basis.get_scale()) # Prints (2, 4, 8).
[/gdscript]
[csharp]
var myBasis = new Basis(
Vector3(2.0f, 0.0f, 0.0f),
Vector3(0.0f, 4.0f, 0.0f),
Vector3(0.0f, 0.0f, 8.0f)
);
// Rotating the Basis in any way preserves its scale.
myBasis = myBasis.Rotated(Vector3.Up, Mathf.Tau / 2.0f);
myBasis = myBasis.Rotated(Vector3.Right, Mathf.Tau / 4.0f);
GD.Print(myBasis.Scale); // Prints (2, 4, 8).
[/csharp]
[/codeblocks]
[b]Note:[/b] If the value returned by [method determinant] is negative, the scale is also negative.
</description>
</method>
<method name="inverse" qualifiers="const">
<return type="Basis" />
<description>
Returns the [url=https://en.wikipedia.org/wiki/Invertible_matrix]inverse of this basis's matrix[/url].
</description>
</method>
<method name="is_conformal" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this basis is conformal. A conformal basis is both [i]orthogonal[/i] (the axes are perpendicular to each other) and [i]uniform[/i] (the axes share the same length). This method can be especially useful during physics calculations.
</description>
</method>
<m
| |
124912
|
ethod name="is_equal_approx" qualifiers="const">
<return type="bool" />
<param index="0" name="b" type="Basis" />
<description>
Returns [code]true[/code] if this basis and [param b] are approximately equal, by calling [method @GlobalScope.is_equal_approx] on all vector components.
</description>
</method>
<method name="is_finite" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this basis is finite, by calling [method @GlobalScope.is_finite] on all vector components.
</description>
</method>
<method name="looking_at" qualifiers="static">
<return type="Basis" />
<param index="0" name="target" type="Vector3" />
<param index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)" />
<param index="2" name="use_model_front" type="bool" default="false" />
<description>
Creates a new [Basis] with a rotation such that the forward axis (-Z) points towards the [param target] position.
By default, the -Z axis (camera forward) is treated as forward (implies +X is right). If [param use_model_front] is [code]true[/code], the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the [param target] position.
The up axis (+Y) points as close to the [param up] vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see [method orthonormalized]). The [param target] and [param up] vectors cannot be [constant Vector3.ZERO], and cannot be parallel to each other.
</description>
</method>
<method name="orthonormalized" qualifiers="const">
<return type="Basis" />
<description>
Returns the orthonormalized version of this basis. An orthonormal basis is both [i]orthogonal[/i] (the axes are perpendicular to each other) and [i]normalized[/i] (the axes have a length of [code]1[/code]), which also means it can only represent rotation.
It is often useful to call this method to avoid rounding errors on a rotating basis:
[codeblocks]
[gdscript]
# Rotate this Node3D every frame.
func _process(delta):
basis = basis.rotated(Vector3.UP, TAU * delta)
basis = basis.rotated(Vector3.RIGHT, TAU * delta)
basis = basis.orthonormalized()
[/gdscript]
[csharp]
// Rotate this Node3D every frame.
public override void _Process(double delta)
{
Basis = Basis.Rotated(Vector3.Up, Mathf.Tau * (float)delta)
.Rotated(Vector3.Right, Mathf.Tau * (float)delta)
.Orthonormalized();
}
[/csharp]
[/codeblocks]
</description>
</method>
<method name="rotated" qualifiers="const">
<return type="Basis" />
<param index="0" name="axis" type="Vector3" />
<param index="1" name="angle" type="float" />
<description>
Returns this basis rotated around the given [param axis] by [param angle] (in radians). The [param axis] must be a normalized vector (see [method Vector3.normalized]).
Positive values rotate this basis clockwise around the axis, while negative values rotate it counterclockwise.
[codeblocks]
[gdscript]
var my_basis = Basis.IDENTITY
var angle = TAU / 2
my_basis = my_basis.rotated(Vector3.UP, angle) # Rotate around the up axis (yaw).
my_basis = my_basis.rotated(Vector3.RIGHT, angle) # Rotate around the right axis (pitch).
my_basis = my_basis.rotated(Vector3.BACK, angle) # Rotate around the back axis (roll).
[/gdscript]
[csharp]
var myBasis = Basis.Identity;
var angle = Mathf.Tau / 2.0f;
myBasis = myBasis.Rotated(Vector3.Up, angle); // Rotate around the up axis (yaw).
myBasis = myBasis.Rotated(Vector3.Right, angle); // Rotate around the right axis (pitch).
myBasis = myBasis.Rotated(Vector3.Back, angle); // Rotate around the back axis (roll).
[/csharp]
[/codeblocks]
</description>
</method>
<method name="scaled" qualifiers="const">
<return type="Basis" />
<param index="0" name="scale" type="Vector3" />
<description>
Returns this basis with each axis's components scaled by the given [param scale]'s components.
The basis matrix's rows are multiplied by [param scale]'s components. This operation is a global scale (relative to the parent).
[codeblocks]
[gdscript]
var my_basis = Basis(
Vector3(1, 1, 1),
Vector3(2, 2, 2),
Vector3(3, 3, 3)
)
my_basis = my_basis.scaled(Vector3(0, 2, -2))
print(my_basis.x) # Prints (0, 2, -2).
print(my_basis.y) # Prints (0, 4, -4).
print(my_basis.z) # Prints (0, 6, -6).
[/gdscript]
[csharp]
var myBasis = new Basis(
new Vector3(1.0f, 1.0f, 1.0f),
new Vector3(2.0f, 2.0f, 2.0f),
new Vector3(3.0f, 3.0f, 3.0f)
);
myBasis = myBasis.Scaled(new Vector3(0.0f, 2.0f, -2.0f));
GD.Print(myBasis.X); // Prints (0, 2, -2).
GD.Print(myBasis.Y); // Prints (0, 4, -4).
GD.Print(myBasis.Z); // Prints (0, 6, -6).
[/csharp]
[/codeblocks]
</description>
</method>
<method name="slerp" qualifiers="const" keywords="interpolate">
<return type="Basis" />
<param index="0" name="to" type="Basis" />
<param index="1" name="weight" type="float" />
<description>
Performs a spherical-linear interpolation with the [param to] basis, given a [param weight]. Both this basis and [param to] should represent a rotation.
[b]Example:[/b] Smoothly rotate a [Node3D] to the target basis over time, with a [Tween].
[codeblock]
var start_basis = Basis.IDENTITY
var target_basis = Basis.IDENTITY.rotated(Vector3.UP, TAU / 2)
func _ready():
create_tween().tween_method(interpolate, 0.0, 1.0, 5.0).set_trans(Tween.TRANS_EXPO)
func interpolate(weight):
basis = start_basis.slerp(target_basis, weight)
[/codeblock]
</description>
</method>
<method name="tdotx" qualifiers="const">
<return type="float" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the transposed dot product between [param with] and the [member x] axis (see [method transposed]).
This is equivalent to [code]basis.x.dot(vector)[/code].
</description>
</method>
<method name="tdoty" qualifiers="const">
<return type="float" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the transposed dot product between [param with] and the [member y] axis (see [method transposed]).
This is equivalent to [code]basis.y.dot(vector)[/code].
</description>
</method>
<m
| |
124951
|
<method name="set_loops">
<return type="Tween" />
<param index="0" name="loops" type="int" default="0" />
<description>
Sets the number of times the tweening sequence will be repeated, i.e. [code]set_loops(2)[/code] will run the animation twice.
Calling this method without arguments will make the [Tween] run infinitely, until either it is killed with [method kill], the [Tween]'s bound node is freed, or all the animated objects have been freed (which makes further animation impossible).
[b]Warning:[/b] Make sure to always add some duration/delay when using infinite loops. To prevent the game freezing, 0-duration looped animations (e.g. a single [CallbackTweener] with no delay) are stopped after a small number of loops, which may produce unexpected results. If a [Tween]'s lifetime depends on some node, always use [method bind_node].
</description>
</method>
<method name="set_parallel">
<return type="Tween" />
<param index="0" name="parallel" type="bool" default="true" />
<description>
If [param parallel] is [code]true[/code], the [Tweener]s appended after this method will by default run simultaneously, as opposed to sequentially.
[b]Note:[/b] Just like with [method parallel], the tweener added right before this method will also be part of the parallel step.
[codeblock]
tween.tween_property(self, "position", Vector2(300, 0), 0.5)
tween.set_parallel()
tween.tween_property(self, "modulate", Color.GREEN, 0.5) # Runs together with the position tweener.
[/codeblock]
</description>
</method>
<method name="set_pause_mode">
<return type="Tween" />
<param index="0" name="mode" type="int" enum="Tween.TweenPauseMode" />
<description>
Determines the behavior of the [Tween] when the [SceneTree] is paused. Check [enum TweenPauseMode] for options.
Default value is [constant TWEEN_PAUSE_BOUND].
</description>
</method>
<method name="set_process_mode">
<return type="Tween" />
<param index="0" name="mode" type="int" enum="Tween.TweenProcessMode" />
<description>
Determines whether the [Tween] should run after process frames (see [method Node._process]) or physics frames (see [method Node._physics_process]).
Default value is [constant TWEEN_PROCESS_IDLE].
</description>
</method>
<method name="set_speed_scale">
<return type="Tween" />
<param index="0" name="speed" type="float" />
<description>
Scales the speed of tweening. This affects all [Tweener]s and their delays.
</description>
</method>
<method name="set_trans">
<return type="Tween" />
<param index="0" name="trans" type="int" enum="Tween.TransitionType" />
<description>
Sets the default transition type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween].
If not specified, the default value is [constant TRANS_LINEAR].
</description>
</method>
<method name="stop">
<return type="void" />
<description>
Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s.
[b]Note:[/b] If a Tween is stopped and not bound to any node, it will exist indefinitely until manually started or invalidated. If you lose a reference to such Tween, you can retrieve it using [method SceneTree.get_processed_tweens].
</description>
</method>
<method name="tween_callback">
<return type="CallbackTweener" />
<param index="0" name="callback" type="Callable" />
<description>
Creates and appends a [CallbackTweener]. This method can be used to call an arbitrary method in any object. Use [method Callable.bind] to bind additional arguments for the call.
[b]Example:[/b] Object that keeps shooting every 1 second:
[codeblocks]
[gdscript]
var tween = get_tree().create_tween().set_loops()
tween.tween_callback(shoot).set_delay(1)
[/gdscript]
[csharp]
Tween tween = GetTree().CreateTween().SetLoops();
tween.TweenCallback(Callable.From(Shoot)).SetDelay(1.0f);
[/csharp]
[/codeblocks]
[b]Example:[/b] Turning a sprite red and then blue, with 2 second delay:
[codeblocks]
[gdscript]
var tween = get_tree().create_tween()
tween.tween_callback($Sprite.set_modulate.bind(Color.RED)).set_delay(2)
tween.tween_callback($Sprite.set_modulate.bind(Color.BLUE)).set_delay(2)
[/gdscript]
[csharp]
Tween tween = GetTree().CreateTween();
Sprite2D sprite = GetNode<Sprite2D>("Sprite");
tween.TweenCallback(Callable.From(() => sprite.Modulate = Colors.Red)).SetDelay(2.0f);
tween.TweenCallback(Callable.From(() => sprite.Modulate = Colors.Blue)).SetDelay(2.0f);
[/csharp]
[/codeblocks]
</description>
</method>
<method name="tween_interval">
<return type="IntervalTweener" />
<param index="0" name="time" type="float" />
<description>
Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative to using the delay in other [Tweener]s, or when there's no animation (in which case the [Tween] acts as a timer). [param time] is the length of the interval, in seconds.
[b]Example:[/b] Creating an interval in code execution:
[codeblocks]
[gdscript]
# ... some code
await create_tween().tween_interval(2).finished
# ... more code
[/gdscript]
[csharp]
// ... some code
await ToSignal(CreateTween().TweenInterval(2.0f), Tween.SignalName.Finished);
// ... more code
[/csharp]
[/codeblocks]
[b]Example:[/b] Creating an object that moves back and forth and jumps every few seconds:
[codeblocks]
[gdscript]
var tween = create_tween().set_loops()
tween.tween_property($Sprite, "position:x", 200.0, 1).as_relative()
tween.tween_callback(jump)
tween.tween_interval(2)
tween.tween_property($Sprite, "position:x", -200.0, 1).as_relative()
tween.tween_callback(jump)
tween.tween_interval(2)
[/gdscript]
[csharp]
Tween tween = CreateTween().SetLoops();
tween.TweenProperty(GetNode("Sprite"), "position:x", 200.0f, 1.0f).AsRelative();
tween.TweenCallback(Callable.From(Jump));
tween.TweenInterval(2.0f);
tween.TweenProperty(GetNode("Sprite"), "position:x", -200.0f, 1.0f).AsRelative();
tween.TweenCallback(Callable.From(Jump));
tween.TweenInterval(2.0f);
[/csharp]
[/codeblocks]
</description>
</method>
| |
124952
|
<method name="tween_method">
<return type="MethodTweener" />
<param index="0" name="method" type="Callable" />
<param index="1" name="from" type="Variant" />
<param index="2" name="to" type="Variant" />
<param index="3" name="duration" type="float" />
<description>
Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [param from] and [param to] over the time specified by [param duration], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening.
[b]Example:[/b] Making a 3D object look from one point to another point:
[codeblocks]
[gdscript]
var tween = create_tween()
tween.tween_method(look_at.bind(Vector3.UP), Vector3(-1, 0, -1), Vector3(1, 0, -1), 1) # The look_at() method takes up vector as second argument.
[/gdscript]
[csharp]
Tween tween = CreateTween();
tween.TweenMethod(Callable.From((Vector3 target) => LookAt(target, Vector3.Up)), new Vector3(-1.0f, 0.0f, -1.0f), new Vector3(1.0f, 0.0f, -1.0f), 1.0f); // Use lambdas to bind additional arguments for the call.
[/csharp]
[/codeblocks]
[b]Example:[/b] Setting the text of a [Label], using an intermediate method and after a delay:
[codeblocks]
[gdscript]
func _ready():
var tween = create_tween()
tween.tween_method(set_label_text, 0, 10, 1).set_delay(1)
func set_label_text(value: int):
$Label.text = "Counting " + str(value)
[/gdscript]
[csharp]
public override void _Ready()
{
base._Ready();
Tween tween = CreateTween();
tween.TweenMethod(Callable.From<int>(SetLabelText), 0.0f, 10.0f, 1.0f).SetDelay(1.0f);
}
private void SetLabelText(int value)
{
GetNode<Label>("Label").Text = $"Counting {value}";
}
[/csharp]
[/codeblocks]
</description>
</method>
<method name="tween_property">
<return type="PropertyTweener" />
<param index="0" name="object" type="Object" />
<param index="1" name="property" type="NodePath" />
<param index="2" name="final_val" type="Variant" />
<param index="3" name="duration" type="float" />
<description>
Creates and appends a [PropertyTweener]. This method tweens a [param property] of an [param object] between an initial value and [param final_val] in a span of time equal to [param duration], in seconds. The initial value by default is the property's value at the time the tweening of the [PropertyTweener] starts.
[codeblocks]
[gdscript]
var tween = create_tween()
tween.tween_property($Sprite, "position", Vector2(100, 200), 1)
tween.tween_property($Sprite, "position", Vector2(200, 300), 1)
[/gdscript]
[csharp]
Tween tween = CreateTween();
tween.TweenProperty(GetNode("Sprite"), "position", new Vector2(100.0f, 200.0f), 1.0f);
tween.TweenProperty(GetNode("Sprite"), "position", new Vector2(200.0f, 300.0f), 1.0f);
[/csharp]
[/codeblocks]
will move the sprite to position (100, 200) and then to (200, 300). If you use [method PropertyTweener.from] or [method PropertyTweener.from_current], the starting position will be overwritten by the given value instead. See other methods in [PropertyTweener] to see how the tweening can be tweaked further.
[b]Note:[/b] You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (eg. [code]position:x[/code]), where it would only apply to that particular component.
[b]Example:[/b] Moving an object twice from the same position, with different transition types:
[codeblocks]
[gdscript]
var tween = create_tween()
tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().set_trans(Tween.TRANS_SINE)
tween.tween_property($Sprite, "position", Vector2.RIGHT * 300, 1).as_relative().from_current().set_trans(Tween.TRANS_EXPO)
[/gdscript]
[csharp]
Tween tween = CreateTween();
tween.TweenProperty(GetNode("Sprite"), "position", Vector2.Right * 300.0f, 1.0f).AsRelative().SetTrans(Tween.TransitionType.Sine);
tween.TweenProperty(GetNode("Sprite"), "position", Vector2.Right * 300.0f, 1.0f).AsRelative().FromCurrent().SetTrans(Tween.TransitionType.Expo);
[/csharp]
[/codeblocks]
</description>
</method>
</methods>
<signals>
<signal name="finished">
<description>
Emitted when the [Tween] has finished all tweening. Never emitted when the [Tween] is set to infinite looping (see [method set_loops]).
</description>
</signal>
<signal name="loop_finished">
<param index="0" name="loop_count" type="int" />
<description>
Emitted when a full loop is complete (see [method set_loops]), providing the loop index. This signal is not emitted after the final loop, use [signal finished] instead for this case.
</description>
</signal>
<signal name="step_finished">
<param index="0" name="idx" type="int" />
<description>
Emitted when one step of the [Tween] is complete, providing the step index. One step is either a single [Tweener] or a group of [Tweener]s running in parallel.
</description>
</signal>
</signals>
| |
124966
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SubViewport" inherits="Viewport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
An interface to a game world that doesn't create a window or draw to the screen directly.
</brief_description>
<description>
[SubViewport] Isolates a rectangular region of a scene to be displayed independently. This can be used, for example, to display UI in 3D space.
[b]Note:[/b] [SubViewport] is a [Viewport] that isn't a [Window], i.e. it doesn't draw anything by itself. To display anything, [SubViewport] must have a non-zero size and be either put inside a [SubViewportContainer] or assigned to a [ViewportTexture].
</description>
<tutorials>
<link title="Using Viewports">$DOCS_URL/tutorials/rendering/viewports.html</link>
<link title="Viewport and canvas transforms">$DOCS_URL/tutorials/2d/2d_transforms.html</link>
<link title="GUI in 3D Viewport Demo">https://godotengine.org/asset-library/asset/2807</link>
<link title="3D in 2D Viewport Demo">https://godotengine.org/asset-library/asset/2804</link>
<link title="2D in 3D Viewport Demo">https://godotengine.org/asset-library/asset/2803</link>
<link title="Screen Capture Demo">https://godotengine.org/asset-library/asset/2808</link>
<link title="Dynamic Split Screen Demo">https://godotengine.org/asset-library/asset/2806</link>
<link title="3D Resolution Scaling Demo">https://godotengine.org/asset-library/asset/2805</link>
</tutorials>
<members>
<member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="SubViewport.ClearMode" default="0">
The clear mode when the sub-viewport is used as a render target.
[b]Note:[/b] This property is intended for 2D usage.
</member>
<member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="SubViewport.UpdateMode" default="2">
The update mode when the sub-viewport is used as a render target.
</member>
<member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(512, 512)">
The width and height of the sub-viewport. Must be set to a value greater than or equal to 2 pixels on both dimensions. Otherwise, nothing will be displayed.
[b]Note:[/b] If the parent node is a [SubViewportContainer] and its [member SubViewportContainer.stretch] is [code]true[/code], the viewport size cannot be changed manually.
</member>
<member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i(0, 0)">
The 2D size override of the sub-viewport. If either the width or height is [code]0[/code], the override is disabled.
</member>
<member name="size_2d_override_stretch" type="bool" setter="set_size_2d_override_stretch" getter="is_size_2d_override_stretch_enabled" default="false">
If [code]true[/code], the 2D size override affects stretch as well.
</member>
</members>
<constants>
<constant name="CLEAR_MODE_ALWAYS" value="0" enum="ClearMode">
Always clear the render target before drawing.
</constant>
<constant name="CLEAR_MODE_NEVER" value="1" enum="ClearMode">
Never clear the render target.
</constant>
<constant name="CLEAR_MODE_ONCE" value="2" enum="ClearMode">
Clear the render target on the next frame, then switch to [constant CLEAR_MODE_NEVER].
</constant>
<constant name="UPDATE_DISABLED" value="0" enum="UpdateMode">
Do not update the render target.
</constant>
<constant name="UPDATE_ONCE" value="1" enum="UpdateMode">
Update the render target once, then switch to [constant UPDATE_DISABLED].
</constant>
<constant name="UPDATE_WHEN_VISIBLE" value="2" enum="UpdateMode">
Update the render target only when it is visible. This is the default value.
</constant>
<constant name="UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="UpdateMode">
Update the render target only when its parent is visible.
</constant>
<constant name="UPDATE_ALWAYS" value="4" enum="UpdateMode">
Always update the render target.
</constant>
</constants>
</class>
| |
125022
|
<member name="transparency" type="int" setter="set_transparency" getter="get_transparency" enum="BaseMaterial3D.Transparency" default="0">
The material's transparency mode. Some transparency modes will disable shadow casting. Any transparency mode other than [constant TRANSPARENCY_DISABLED] has a greater performance impact compared to opaque rendering. See also [member blend_mode].
</member>
<member name="use_particle_trails" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], enables parts of the shader required for [GPUParticles3D] trails to function. This also requires using a mesh with appropriate skinning, such as [RibbonTrailMesh] or [TubeTrailMesh]. Enabling this feature outside of materials used in [GPUParticles3D] meshes will break material rendering.
</member>
<member name="use_point_size" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], render point size can be changed.
[b]Note:[/b] This is only effective for objects whose geometry is point-based rather than triangle-based. See also [member point_size].
</member>
<member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" default="Vector3(0, 0, 0)">
How much to offset the [code]UV[/code] coordinates. This amount will be added to [code]UV[/code] in the vertex function. This can be used to offset a texture. The Z component is used when [member uv1_triplanar] is enabled, but it is not used anywhere else.
</member>
<member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" default="Vector3(1, 1, 1)">
How much to scale the [code]UV[/code] coordinates. This is multiplied by [code]UV[/code] in the vertex function. The Z component is used when [member uv1_triplanar] is enabled, but it is not used anywhere else.
</member>
<member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], instead of using [code]UV[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing.
</member>
<member name="uv1_triplanar_sharpness" type="float" setter="set_uv1_triplanar_blend_sharpness" getter="get_uv1_triplanar_blend_sharpness" default="1.0">
A lower number blends the texture more softly while a higher number blends the texture more sharply.
[b]Note:[/b] [member uv1_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh.
</member>
<member name="uv1_world_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], triplanar mapping for [code]UV[/code] is calculated in world space rather than object local space. See also [member uv1_triplanar].
</member>
<member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3(0, 0, 0)">
How much to offset the [code]UV2[/code] coordinates. This amount will be added to [code]UV2[/code] in the vertex function. This can be used to offset a texture. The Z component is used when [member uv2_triplanar] is enabled, but it is not used anywhere else.
</member>
<member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" default="Vector3(1, 1, 1)">
How much to scale the [code]UV2[/code] coordinates. This is multiplied by [code]UV2[/code] in the vertex function. The Z component is used when [member uv2_triplanar] is enabled, but it is not used anywhere else.
</member>
<member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], instead of using [code]UV2[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing.
</member>
<member name="uv2_triplanar_sharpness" type="float" setter="set_uv2_triplanar_blend_sharpness" getter="get_uv2_triplanar_blend_sharpness" default="1.0">
A lower number blends the texture more softly while a higher number blends the texture more sharply.
[b]Note:[/b] [member uv2_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh.
</member>
<member name="uv2_world_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], triplanar mapping for [code]UV2[/code] is calculated in world space rather than object local space. See also [member uv2_triplanar].
</member>
<member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], vertex colors are considered to be stored in sRGB color space and are converted to linear color space during rendering. If [code]false[/code], vertex colors are considered to be stored in linear color space and are rendered as-is. See also [member albedo_texture_force_srgb].
[b]Note:[/b] Only effective when using the Forward+ and Mobile rendering methods, not Compatibility.
</member>
<member name="vertex_color_use_as_albedo" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the vertex color is used as albedo color.
</member>
</members>
| |
125068
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorImportPlugin" inherits="ResourceImporter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Registers a custom resource importer in the editor. Use the class to parse any file and import it as a new resource type.
</brief_description>
<description>
[EditorImportPlugin]s provide a way to extend the editor's resource import functionality. Use them to import resources from custom files or to provide alternatives to the editor's existing importers.
EditorImportPlugins work by associating with specific file extensions and a resource type. See [method _get_recognized_extensions] and [method _get_resource_type]. They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the [code].godot/imported[/code] directory (see [member ProjectSettings.application/config/use_hidden_project_data_directory]).
Below is an example EditorImportPlugin that imports a [Mesh] from a file with the extension ".special" or ".spec":
[codeblocks]
[gdscript]
@tool
extends EditorImportPlugin
func _get_importer_name():
return "my.special.plugin"
func _get_visible_name():
return "Special Mesh"
func _get_recognized_extensions():
return ["special", "spec"]
func _get_save_extension():
return "mesh"
func _get_resource_type():
return "Mesh"
func _get_preset_count():
return 1
func _get_preset_name(preset_index):
return "Default"
func _get_import_options(path, preset_index):
return [{"name": "my_option", "default_value": false}]
func _import(source_file, save_path, options, platform_variants, gen_files):
var file = FileAccess.open(source_file, FileAccess.READ)
if file == null:
return FAILED
var mesh = ArrayMesh.new()
# Fill the Mesh with data read in "file", left as an exercise to the reader.
var filename = save_path + "." + _get_save_extension()
return ResourceSaver.save(mesh, filename)
[/gdscript]
[csharp]
using Godot;
public partial class MySpecialPlugin : EditorImportPlugin
{
public override string _GetImporterName()
{
return "my.special.plugin";
}
public override string _GetVisibleName()
{
return "Special Mesh";
}
public override string[] _GetRecognizedExtensions()
{
return new string[] { "special", "spec" };
}
public override string _GetSaveExtension()
{
return "mesh";
}
public override string _GetResourceType()
{
return "Mesh";
}
public override int _GetPresetCount()
{
return 1;
}
public override string _GetPresetName(int presetIndex)
{
return "Default";
}
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetImportOptions(string path, int presetIndex)
{
return new Godot.Collections.Array<Godot.Collections.Dictionary>
{
new Godot.Collections.Dictionary
{
{ "name", "myOption" },
{ "default_value", false },
}
};
}
public override Error _Import(string sourceFile, string savePath, Godot.Collections.Dictionary options, Godot.Collections.Array<string> platformVariants, Godot.Collections.Array<string> genFiles)
{
using var file = FileAccess.Open(sourceFile, FileAccess.ModeFlags.Read);
if (file.GetError() != Error.Ok)
{
return Error.Failed;
}
var mesh = new ArrayMesh();
// Fill the Mesh with data read in "file", left as an exercise to the reader.
string filename = $"{savePath}.{_GetSaveExtension()}";
return ResourceSaver.Save(mesh, filename);
}
}
[/csharp]
[/codeblocks]
To use [EditorImportPlugin], register it using the [method EditorPlugin.add_import_plugin] method first.
</description>
<tutorials>
<link title="Import plugins">$DOCS_URL/tutorials/plugins/editor/import_plugins.html</link>
</tutorials>
| |
125090
|
<brief_description>
Settings for a single tile in a [TileSet].
</brief_description>
<description>
[TileData] object represents a single tile in a [TileSet]. It is usually edited using the tileset editor, but it can be modified at runtime using [method TileMap._tile_data_runtime_update].
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_collision_polygon">
<return type="void" />
<param index="0" name="layer_id" type="int" />
<description>
Adds a collision polygon to the tile on the given TileSet physics layer.
</description>
</method>
<method name="add_occluder_polygon">
<return type="void" />
<param index="0" name="layer_id" type="int" />
<description>
Adds an occlusion polygon to the tile on the TileSet occlusion layer with index [param layer_id].
</description>
</method>
<method name="get_collision_polygon_one_way_margin" qualifiers="const">
<return type="float" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns the one-way margin (for one-way platforms) of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_collision_polygon_points" qualifiers="const">
<return type="PackedVector2Array" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns the points of the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_collision_polygons_count" qualifiers="const">
<return type="int" />
<param index="0" name="layer_id" type="int" />
<description>
Returns how many polygons the tile has for TileSet physics layer with index [param layer_id].
</description>
</method>
<method name="get_constant_angular_velocity" qualifiers="const">
<return type="float" />
<param index="0" name="layer_id" type="int" />
<description>
Returns the constant angular velocity applied to objects colliding with this tile.
</description>
</method>
<method name="get_constant_linear_velocity" qualifiers="const">
<return type="Vector2" />
<param index="0" name="layer_id" type="int" />
<description>
Returns the constant linear velocity applied to objects colliding with this tile.
</description>
</method>
<method name="get_custom_data" qualifiers="const">
<return type="Variant" />
<param index="0" name="layer_name" type="String" />
<description>
Returns the custom data value for custom data layer named [param layer_name].
</description>
</method>
<method name="get_custom_data_by_layer_id" qualifiers="const">
<return type="Variant" />
<param index="0" name="layer_id" type="int" />
<description>
Returns the custom data value for custom data layer with index [param layer_id].
</description>
</method>
<method name="get_navigation_polygon" qualifiers="const">
<return type="NavigationPolygon" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="flip_h" type="bool" default="false" />
<param index="2" name="flip_v" type="bool" default="false" />
<param index="3" name="transpose" type="bool" default="false" />
<description>
Returns the navigation polygon of the tile for the TileSet navigation layer with index [param layer_id].
[param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon.
</description>
</method>
<method name="get_occluder" qualifiers="const" deprecated="Use [method get_occluder_polygon] instead.">
<return type="OccluderPolygon2D" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="flip_h" type="bool" default="false" />
<param index="2" name="flip_v" type="bool" default="false" />
<param index="3" name="transpose" type="bool" default="false" />
<description>
Returns the occluder polygon of the tile for the TileSet occlusion layer with index [param layer_id].
[param flip_h], [param flip_v], and [param transpose] allow transforming the returned polygon.
</description>
</method>
<method name="get_occluder_polygon" qualifiers="const">
<return type="OccluderPolygon2D" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<param index="2" name="flip_h" type="bool" default="false" />
<param index="3" name="flip_v" type="bool" default="false" />
<param index="4" name="transpose" type="bool" default="false" />
<description>
Returns the occluder polygon at index [param polygon_index] from the TileSet occlusion layer with index [param layer_id].
The [param flip_h], [param flip_v], and [param transpose] parameters can be [code]true[/code] to transform the returned polygon.
</description>
</method>
<method name="get_occluder_polygons_count" qualifiers="const">
<return type="int" />
<param index="0" name="layer_id" type="int" />
<description>
Returns the number of occluder polygons of the tile in the TileSet occlusion layer with index [param layer_id].
</description>
</method>
<method name="get_terrain_peering_bit" qualifiers="const">
<return type="int" />
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<description>
Returns the tile's terrain bit for the given [param peering_bit] direction. To check that a direction is valid, use [method is_valid_terrain_peering_bit].
</description>
</method>
<method name="is_collision_polygon_one_way" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Returns whether one-way collisions are enabled for the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
</description>
</method>
<method name="is_valid_terrain_peering_bit" qualifiers="const">
<return type="bool" />
<param index="0" name="peering_bit" type="int" enum="TileSet.CellNeighbor" />
<description>
Returns whether the given [param peering_bit] direction is valid for this tile.
</description>
</method>
<method name="remove_collision_polygon">
<return type="void" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Removes the polygon at index [param polygon_index] for TileSet physics layer with index [param layer_id].
</description>
</method>
<method name="remove_occluder_polygon">
<return type="void" />
<param index="0" name="layer_id" type="int" />
<param index="1" name="polygon_index" type="int" />
<description>
Removes the polygon at index [param polygon_index] for TileSet occlusion layer with index [param layer_id].
</description>
</method>
| |
125127
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ResourceLoader" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A singleton for loading resource files.
</brief_description>
<description>
A singleton used to load resource files from the filesystem.
It uses the many [ResourceFormatLoader] classes registered in the engine (either built-in or from a plugin) to load files into memory and convert them to a format that can be used by the engine.
[b]Note:[/b] You have to import the files into the engine first to load them using [method load]. If you want to load [Image]s at run-time, you may use [method Image.load]. If you want to import audio files, you can use the snippet described in [member AudioStreamMP3.data].
</description>
<tutorials>
<link title="Operating System Testing Demo">https://godotengine.org/asset-library/asset/2789</link>
</tutorials>
| |
125128
|
<methods>
<method name="add_resource_format_loader">
<return type="void" />
<param index="0" name="format_loader" type="ResourceFormatLoader" />
<param index="1" name="at_front" type="bool" default="false" />
<description>
Registers a new [ResourceFormatLoader]. The ResourceLoader will use the ResourceFormatLoader as described in [method load].
This method is performed implicitly for ResourceFormatLoaders written in GDScript (see [ResourceFormatLoader] for more information).
</description>
</method>
<method name="exists">
<return type="bool" />
<param index="0" name="path" type="String" />
<param index="1" name="type_hint" type="String" default="""" />
<description>
Returns whether a recognized resource exists for the given [param path].
An optional [param type_hint] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader]. Anything that inherits from [Resource] can be used as a type hint, for example [Image].
[b]Note:[/b] If you use [method Resource.take_over_path], this method will return [code]true[/code] for the taken path even if the resource wasn't saved (i.e. exists only in resource cache).
</description>
</method>
<method name="get_cached_ref">
<return type="Resource" />
<param index="0" name="path" type="String" />
<description>
Returns the cached resource reference for the given [param path].
[b]Note:[/b] If the resource is not cached, the returned [Resource] will be invalid.
</description>
</method>
<method name="get_dependencies">
<return type="PackedStringArray" />
<param index="0" name="path" type="String" />
<description>
Returns the dependencies for the resource at the given [param path].
[b]Note:[/b] The dependencies are returned with slices separated by [code]::[/code]. You can use [method String.get_slice] to get their components.
[codeblock]
for dep in ResourceLoader.get_dependencies(path):
print(dep.get_slice("::", 0)) # Prints UID.
print(dep.get_slice("::", 2)) # Prints path.
[/codeblock]
</description>
</method>
<method name="get_recognized_extensions_for_type">
<return type="PackedStringArray" />
<param index="0" name="type" type="String" />
<description>
Returns the list of recognized extensions for a resource type.
</description>
</method>
<method name="get_resource_uid">
<return type="int" />
<param index="0" name="path" type="String" />
<description>
Returns the ID associated with a given resource path, or [code]-1[/code] when no such ID exists.
</description>
</method>
<method name="has_cached">
<return type="bool" />
<param index="0" name="path" type="String" />
<description>
Returns whether a cached resource is available for the given [param path].
Once a resource has been loaded by the engine, it is cached in memory for faster access, and future calls to the [method load] method will use the cached version. The cached resource can be overridden by using [method Resource.take_over_path] on a new resource for that same path.
</description>
</method>
<method name="load">
<return type="Resource" />
<param index="0" name="path" type="String" />
<param index="1" name="type_hint" type="String" default="""" />
<param index="2" name="cache_mode" type="int" enum="ResourceLoader.CacheMode" default="1" />
<description>
Loads a resource at the given [param path], caching the result for further access.
The registered [ResourceFormatLoader]s are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
An optional [param type_hint] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader]. Anything that inherits from [Resource] can be used as a type hint, for example [Image].
The [param cache_mode] property defines whether and how the cache should be used or updated when loading the resource. See [enum CacheMode] for details.
Returns an empty resource if no [ResourceFormatLoader] could handle the file, and prints an error if no file is found at the specified path.
GDScript has a simplified [method @GDScript.load] built-in method which can be used in most situations, leaving the use of [ResourceLoader] for more advanced scenarios.
[b]Note:[/b] If [member ProjectSettings.editor/export/convert_text_resources_to_binary] is [code]true[/code], [method @GDScript.load] will not be able to read converted files in an exported project. If you rely on run-time loading of files present within the PCK, set [member ProjectSettings.editor/export/convert_text_resources_to_binary] to [code]false[/code].
[b]Note:[/b] Relative paths will be prefixed with [code]"res://"[/code] before loading, to avoid unexpected results make sure your paths are absolute.
</description>
</method>
<method name="load_threaded_get">
<return type="Resource" />
<param index="0" name="path" type="String" />
<description>
Returns the resource loaded by [method load_threaded_request].
If this is called before the loading thread is done (i.e. [method load_threaded_get_status] is not [constant THREAD_LOAD_LOADED]), the calling thread will be blocked until the resource has finished loading. However, it's recommended to use [method load_threaded_get_status] to known when the load has actually completed.
</description>
</method>
<method name="load_threaded_get_status">
<return type="int" enum="ResourceLoader.ThreadLoadStatus" />
<param index="0" name="path" type="String" />
<param index="1" name="progress" type="Array" default="[]" />
<description>
Returns the status of a threaded loading operation started with [method load_threaded_request] for the resource at [param path]. See [enum ThreadLoadStatus] for possible return values.
An array variable can optionally be passed via [param progress], and will return a one-element array containing the percentage of completion of the threaded loading.
[b]Note:[/b] The recommended way of using this method is to call it during different frames (e.g., in [method Node._process], instead of a loop).
</description>
</method>
<method name="load_threaded_request">
<return type="int" enum="Error" />
<param index="0" name="path" type="String" />
<param index="1" name="type_hint" type="String" default="""" />
<param index="2" name="use_sub_threads" type="bool" default="false" />
<param index="3" name="cache_mode" type="int" enum="ResourceLoader.CacheMode" default="1" />
<description>
Loads the resource using threads. If [param use_sub_threads] is [code]true[/code], multiple threads will be used to load the resource, which makes loading faster, but may affect the main thread (and thus cause game slowdowns).
The [param cache_mode] property defines whether and how the cache should be used or updated when loading the resource. See [enum CacheMode] for details.
</description>
</method>
<method name="remove_resource_format_loader">
<return type="void" />
<param index="0" name="format_loader" type="ResourceFormatLoader" />
<description>
Unregisters the given [ResourceFormatLoader].
</description>
</method>
<method name="set_abort_on_missing_resources">
<return type="void" />
<param index="0" name="abort" type="bool" />
<description>
Changes the behavior on missing sub-resources. The default behavior is to abort loading.
</description>
</method>
</methods>
| |
125129
|
<constants>
<constant name="THREAD_LOAD_INVALID_RESOURCE" value="0" enum="ThreadLoadStatus">
The resource is invalid, or has not been loaded with [method load_threaded_request].
</constant>
<constant name="THREAD_LOAD_IN_PROGRESS" value="1" enum="ThreadLoadStatus">
The resource is still being loaded.
</constant>
<constant name="THREAD_LOAD_FAILED" value="2" enum="ThreadLoadStatus">
Some error occurred during loading and it failed.
</constant>
<constant name="THREAD_LOAD_LOADED" value="3" enum="ThreadLoadStatus">
The resource was loaded successfully and can be accessed via [method load_threaded_get].
</constant>
<constant name="CACHE_MODE_IGNORE" value="0" enum="CacheMode">
Neither the main resource (the one requested to be loaded) nor any of its subresources are retrieved from cache nor stored into it. Dependencies (external resources) are loaded with [constant CACHE_MODE_REUSE].
</constant>
<constant name="CACHE_MODE_REUSE" value="1" enum="CacheMode">
The main resource (the one requested to be loaded), its subresources, and its dependencies (external resources) are retrieved from cache if present, instead of loaded. Those not cached are loaded and then stored into the cache. The same rules are propagated recursively down the tree of dependencies (external resources).
</constant>
<constant name="CACHE_MODE_REPLACE" value="2" enum="CacheMode">
Like [constant CACHE_MODE_REUSE], but the cache is checked for the main resource (the one requested to be loaded) as well as for each of its subresources. Those already in the cache, as long as the loaded and cached types match, have their data refreshed from storage into the already existing instances. Otherwise, they are recreated as completely new objects.
</constant>
<constant name="CACHE_MODE_IGNORE_DEEP" value="3" enum="CacheMode">
Like [constant CACHE_MODE_IGNORE], but propagated recursively down the tree of dependencies (external resources).
</constant>
<constant name="CACHE_MODE_REPLACE_DEEP" value="4" enum="CacheMode">
Like [constant CACHE_MODE_REPLACE], but propagated recursively down the tree of dependencies (external resources).
</constant>
</constants>
</class>
| |
125170
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Resource" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Base class for serializable objects.
</brief_description>
<description>
Resource is the base class for all Godot-specific resource types, serving primarily as data containers. Since they inherit from [RefCounted], resources are reference-counted and freed when no longer in use. They can also be nested within other resources, and saved on disk. [PackedScene], one of the most common [Object]s in a Godot project, is also a resource, uniquely capable of storing and instantiating the [Node]s it contains as many times as desired.
In GDScript, resources can loaded from disk by their [member resource_path] using [method @GDScript.load] or [method @GDScript.preload].
The engine keeps a global cache of all loaded resources, referenced by paths (see [method ResourceLoader.has_cached]). A resource will be cached when loaded for the first time and removed from cache once all references are released. When a resource is cached, subsequent loads using its path will return the cached reference.
[b]Note:[/b] In C#, resources will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free resources that are no longer in use. This means that unused resources will remain in memory for a while before being removed.
</description>
<tutorials>
<link title="Resources">$DOCS_URL/tutorials/scripting/resources.html</link>
<link title="When and how to avoid using nodes for everything">$DOCS_URL/tutorials/best_practices/node_alternatives.html</link>
</tutorials>
| |
125172
|
<members>
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" default="false">
If [code]true[/code], the resource is duplicated for each instance of all scenes using it. At run-time, the resource can be modified in one scene without affecting other instances (see [method PackedScene.instantiate]).
[b]Note:[/b] Changing this property at run-time has no effect on already created duplicate resources.
</member>
<member name="resource_name" type="String" setter="set_name" getter="get_name" default="""">
An optional name for this resource. When defined, its value is displayed to represent the resource in the Inspector dock. For built-in scripts, the name is displayed as part of the tab name in the script editor.
[b]Note:[/b] Some resource formats do not support resource names. You can still set the name in the editor or via code, but it will be lost when the resource is reloaded. For example, only built-in scripts can have a resource name, while scripts stored in separate files cannot.
</member>
<member name="resource_path" type="String" setter="set_path" getter="get_path" default="""">
The unique path to this resource. If it has been saved to disk, the value will be its filepath. If the resource is exclusively contained within a scene, the value will be the [PackedScene]'s filepath, followed by a unique identifier.
[b]Note:[/b] Setting this property manually may fail if a resource with the same path has already been previously loaded. If necessary, use [method take_over_path].
</member>
<member name="resource_scene_unique_id" type="String" setter="set_scene_unique_id" getter="get_scene_unique_id">
An unique identifier relative to the this resource's scene. If left empty, the ID is automatically generated when this resource is saved inside a [PackedScene]. If the resource is not inside a scene, this property is empty by default.
[b]Note:[/b] When the [PackedScene] is saved, if multiple resources in the same scene use the same ID, only the earliest resource in the scene hierarchy keeps the original ID. The other resources are assigned new IDs from [method generate_scene_unique_id].
[b]Note:[/b] Setting this property does not emit the [signal changed] signal.
[b]Warning:[/b] When setting, the ID must only consist of letters, numbers, and underscores. Otherwise, it will fail and default to a randomly generated ID.
</member>
</members>
<signals>
<signal name="changed">
<description>
Emitted when the resource changes, usually when one of its properties is modified. See also [method emit_changed].
[b]Note:[/b] This signal is not emitted automatically for properties of custom resources. If necessary, a setter needs to be created to emit the signal.
</description>
</signal>
<signal name="setup_local_to_scene_requested" deprecated="This signal is only emitted when the resource is created. Override [method _setup_local_to_scene] instead.">
<description>
Emitted by a newly duplicated resource with [member resource_local_to_scene] set to [code]true[/code].
</description>
</signal>
</signals>
</class>
| |
125178
|
method name="_has_main_screen" qualifiers="virtual const">
<return type="bool" />
<description>
Returns [code]true[/code] if this is a main screen editor plugin (it goes in the workspace selector together with [b]2D[/b], [b]3D[/b], [b]Script[/b] and [b]AssetLib[/b]).
When the plugin's workspace is selected, other main screen plugins will be hidden, but your plugin will not appear automatically. It needs to be added as a child of [method EditorInterface.get_editor_main_screen] and made visible inside [method _make_visible].
Use [method _get_plugin_name] and [method _get_plugin_icon] to customize the plugin button's appearance.
[codeblock]
var plugin_control
func _enter_tree():
plugin_control = preload("my_plugin_control.tscn").instantiate()
EditorInterface.get_editor_main_screen().add_child(plugin_control)
plugin_control.hide()
func _has_main_screen():
return true
func _make_visible(visible):
plugin_control.visible = visible
func _get_plugin_name():
return "My Super Cool Plugin 3000"
func _get_plugin_icon():
return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")
[/codeblock]
</description>
</method>
<method name="_make_visible" qualifiers="virtual">
<return type="void" />
<param index="0" name="visible" type="bool" />
<description>
This function will be called when the editor is requested to become visible. It is used for plugins that edit a specific object type.
Remember that you have to manage the visibility of all your editor controls manually.
</description>
</method>
<method name="_save_external_data" qualifiers="virtual">
<return type="void" />
<description>
This method is called after the editor saves the project or when it's closed. It asks the plugin to save edited external scenes/resources.
</description>
</method>
<method name="_set_state" qualifiers="virtual">
<return type="void" />
<param index="0" name="state" type="Dictionary" />
<description>
Restore the state saved by [method _get_state]. This method is called when the current scene tab is changed in the editor.
[b]Note:[/b] Your plugin must implement [method _get_plugin_name], otherwise it will not be recognized and this method will not be called.
[codeblock]
func _set_state(data):
zoom = data.get("zoom", 1.0)
preferred_color = data.get("my_color", Color.WHITE)
[/codeblock]
</description>
</method>
<method name="_set_window_layout" qualifiers="virtual">
<return type="void" />
<param index="0" name="configuration" type="ConfigFile" />
<description>
Restore the plugin GUI layout and data saved by [method _get_window_layout]. This method is called for every plugin on editor startup. Use the provided [param configuration] file to read your saved data.
[codeblock]
func _set_window_layout(configuration):
$Window.position = configuration.get_value("MyPlugin", "window_position", Vector2())
$Icon.modulate = configuration.get_value("MyPlugin", "icon_color", Color.WHITE)
[/codeblock]
</description>
</method>
<method name="add_autoload_singleton">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="path" type="String" />
<description>
Adds a script at [param path] to the Autoload list as [param name].
</description>
</method>
<method name="add_context_menu_plugin">
<return type="void" />
<param index="0" name="slot" type="int" enum="EditorContextMenuPlugin.ContextMenuSlot" />
<param index="1" name="plugin" type="EditorContextMenuPlugin" />
<description>
Adds a plugin to the context menu. [param slot] is the context menu where the plugin will be added.
See [enum EditorContextMenuPlugin.ContextMenuSlot] for available context menus. A plugin instance can belong only to a single context menu slot.
</description>
</method>
<method name="add_control_to_bottom_panel">
<return type="Button" />
<param index="0" name="control" type="Control" />
<param index="1" name="title" type="String" />
<param index="2" name="shortcut" type="Shortcut" default="null" />
<description>
Adds a control to the bottom panel (together with Output, Debug, Animation, etc). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_bottom_panel] and free it with [method Node.queue_free].
Optionally, you can specify a shortcut parameter. When pressed, this shortcut will toggle the bottom panel's visibility. See the default editor bottom panel shortcuts in the Editor Settings for inspiration. Per convention, they all use [kbd]Alt[/kbd] modifier.
</description>
</method>
<method name="add_control_to_container">
<return type="void" />
<param index="0" name="container" type="int" enum="EditorPlugin.CustomControlContainer" />
<param index="1" name="control" type="Control" />
<description>
Adds a custom control to a container (see [enum CustomControlContainer]). There are many locations where custom controls can be added in the editor UI.
Please remember that you have to manage the visibility of your custom controls yourself (and likely hide it after adding it).
When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_container] and free it with [method Node.queue_free].
</description>
</method>
<method name="add_control_to_dock">
<return type="void" />
<param index="0" name="slot" type="int" enum="EditorPlugin.DockSlot" />
<param index="1" name="control" type="Control" />
<param index="2" name="shortcut" type="Shortcut" default="null" />
<description>
Adds the control to a specific dock slot (see [enum DockSlot] for options).
If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions.
When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_docks] and free it with [method Node.queue_free].
Optionally, you can specify a shortcut parameter. When pressed, this shortcut will toggle the dock's visibility once it's moved to the bottom panel (this shortcut does not affect the dock otherwise). See the default editor bottom panel shortcuts in the Editor Settings for inspiration. Per convention, they all use [kbd]Alt[/kbd] modifier.
</description>
</method>
<method name="add_custom_type">
<return type="void" />
<param index="0" name="type" type="String" />
<param index="1" name="base" type="String" />
<param index="2" name="script" type="Script" />
<param index="3" name="icon" type="Texture2D" />
<description>
Adds a custom type, which will appear in the list of nodes or resources.
When a given node or resource is selected, the base type will be instantiated (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object.
[b]Note:[/b] The base type is the base engine class which this type's class hierarchy inherits, not any custom type parent classes.
You can use the virtual method [method _handles] to check if your custom object is being edited by checking the script or using the [code]is[/code] keyword.
During run-time, this will be a simple object with a script so this function does not need to be called then.
[b]Note:[/b] Custom types added this way are not true classes. They are just a helper to create a node with specific script.
</description>
</method>
<
| |
125179
|
method name="add_debugger_plugin">
<return type="void" />
<param index="0" name="script" type="EditorDebuggerPlugin" />
<description>
Adds a [Script] as debugger plugin to the Debugger. The script must extend [EditorDebuggerPlugin].
</description>
</method>
<method name="add_export_platform">
<return type="void" />
<param index="0" name="platform" type="EditorExportPlatform" />
<description>
Registers a new [EditorExportPlatform]. Export platforms provides functionality of exporting to the specific platform.
</description>
</method>
<method name="add_export_plugin">
<return type="void" />
<param index="0" name="plugin" type="EditorExportPlugin" />
<description>
Registers a new [EditorExportPlugin]. Export plugins are used to perform tasks when the project is being exported.
See [method add_inspector_plugin] for an example of how to register a plugin.
</description>
</method>
<method name="add_import_plugin">
<return type="void" />
<param index="0" name="importer" type="EditorImportPlugin" />
<param index="1" name="first_priority" type="bool" default="false" />
<description>
Registers a new [EditorImportPlugin]. Import plugins are used to import custom and unsupported assets as a custom [Resource] type.
If [param first_priority] is [code]true[/code], the new import plugin is inserted first in the list and takes precedence over pre-existing plugins.
[b]Note:[/b] If you want to import custom 3D asset formats use [method add_scene_format_importer_plugin] instead.
See [method add_inspector_plugin] for an example of how to register a plugin.
</description>
</method>
<method name="add_inspector_plugin">
<return type="void" />
<param index="0" name="plugin" type="EditorInspectorPlugin" />
<description>
Registers a new [EditorInspectorPlugin]. Inspector plugins are used to extend [EditorInspector] and provide custom configuration tools for your object's properties.
[b]Note:[/b] Always use [method remove_inspector_plugin] to remove the registered [EditorInspectorPlugin] when your [EditorPlugin] is disabled to prevent leaks and an unexpected behavior.
[codeblocks]
[gdscript]
const MyInspectorPlugin = preload("res://addons/your_addon/path/to/your/script.gd")
var inspector_plugin = MyInspectorPlugin.new()
func _enter_tree():
add_inspector_plugin(inspector_plugin)
func _exit_tree():
remove_inspector_plugin(inspector_plugin)
[/gdscript]
[/codeblocks]
</description>
</method>
<method name="add_node_3d_gizmo_plugin">
<return type="void" />
<param index="0" name="plugin" type="EditorNode3DGizmoPlugin" />
<description>
Registers a new [EditorNode3DGizmoPlugin]. Gizmo plugins are used to add custom gizmos to the 3D preview viewport for a [Node3D].
See [method add_inspector_plugin] for an example of how to register a plugin.
</description>
</method>
<method name="add_resource_conversion_plugin">
<return type="void" />
<param index="0" name="plugin" type="EditorResourceConversionPlugin" />
<description>
Registers a new [EditorResourceConversionPlugin]. Resource conversion plugins are used to add custom resource converters to the editor inspector.
See [EditorResourceConversionPlugin] for an example of how to create a resource conversion plugin.
</description>
</method>
<method name="add_scene_format_importer_plugin">
<return type="void" />
<param index="0" name="scene_format_importer" type="EditorSceneFormatImporter" />
<param index="1" name="first_priority" type="bool" default="false" />
<description>
Registers a new [EditorSceneFormatImporter]. Scene importers are used to import custom 3D asset formats as scenes.
If [param first_priority] is [code]true[/code], the new import plugin is inserted first in the list and takes precedence over pre-existing plugins.
</description>
</method>
<method name="add_scene_post_import_plugin">
<return type="void" />
<param index="0" name="scene_import_plugin" type="EditorScenePostImportPlugin" />
<param index="1" name="first_priority" type="bool" default="false" />
<description>
Add a [EditorScenePostImportPlugin]. These plugins allow customizing the import process of 3D assets by adding new options to the import dialogs.
If [param first_priority] is [code]true[/code], the new import plugin is inserted first in the list and takes precedence over pre-existing plugins.
</description>
</method>
<method name="add_tool_menu_item">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="callable" type="Callable" />
<description>
Adds a custom menu item to [b]Project > Tools[/b] named [param name]. When clicked, the provided [param callable] will be called.
</description>
</method>
<method name="add_tool_submenu_item">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="submenu" type="PopupMenu" />
<description>
Adds a custom [PopupMenu] submenu under [b]Project > Tools >[/b] [param name]. Use [method remove_tool_menu_item] on plugin clean up to remove the menu.
</description>
</method>
<method name="add_translation_parser_plugin">
<return type="void" />
<param index="0" name="parser" type="EditorTranslationParserPlugin" />
<description>
Registers a custom translation parser plugin for extracting translatable strings from custom files.
</description>
</method>
<method name="add_undo_redo_inspector_hook_callback">
<return type="void" />
<param index="0" name="callable" type="Callable" />
<description>
Hooks a callback into the undo/redo action creation when a property is modified in the inspector. This allows, for example, to save other properties that may be lost when a given property is modified.
The callback should have 4 arguments: [Object] [code]undo_redo[/code], [Object] [code]modified_object[/code], [String] [code]property[/code] and [Variant] [code]new_value[/code]. They are, respectively, the [UndoRedo] object used by the inspector, the currently modified object, the name of the modified property and the new value the property is about to take.
</description>
</method>
<method name="get_editor_interface" deprecated="[EditorInterface] is a global singleton and can be accessed directly by its name.">
<return type="EditorInterface" />
<description>
Returns the [EditorInterface] singleton instance.
</description>
</method>
<method name="get_export_as_menu">
<return type="PopupMenu" />
<description>
Returns the [PopupMenu] under [b]Scene > Export As...[/b].
</description>
</method>
<method name="get_plugin_version" qualifiers="const">
<return type="String" />
<description>
Provide the version of the plugin declared in the [code]plugin.cfg[/code] config file.
</description>
</method>
<method name="get_script_create_dialog">
<return type="ScriptCreateDialog" />
<description>
Gets the Editor's dialog used for making scripts.
[b]Note:[/b] Users can configure it before use.
[b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
</description>
</method>
<
| |
125209
|
<method name="abs" qualifiers="const">
<return type="Vector3" />
<description>
Returns a new vector with all components in absolute values (i.e. positive).
</description>
</method>
<method name="angle_to" qualifiers="const">
<return type="float" />
<param index="0" name="to" type="Vector3" />
<description>
Returns the unsigned minimum angle to the given vector, in radians.
</description>
</method>
<method name="bezier_derivative" qualifiers="const">
<return type="Vector3" />
<param index="0" name="control_1" type="Vector3" />
<param index="1" name="control_2" type="Vector3" />
<param index="2" name="end" type="Vector3" />
<param index="3" name="t" type="float" />
<description>
Returns the derivative at the given [param t] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bézier curve[/url] defined by this vector and the given [param control_1], [param control_2], and [param end] points.
</description>
</method>
<method name="bezier_interpolate" qualifiers="const">
<return type="Vector3" />
<param index="0" name="control_1" type="Vector3" />
<param index="1" name="control_2" type="Vector3" />
<param index="2" name="end" type="Vector3" />
<param index="3" name="t" type="float" />
<description>
Returns the point at the given [param t] on the [url=https://en.wikipedia.org/wiki/B%C3%A9zier_curve]Bézier curve[/url] defined by this vector and the given [param control_1], [param control_2], and [param end] points.
</description>
</method>
<method name="bounce" qualifiers="const">
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
Returns the vector "bounced off" from a plane defined by the given normal [param n].
[b]Note:[/b] [method bounce] performs the operation that most engines and frameworks call [code skip-lint]reflect()[/code].
</description>
</method>
<method name="ceil" qualifiers="const">
<return type="Vector3" />
<description>
Returns a new vector with all components rounded up (towards positive infinity).
</description>
</method>
<method name="clamp" qualifiers="const">
<return type="Vector3" />
<param index="0" name="min" type="Vector3" />
<param index="1" name="max" type="Vector3" />
<description>
Returns a new vector with all components clamped between the components of [param min] and [param max], by running [method @GlobalScope.clamp] on each component.
</description>
</method>
<method name="clampf" qualifiers="const">
<return type="Vector3" />
<param index="0" name="min" type="float" />
<param index="1" name="max" type="float" />
<description>
Returns a new vector with all components clamped between [param min] and [param max], by running [method @GlobalScope.clamp] on each component.
</description>
</method>
<method name="cross" qualifiers="const">
<return type="Vector3" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the cross product of this vector and [param with].
This returns a vector perpendicular to both this and [param with], which would be the normal vector of the plane defined by the two vectors. As there are two such vectors, in opposite directions, this method returns the vector defined by a right-handed coordinate system. If the two vectors are parallel this returns an empty vector, making it useful for testing if two vectors are parallel.
</description>
</method>
<method name="cubic_interpolate" qualifiers="const">
<return type="Vector3" />
<param index="0" name="b" type="Vector3" />
<param index="1" name="pre_a" type="Vector3" />
<param index="2" name="post_b" type="Vector3" />
<param index="3" name="weight" type="float" />
<description>
Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation.
</description>
</method>
<method name="cubic_interpolate_in_time" qualifiers="const">
<return type="Vector3" />
<param index="0" name="b" type="Vector3" />
<param index="1" name="pre_a" type="Vector3" />
<param index="2" name="post_b" type="Vector3" />
<param index="3" name="weight" type="float" />
<param index="4" name="b_t" type="float" />
<param index="5" name="pre_a_t" type="float" />
<param index="6" name="post_b_t" type="float" />
<description>
Performs a cubic interpolation between this vector and [param b] using [param pre_a] and [param post_b] as handles, and returns the result at position [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation.
It can perform smoother interpolation than [method cubic_interpolate] by the time values.
</description>
</method>
<method name="direction_to" qualifiers="const">
<return type="Vector3" />
<param index="0" name="to" type="Vector3" />
<description>
Returns the normalized vector pointing from this vector to [param to]. This is equivalent to using [code](b - a).normalized()[/code].
</description>
</method>
<method name="distance_squared_to" qualifiers="const">
<return type="float" />
<param index="0" name="to" type="Vector3" />
<description>
Returns the squared distance between this vector and [param to].
This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula.
</description>
</method>
<method name="distance_to" qualifiers="const">
<return type="float" />
<param index="0" name="to" type="Vector3" />
<description>
Returns the distance between this vector and [param to].
</description>
</method>
<method name="dot" qualifiers="const">
<return type="float" />
<param index="0" name="with" type="Vector3" />
<description>
Returns the dot product of this vector and [param with]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
The dot product will be [code]0[/code] for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned.
[b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code].
</description>
</method>
<method name="floor" qualifiers="const">
<return type="Vector3" />
<description>
Returns a new vector with all components rounded down (towards negative infinity).
</description>
</method>
<m
| |
125211
|
ethod name="posmod" qualifiers="const">
<return type="Vector3" />
<param index="0" name="mod" type="float" />
<description>
Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param mod].
</description>
</method>
<method name="posmodv" qualifiers="const">
<return type="Vector3" />
<param index="0" name="modv" type="Vector3" />
<description>
Returns a vector composed of the [method @GlobalScope.fposmod] of this vector's components and [param modv]'s components.
</description>
</method>
<method name="project" qualifiers="const">
<return type="Vector3" />
<param index="0" name="b" type="Vector3" />
<description>
Returns a new vector resulting from projecting this vector onto the given vector [param b]. The resulting new vector is parallel to [param b]. See also [method slide].
[b]Note:[/b] If the vector [param b] is a zero vector, the components of the resulting new vector will be [constant @GDScript.NAN].
</description>
</method>
<method name="reflect" qualifiers="const">
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
Returns the result of reflecting the vector through a plane defined by the given normal vector [param n].
[b]Note:[/b] [method reflect] differs from what other engines and frameworks call [code skip-lint]reflect()[/code]. In other engines, [code skip-lint]reflect()[/code] returns the result of the vector reflected by the given plane. The reflection thus passes through the given normal. While in Godot the reflection passes through the plane and can be thought of as bouncing off the normal. See also [method bounce] which does what most engines call [code skip-lint]reflect()[/code].
</description>
</method>
<method name="rotated" qualifiers="const">
<return type="Vector3" />
<param index="0" name="axis" type="Vector3" />
<param index="1" name="angle" type="float" />
<description>
Returns the result of rotating this vector around a given axis by [param angle] (in radians). The axis must be a normalized vector. See also [method @GlobalScope.deg_to_rad].
</description>
</method>
<method name="round" qualifiers="const">
<return type="Vector3" />
<description>
Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
</description>
</method>
<method name="sign" qualifiers="const">
<return type="Vector3" />
<description>
Returns a new vector with each component set to [code]1.0[/code] if it's positive, [code]-1.0[/code] if it's negative, and [code]0.0[/code] if it's zero. The result is identical to calling [method @GlobalScope.sign] on each component.
</description>
</method>
<method name="signed_angle_to" qualifiers="const">
<return type="float" />
<param index="0" name="to" type="Vector3" />
<param index="1" name="axis" type="Vector3" />
<description>
Returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the [param axis].
</description>
</method>
<method name="slerp" qualifiers="const" keywords="interpolate">
<return type="Vector3" />
<param index="0" name="to" type="Vector3" />
<param index="1" name="weight" type="float" />
<description>
Returns the result of spherical linear interpolation between this vector and [param to], by amount [param weight]. [param weight] is on the range of 0.0 to 1.0, representing the amount of interpolation.
This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like [method lerp].
</description>
</method>
<method name="slide" qualifiers="const">
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
Returns a new vector resulting from sliding this vector along a plane with normal [param n]. The resulting new vector is perpendicular to [param n], and is equivalent to this vector minus its projection on [param n]. See also [method project].
[b]Note:[/b] The vector [param n] must be normalized. See also [method normalized].
</description>
</method>
<method name="snapped" qualifiers="const">
<return type="Vector3" />
<param index="0" name="step" type="Vector3" />
<description>
Returns a new vector with each component snapped to the nearest multiple of the corresponding component in [param step]. This can also be used to round the components to an arbitrary number of decimals.
</description>
</method>
<method name="snappedf" qualifiers="const">
<return type="Vector3" />
<param index="0" name="step" type="float" />
<description>
Returns a new vector with each component snapped to the nearest multiple of [param step]. This can also be used to round the components to an arbitrary number of decimals.
</description>
</method>
</methods>
<members>
<member name="x" type="float" setter="" getter="" default="0.0">
The vector's X component. Also accessible by using the index position [code][0][/code].
</member>
<member name="y" type="float" setter="" getter="" default="0.0">
The vector's Y component. Also accessible by using the index position [code][1][/code].
</member>
<member name="z" type="float" setter="" getter="" default="0.0">
The vector's Z component. Also accessible by using the index position [code][2][/code].
</member>
</members>
<c
| |
125286
|
methods>
<method name="adjust_bcs">
<return type="void" />
<param index="0" name="brightness" type="float" />
<param index="1" name="contrast" type="float" />
<param index="2" name="saturation" type="float" />
<description>
Adjusts this image's [param brightness], [param contrast], and [param saturation] by the given values. Does not work if the image is compressed (see [method is_compressed]).
</description>
</method>
<method name="blend_rect">
<return type="void" />
<param index="0" name="src" type="Image" />
<param index="1" name="src_rect" type="Rect2i" />
<param index="2" name="dst" type="Vector2i" />
<description>
Alpha-blends [param src_rect] from [param src] image to this image at coordinates [param dst], clipped accordingly to both image bounds. This image and [param src] image [b]must[/b] have the same format. [param src_rect] with non-positive size is treated as empty.
</description>
</method>
<method name="blend_rect_mask">
<return type="void" />
<param index="0" name="src" type="Image" />
<param index="1" name="mask" type="Image" />
<param index="2" name="src_rect" type="Rect2i" />
<param index="3" name="dst" type="Vector2i" />
<description>
Alpha-blends [param src_rect] from [param src] image to this image using [param mask] image at coordinates [param dst], clipped accordingly to both image bounds. Alpha channels are required for both [param src] and [param mask]. [param dst] pixels and [param src] pixels will blend if the corresponding mask pixel's alpha value is not 0. This image and [param src] image [b]must[/b] have the same format. [param src] image and [param mask] image [b]must[/b] have the same size (width and height) but they can have different formats. [param src_rect] with non-positive size is treated as empty.
</description>
</method>
<method name="blit_rect">
<return type="void" />
<param index="0" name="src" type="Image" />
<param index="1" name="src_rect" type="Rect2i" />
<param index="2" name="dst" type="Vector2i" />
<description>
Copies [param src_rect] from [param src] image to this image at coordinates [param dst], clipped accordingly to both image bounds. This image and [param src] image [b]must[/b] have the same format. [param src_rect] with non-positive size is treated as empty.
</description>
</method>
<method name="blit_rect_mask">
<return type="void" />
<param index="0" name="src" type="Image" />
<param index="1" name="mask" type="Image" />
<param index="2" name="src_rect" type="Rect2i" />
<param index="3" name="dst" type="Vector2i" />
<description>
Blits [param src_rect] area from [param src] image to this image at the coordinates given by [param dst], clipped accordingly to both image bounds. [param src] pixel is copied onto [param dst] if the corresponding [param mask] pixel's alpha value is not 0. This image and [param src] image [b]must[/b] have the same format. [param src] image and [param mask] image [b]must[/b] have the same size (width and height) but they can have different formats. [param src_rect] with non-positive size is treated as empty.
</description>
</method>
<method name="bump_map_to_normal_map">
<return type="void" />
<param index="0" name="bump_scale" type="float" default="1.0" />
<description>
Converts a bump map to a normal map. A bump map provides a height offset per-pixel, while a normal map provides a normal direction per pixel.
</description>
</method>
<method name="clear_mipmaps">
<return type="void" />
<description>
Removes the image's mipmaps.
</description>
</method>
<method name="compress">
<return type="int" enum="Error" />
<param index="0" name="mode" type="int" enum="Image.CompressMode" />
<param index="1" name="source" type="int" enum="Image.CompressSource" default="0" />
<param index="2" name="astc_format" type="int" enum="Image.ASTCFormat" default="0" />
<description>
Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available.
The [param source] parameter helps to pick the best compression method for DXT and ETC2 formats. It is ignored for ASTC compression.
For ASTC compression, the [param astc_format] parameter must be supplied.
</description>
</method>
<method name="compress_from_channels">
<return type="int" enum="Error" />
<param index="0" name="mode" type="int" enum="Image.CompressMode" />
<param index="1" name="channels" type="int" enum="Image.UsedChannels" />
<param index="2" name="astc_format" type="int" enum="Image.ASTCFormat" default="0" />
<description>
Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available.
This is an alternative to [method compress] that lets the user supply the channels used in order for the compressor to pick the best DXT and ETC2 formats. For other formats (non DXT or ETC2), this argument is ignored.
For ASTC compression, the [param astc_format] parameter must be supplied.
</description>
</method>
<method name="compute_image_metrics">
<return type="Dictionary" />
<param index="0" name="compared_image" type="Image" />
<param index="1" name="use_luma" type="bool" />
<description>
Compute image metrics on the current image and the compared image.
The dictionary contains [code]max[/code], [code]mean[/code], [code]mean_squared[/code], [code]root_mean_squared[/code] and [code]peak_snr[/code].
</description>
</method>
<method name="convert">
<return type="void" />
<param index="0" name="format" type="int" enum="Image.Format" />
<description>
Converts the image's format. See [enum Format] constants.
</description>
</method>
<method name="copy_from">
<return type="void" />
<param index="0" name="src" type="Image" />
<description>
Copies [param src] image to this image.
</description>
</method>
<method name="create" qualifiers="static" deprecated="Use [method create_empty].">
<return type="Image" />
<param index="0" name="width" type="int" />
<param index="1" name="height" type="int" />
<param index="2" name="use_mipmaps" type="bool" />
<param index="3" name="format" type="int" enum="Image.Format" />
<description>
Creates an empty image of given size and format. See [enum Format] constants. If [param use_mipmaps] is [code]true[/code], then generate mipmaps for this image. See the [method generate_mipmaps].
</description>
</method>
<
| |
125319
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PackedScene" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
An abstraction of a serialized scene.
</brief_description>
<description>
A simplified interface to a scene file. Provides access to operations and checks that can be performed on the scene resource itself.
Can be used to save a node to a file. When saving, the node as well as all the nodes it owns get saved (see [member Node.owner] property).
[b]Note:[/b] The node doesn't need to own itself.
[b]Example of loading a saved scene:[/b]
[codeblocks]
[gdscript]
# Use load() instead of preload() if the path isn't known at compile-time.
var scene = preload("res://scene.tscn").instantiate()
# Add the node as a child of the node the script is attached to.
add_child(scene)
[/gdscript]
[csharp]
// C# has no preload, so you have to always use ResourceLoader.Load<PackedScene>().
var scene = ResourceLoader.Load<PackedScene>("res://scene.tscn").Instantiate();
// Add the node as a child of the node the script is attached to.
AddChild(scene);
[/csharp]
[/codeblocks]
[b]Example of saving a node with different owners:[/b] The following example creates 3 objects: [Node2D] ([code]node[/code]), [RigidBody2D] ([code]body[/code]) and [CollisionObject2D] ([code]collision[/code]). [code]collision[/code] is a child of [code]body[/code] which is a child of [code]node[/code]. Only [code]body[/code] is owned by [code]node[/code] and [method pack] will therefore only save those two nodes, but not [code]collision[/code].
[codeblocks]
[gdscript]
# Create the objects.
var node = Node2D.new()
var body = RigidBody2D.new()
var collision = CollisionShape2D.new()
# Create the object hierarchy.
body.add_child(collision)
node.add_child(body)
# Change owner of `body`, but not of `collision`.
body.owner = node
var scene = PackedScene.new()
# Only `node` and `body` are now packed.
var result = scene.pack(node)
if result == OK:
var error = ResourceSaver.save(scene, "res://path/name.tscn") # Or "user://..."
if error != OK:
push_error("An error occurred while saving the scene to disk.")
[/gdscript]
[csharp]
// Create the objects.
var node = new Node2D();
var body = new RigidBody2D();
var collision = new CollisionShape2D();
// Create the object hierarchy.
body.AddChild(collision);
node.AddChild(body);
// Change owner of `body`, but not of `collision`.
body.Owner = node;
var scene = new PackedScene();
// Only `node` and `body` are now packed.
Error result = scene.Pack(node);
if (result == Error.Ok)
{
Error error = ResourceSaver.Save(scene, "res://path/name.tscn"); // Or "user://..."
if (error != Error.Ok)
{
GD.PushError("An error occurred while saving the scene to disk.");
}
}
[/csharp]
[/codeblocks]
</description>
<tutorials>
<link title="2D Role Playing Game (RPG) Demo">https://godotengine.org/asset-library/asset/2729</link>
</tutorials>
<methods>
<method name="can_instantiate" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the scene file has nodes.
</description>
</method>
<method name="get_state" qualifiers="const">
<return type="SceneState" />
<description>
Returns the [SceneState] representing the scene file contents.
</description>
</method>
<method name="instantiate" qualifiers="const" keywords="create, make, spawn, new">
<return type="Node" />
<param index="0" name="edit_state" type="int" enum="PackedScene.GenEditState" default="0" />
<description>
Instantiates the scene's node hierarchy. Triggers child scene instantiation(s). Triggers a [constant Node.NOTIFICATION_SCENE_INSTANTIATED] notification on the root node.
</description>
</method>
<method name="pack">
<return type="int" enum="Error" />
<param index="0" name="path" type="Node" />
<description>
Packs the [param path] node, and all owned sub-nodes, into this [PackedScene]. Any existing data will be cleared. See [member Node.owner].
</description>
</method>
</methods>
<constants>
<constant name="GEN_EDIT_STATE_DISABLED" value="0" enum="GenEditState">
If passed to [method instantiate], blocks edits to the scene state.
</constant>
<constant name="GEN_EDIT_STATE_INSTANCE" value="1" enum="GenEditState">
If passed to [method instantiate], provides local scene resources to the local scene.
[b]Note:[/b] Only available in editor builds.
</constant>
<constant name="GEN_EDIT_STATE_MAIN" value="2" enum="GenEditState">
If passed to [method instantiate], provides local scene resources to the local scene. Only the main scene should receive the main edit state.
[b]Note:[/b] Only available in editor builds.
</constant>
<constant name="GEN_EDIT_STATE_MAIN_INHERITED" value="3" enum="GenEditState">
It's similar to [constant GEN_EDIT_STATE_MAIN], but for the case where the scene is being instantiated to be the base of another one.
[b]Note:[/b] Only available in editor builds.
</constant>
</constants>
</class>
| |
125326
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorFileSystem" inherits="Node" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Resource filesystem, as the editor sees it.
</brief_description>
<description>
This object holds information of all resources in the filesystem, their types, etc.
[b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton using [method EditorInterface.get_resource_filesystem].
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_file_type" qualifiers="const">
<return type="String" />
<param index="0" name="path" type="String" />
<description>
Returns the resource type of the file, given the full path. This returns a string such as [code]"Resource"[/code] or [code]"GDScript"[/code], [i]not[/i] a file extension such as [code]".gd"[/code].
</description>
</method>
<method name="get_filesystem">
<return type="EditorFileSystemDirectory" />
<description>
Gets the root directory object.
</description>
</method>
<method name="get_filesystem_path">
<return type="EditorFileSystemDirectory" />
<param index="0" name="path" type="String" />
<description>
Returns a view into the filesystem at [param path].
</description>
</method>
<method name="get_scanning_progress" qualifiers="const">
<return type="float" />
<description>
Returns the scan progress for 0 to 1 if the FS is being scanned.
</description>
</method>
<method name="is_scanning" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if the filesystem is being scanned.
</description>
</method>
<method name="reimport_files">
<return type="void" />
<param index="0" name="files" type="PackedStringArray" />
<description>
Reimports a set of files. Call this if these files or their [code].import[/code] files were directly edited by script or an external program.
If the file type changed or the file was newly created, use [method update_file] or [method scan].
[b]Note:[/b] This function blocks until the import is finished. However, the main loop iteration, including timers and [method Node._process], will occur during the import process due to progress bar updates. Avoid calls to [method reimport_files] or [method scan] while an import is in progress.
</description>
</method>
<method name="scan">
<return type="void" />
<description>
Scan the filesystem for changes.
</description>
</method>
<method name="scan_sources">
<return type="void" />
<description>
Check if the source of any imported resource changed.
</description>
</method>
<method name="update_file">
<return type="void" />
<param index="0" name="path" type="String" />
<description>
Add a file in an existing directory, or schedule file information to be updated on editor restart. Can be used to update text files saved by an external program.
This will not import the file. To reimport, call [method reimport_files] or [method scan] methods.
</description>
</method>
</methods>
<signals>
<signal name="filesystem_changed">
<description>
Emitted if the filesystem changed.
</description>
</signal>
<signal name="resources_reimported">
<param index="0" name="resources" type="PackedStringArray" />
<description>
Emitted if a resource is reimported.
</description>
</signal>
<signal name="resources_reimporting">
<param index="0" name="resources" type="PackedStringArray" />
<description>
Emitted before a resource is reimported.
</description>
</signal>
<signal name="resources_reload">
<param index="0" name="resources" type="PackedStringArray" />
<description>
Emitted if at least one resource is reloaded when the filesystem is scanned.
</description>
</signal>
<signal name="script_classes_updated">
<description>
Emitted when the list of global script classes gets updated.
</description>
</signal>
<signal name="sources_changed">
<param index="0" name="exist" type="bool" />
<description>
Emitted if the source of any imported file changed.
</description>
</signal>
</signals>
</class>
| |
125379
|
RotationEditMode get_rotation_edit_mode() const;
void set_rotation_order(EulerOrder p_order);
void set_rotation(const Vector3 &p_euler_rad);
void set_rotation_degrees(const Vector3 &p_euler_degrees);
void set_scale(const Vector3 &p_scale);
void set_global_position(const Vector3 &p_position);
void set_global_basis(const Basis &p_basis);
void set_global_rotation(const Vector3 &p_euler_rad);
void set_global_rotation_degrees(const Vector3 &p_euler_degrees);
Vector3 get_position() const;
EulerOrder get_rotation_order() const;
Vector3 get_rotation() const;
Vector3 get_rotation_degrees() const;
Vector3 get_scale() const;
Vector3 get_global_position() const;
Basis get_global_basis() const;
Vector3 get_global_rotation() const;
Vector3 get_global_rotation_degrees() const;
void set_transform(const Transform3D &p_transform);
void set_basis(const Basis &p_basis);
void set_quaternion(const Quaternion &p_quaternion);
void set_global_transform(const Transform3D &p_transform);
Transform3D get_transform() const;
Basis get_basis() const;
Quaternion get_quaternion() const;
Transform3D get_global_transform() const;
Transform3D get_global_transform_interpolated();
bool update_client_physics_interpolation_data();
#ifdef TOOLS_ENABLED
virtual Transform3D get_global_gizmo_transform() const;
virtual Transform3D get_local_gizmo_transform() const;
virtual void set_transform_gizmo_visible(bool p_enabled) { data.transform_gizmo_visible = p_enabled; };
virtual bool is_transform_gizmo_visible() const { return data.transform_gizmo_visible; };
#endif
virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
void set_disable_gizmos(bool p_enabled);
void update_gizmos();
void set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D());
void clear_subgizmo_selection();
Vector<Ref<Node3DGizmo>> get_gizmos() const;
TypedArray<Node3DGizmo> get_gizmos_bind() const;
void add_gizmo(Ref<Node3DGizmo> p_gizmo);
void remove_gizmo(Ref<Node3DGizmo> p_gizmo);
void clear_gizmos();
void set_as_top_level(bool p_enabled);
void set_as_top_level_keep_local(bool p_enabled);
bool is_set_as_top_level() const;
void set_disable_scale(bool p_enabled);
bool is_scale_disabled() const;
_FORCE_INLINE_ bool is_inside_world() const { return data.inside_world; }
Transform3D get_relative_transform(const Node *p_parent) const;
void rotate(const Vector3 &p_axis, real_t p_angle);
void rotate_x(real_t p_angle);
void rotate_y(real_t p_angle);
void rotate_z(real_t p_angle);
void translate(const Vector3 &p_offset);
void scale(const Vector3 &p_ratio);
void rotate_object_local(const Vector3 &p_axis, real_t p_angle);
void scale_object_local(const Vector3 &p_scale);
void translate_object_local(const Vector3 &p_offset);
void global_rotate(const Vector3 &p_axis, real_t p_angle);
void global_scale(const Vector3 &p_scale);
void global_translate(const Vector3 &p_offset);
void look_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false);
void look_at_from_position(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false);
Vector3 to_local(Vector3 p_global) const;
Vector3 to_global(Vector3 p_local) const;
void set_notify_transform(bool p_enabled);
bool is_transform_notification_enabled() const;
void set_notify_local_transform(bool p_enabled);
bool is_local_transform_notification_enabled() const;
void orthonormalize();
void set_identity();
void set_visible(bool p_visible);
void show();
void hide();
bool is_visible() const;
bool is_visible_in_tree() const;
void force_update_transform();
void set_visibility_parent(const NodePath &p_path);
NodePath get_visibility_parent() const;
Node3D();
~Node3D();
};
VARIANT_ENUM_CAST(Node3D::RotationEditMode)
#endif // NODE_3D_H
| |
125389
|
/**************************************************************************/
/* character_body_3d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CHARACTER_BODY_3D_H
#define CHARACTER_BODY_3D_H
#include "scene/3d/physics/kinematic_collision_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
class CharacterBody3D : public PhysicsBody3D {
GDCLASS(CharacterBody3D, PhysicsBody3D);
public:
enum MotionMode {
MOTION_MODE_GROUNDED,
MOTION_MODE_FLOATING,
};
enum PlatformOnLeave {
PLATFORM_ON_LEAVE_ADD_VELOCITY,
PLATFORM_ON_LEAVE_ADD_UPWARD_VELOCITY,
PLATFORM_ON_LEAVE_DO_NOTHING,
};
bool move_and_slide();
void apply_floor_snap();
const Vector3 &get_velocity() const;
void set_velocity(const Vector3 &p_velocity);
bool is_on_floor() const;
bool is_on_floor_only() const;
bool is_on_wall() const;
bool is_on_wall_only() const;
bool is_on_ceiling() const;
bool is_on_ceiling_only() const;
const Vector3 &get_last_motion() const;
Vector3 get_position_delta() const;
const Vector3 &get_floor_normal() const;
const Vector3 &get_wall_normal() const;
const Vector3 &get_real_velocity() const;
real_t get_floor_angle(const Vector3 &p_up_direction = Vector3(0.0, 1.0, 0.0)) const;
const Vector3 &get_platform_velocity() const;
const Vector3 &get_platform_angular_velocity() const;
virtual Vector3 get_linear_velocity() const override;
int get_slide_collision_count() const;
PhysicsServer3D::MotionResult get_slide_collision(int p_bounce) const;
void set_safe_margin(real_t p_margin);
real_t get_safe_margin() const;
bool is_floor_stop_on_slope_enabled() const;
void set_floor_stop_on_slope_enabled(bool p_enabled);
bool is_floor_constant_speed_enabled() const;
void set_floor_constant_speed_enabled(bool p_enabled);
bool is_floor_block_on_wall_enabled() const;
void set_floor_block_on_wall_enabled(bool p_enabled);
bool is_slide_on_ceiling_enabled() const;
void set_slide_on_ceiling_enabled(bool p_enabled);
int get_max_slides() const;
void set_max_slides(int p_max_slides);
real_t get_floor_max_angle() const;
void set_floor_max_angle(real_t p_radians);
real_t get_floor_snap_length();
void set_floor_snap_length(real_t p_floor_snap_length);
real_t get_wall_min_slide_angle() const;
void set_wall_min_slide_angle(real_t p_radians);
uint32_t get_platform_floor_layers() const;
void set_platform_floor_layers(const uint32_t p_exclude_layer);
uint32_t get_platform_wall_layers() const;
void set_platform_wall_layers(const uint32_t p_exclude_layer);
void set_motion_mode(MotionMode p_mode);
MotionMode get_motion_mode() const;
void set_platform_on_leave(PlatformOnLeave p_on_leave_velocity);
PlatformOnLeave get_platform_on_leave() const;
CharacterBody3D();
private:
real_t margin = 0.001;
MotionMode motion_mode = MOTION_MODE_GROUNDED;
PlatformOnLeave platform_on_leave = PLATFORM_ON_LEAVE_ADD_VELOCITY;
union CollisionState {
uint32_t state = 0;
struct {
bool floor;
bool wall;
bool ceiling;
};
CollisionState() {
}
CollisionState(bool p_floor, bool p_wall, bool p_ceiling) {
floor = p_floor;
wall = p_wall;
ceiling = p_ceiling;
}
};
CollisionState collision_state;
bool floor_constant_speed = false;
bool floor_stop_on_slope = true;
bool floor_block_on_wall = true;
bool slide_on_ceiling = true;
int max_slides = 6;
int platform_layer = 0;
RID platform_rid;
ObjectID platform_object_id;
uint32_t platform_floor_layers = UINT32_MAX;
uint32_t platform_wall_layers = 0;
real_t floor_snap_length = 0.1;
real_t floor_max_angle = Math::deg_to_rad((real_t)45.0);
real_t wall_min_slide_angle = Math::deg_to_rad((real_t)15.0);
Vector3 up_direction = Vector3(0.0, 1.0, 0.0);
Vector3 velocity;
Vector3 floor_normal;
Vector3 wall_normal;
Vector3 ceiling_normal;
Vector3 last_motion;
Vector3 platform_velocity;
Vector3 platform_angular_velocity;
Vector3 platform_ceiling_velocity;
Vector3 previous_position;
Vector3 real_velocity;
Vector<PhysicsServer3D::MotionResult> motion_results;
Vector<Ref<KinematicCollision3D>> slide_colliders;
void _move_and_slide_floating(double p_delta);
void _move_and_slide_grounded(double p_delta, bool p_was_on_floor);
Ref<KinematicCollision3D> _get_slide_collision(int p_bounce);
Ref<KinematicCollision3D> _get_last_slide_collision();
const Vector3 &get_up_direction() const;
bool _on_floor_if_snapped(bool p_was_on_floor, bool p_vel_dir_facing_up);
void set_up_direction(const Vector3 &p_up_direction);
void _set_collision_direction(const PhysicsServer3D::MotionResult &p_result, CollisionState &r_state, CollisionState p_apply_state = CollisionState(true, true, true));
void _set_platform_data(const PhysicsServer3D::MotionCollision &p_collision);
void _snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_up);
protected:
void _notification(int p_what);
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
};
VARIANT_ENUM_CAST(CharacterBody3D::MotionMode);
VARIANT_ENUM_CAST(CharacterBody3D::PlatformOnLeave);
#endif // CHARACTER_BODY_3D_H
| |
125390
|
/**************************************************************************/
/* collision_object_3d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_OBJECT_3D_H
#define COLLISION_OBJECT_3D_H
#include "scene/3d/camera_3d.h"
#include "scene/3d/node_3d.h"
class CollisionObject3D : public Node3D {
GDCLASS(CollisionObject3D, Node3D);
public:
enum DisableMode {
DISABLE_MODE_REMOVE,
DISABLE_MODE_MAKE_STATIC,
DISABLE_MODE_KEEP_ACTIVE,
};
private:
uint32_t collision_layer = 1;
uint32_t collision_mask = 1;
real_t collision_priority = 1.0;
bool area = false;
RID rid;
uint32_t callback_lock = 0;
DisableMode disable_mode = DISABLE_MODE_REMOVE;
PhysicsServer3D::BodyMode body_mode = PhysicsServer3D::BODY_MODE_STATIC;
struct ShapeData {
ObjectID owner_id;
Transform3D xform;
struct ShapeBase {
RID debug_shape;
Ref<Shape3D> shape;
int index = 0;
};
Vector<ShapeBase> shapes;
bool disabled = false;
};
int total_subshapes = 0;
RBMap<uint32_t, ShapeData> shapes;
bool only_update_transform_changes = false; // This is used for sync to physics.
bool capture_input_on_drag = false;
bool ray_pickable = true;
HashSet<uint32_t> debug_shapes_to_update;
int debug_shapes_count = 0;
Transform3D debug_shape_old_transform;
void _update_pickable();
bool _are_collision_shapes_visible();
void _update_shape_data(uint32_t p_owner);
void _shape_changed(const Ref<Shape3D> &p_shape);
void _update_debug_shapes();
void _clear_debug_shapes();
void _apply_disabled();
void _apply_enabled();
protected:
CollisionObject3D(RID p_rid, bool p_area);
_FORCE_INLINE_ void lock_callback() { callback_lock++; }
_FORCE_INLINE_ void unlock_callback() {
ERR_FAIL_COND(callback_lock == 0);
callback_lock--;
}
void _notification(int p_what);
static void _bind_methods();
void _on_transform_changed();
friend class Viewport;
virtual void _input_event_call(Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
virtual void _mouse_enter();
virtual void _mouse_exit();
void set_body_mode(PhysicsServer3D::BodyMode p_mode);
virtual void _space_changed(const RID &p_new_space);
void set_only_update_transform_changes(bool p_enable);
bool is_only_update_transform_changes_enabled() const;
GDVIRTUAL5(_input_event, Camera3D *, Ref<InputEvent>, Vector3, Vector3, int)
GDVIRTUAL0(_mouse_enter)
GDVIRTUAL0(_mouse_exit)
public:
void set_collision_layer(uint32_t p_layer);
uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
void set_collision_layer_value(int p_layer_number, bool p_value);
bool get_collision_layer_value(int p_layer_number) const;
void set_collision_mask_value(int p_layer_number, bool p_value);
bool get_collision_mask_value(int p_layer_number) const;
void set_collision_priority(real_t p_priority);
real_t get_collision_priority() const;
void set_disable_mode(DisableMode p_mode);
DisableMode get_disable_mode() const;
uint32_t create_shape_owner(Object *p_owner);
void remove_shape_owner(uint32_t owner);
void get_shape_owners(List<uint32_t> *r_owners);
PackedInt32Array _get_shape_owners();
void shape_owner_set_transform(uint32_t p_owner, const Transform3D &p_transform);
Transform3D shape_owner_get_transform(uint32_t p_owner) const;
Object *shape_owner_get_owner(uint32_t p_owner) const;
void shape_owner_set_disabled(uint32_t p_owner, bool p_disabled);
bool is_shape_owner_disabled(uint32_t p_owner) const;
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
Ref<Shape3D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
void shape_owner_clear_shapes(uint32_t p_owner);
uint32_t shape_find_owner(int p_shape_index) const;
void set_ray_pickable(bool p_ray_pickable);
bool is_ray_pickable() const;
void set_capture_input_on_drag(bool p_capture);
bool get_capture_input_on_drag() const;
_FORCE_INLINE_ RID get_rid() const { return rid; }
PackedStringArray get_configuration_warnings() const override;
CollisionObject3D();
~CollisionObject3D();
};
VARIANT_ENUM_CAST(CollisionObject3D::DisableMode);
#endif // COLLISION_OBJECT_3D_H
| |
125392
|
/**************************************************************************/
/* ray_cast_3d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RAY_CAST_3D_H
#define RAY_CAST_3D_H
#include "scene/3d/node_3d.h"
class CollisionObject3D;
class RayCast3D : public Node3D {
GDCLASS(RayCast3D, Node3D);
bool enabled = true;
bool collided = false;
ObjectID against;
RID against_rid;
int against_shape = 0;
Vector3 collision_point;
Vector3 collision_normal;
int collision_face_index = -1;
Vector3 target_position = Vector3(0, -1, 0);
HashSet<RID> exclude;
uint32_t collision_mask = 1;
bool exclude_parent_body = true;
Ref<Material> debug_material;
Color debug_shape_custom_color = Color(0.0, 0.0, 0.0);
int debug_shape_thickness = 2;
Vector<Vector3> debug_shape_vertices;
Vector<Vector3> debug_line_vertices;
void _create_debug_shape();
void _update_debug_shape();
void _update_debug_shape_material(bool p_check_collision = false);
void _update_debug_shape_vertices();
void _clear_debug_shape();
bool collide_with_areas = false;
bool collide_with_bodies = true;
bool hit_from_inside = false;
bool hit_back_faces = true;
RID debug_instance;
Ref<ArrayMesh> debug_mesh;
protected:
void _notification(int p_what);
void _update_raycast_state();
static void _bind_methods();
public:
void set_collide_with_areas(bool p_enabled);
bool is_collide_with_areas_enabled() const;
void set_collide_with_bodies(bool p_enabled);
bool is_collide_with_bodies_enabled() const;
void set_hit_from_inside(bool p_enabled);
bool is_hit_from_inside_enabled() const;
void set_hit_back_faces(bool p_enabled);
bool is_hit_back_faces_enabled() const;
void set_enabled(bool p_enabled);
bool is_enabled() const;
void set_target_position(const Vector3 &p_point);
Vector3 get_target_position() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
void set_collision_mask_value(int p_layer_number, bool p_value);
bool get_collision_mask_value(int p_layer_number) const;
void set_exclude_parent_body(bool p_exclude_parent_body);
bool get_exclude_parent_body() const;
const Color &get_debug_shape_custom_color() const;
void set_debug_shape_custom_color(const Color &p_color);
const Vector<Vector3> &get_debug_shape_vertices() const;
const Vector<Vector3> &get_debug_line_vertices() const;
Ref<StandardMaterial3D> get_debug_material();
int get_debug_shape_thickness() const;
void set_debug_shape_thickness(const int p_debug_thickness);
void force_raycast_update();
bool is_colliding() const;
Object *get_collider() const;
RID get_collider_rid() const;
int get_collider_shape() const;
Vector3 get_collision_point() const;
Vector3 get_collision_normal() const;
int get_collision_face_index() const;
void add_exception_rid(const RID &p_rid);
void add_exception(const CollisionObject3D *p_node);
void remove_exception_rid(const RID &p_rid);
void remove_exception(const CollisionObject3D *p_node);
void clear_exceptions();
RayCast3D();
};
#endif // RAY_CAST_3D_H
| |
125427
|
/**************************************************************************/
/* sprite_frames.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRITE_FRAMES_H
#define SPRITE_FRAMES_H
#include "scene/resources/texture.h"
static const float SPRITE_FRAME_MINIMUM_DURATION = 0.01;
class SpriteFrames : public Resource {
GDCLASS(SpriteFrames, Resource);
struct Frame {
Ref<Texture2D> texture;
float duration = 1.0;
};
struct Anim {
double speed = 5.0;
bool loop = true;
Vector<Frame> frames;
};
HashMap<StringName, Anim> animations;
Array _get_animations() const;
void _set_animations(const Array &p_animations);
protected:
static void _bind_methods();
public:
void add_animation(const StringName &p_anim);
bool has_animation(const StringName &p_anim) const;
void duplicate_animation(const StringName &p_from, const StringName &p_to);
void remove_animation(const StringName &p_anim);
void rename_animation(const StringName &p_prev, const StringName &p_next);
void get_animation_list(List<StringName> *r_animations) const;
Vector<String> get_animation_names() const;
void set_animation_speed(const StringName &p_anim, double p_fps);
double get_animation_speed(const StringName &p_anim) const;
void set_animation_loop(const StringName &p_anim, bool p_loop);
bool get_animation_loop(const StringName &p_anim) const;
void add_frame(const StringName &p_anim, const Ref<Texture2D> &p_texture, float p_duration = 1.0, int p_at_pos = -1);
void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture2D> &p_texture, float p_duration = 1.0);
void remove_frame(const StringName &p_anim, int p_idx);
int get_frame_count(const StringName &p_anim) const;
_FORCE_INLINE_ Ref<Texture2D> get_frame_texture(const StringName &p_anim, int p_idx) const {
HashMap<StringName, Anim>::ConstIterator E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>());
if (p_idx >= E->value.frames.size()) {
return Ref<Texture2D>();
}
return E->value.frames[p_idx].texture;
}
_FORCE_INLINE_ float get_frame_duration(const StringName &p_anim, int p_idx) const {
HashMap<StringName, Anim>::ConstIterator E = animations.find(p_anim);
ERR_FAIL_COND_V_MSG(!E, 1.0, "Animation '" + String(p_anim) + "' doesn't exist.");
ERR_FAIL_COND_V(p_idx < 0, 1.0);
if (p_idx >= E->value.frames.size()) {
return 1.0;
}
return E->value.frames[p_idx].duration;
}
void clear(const StringName &p_anim);
void clear_all();
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
SpriteFrames();
};
#endif // SPRITE_FRAMES_H
| |
125568
|
/**************************************************************************/
/* animation_blend_space_2d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef ANIMATION_BLEND_SPACE_2D_H
#define ANIMATION_BLEND_SPACE_2D_H
#include "scene/animation/animation_tree.h"
class AnimationNodeBlendSpace2D : public AnimationRootNode {
GDCLASS(AnimationNodeBlendSpace2D, AnimationRootNode);
public:
enum BlendMode {
BLEND_MODE_INTERPOLATED,
BLEND_MODE_DISCRETE,
BLEND_MODE_DISCRETE_CARRY,
};
protected:
enum {
MAX_BLEND_POINTS = 64
};
struct BlendPoint {
StringName name;
Ref<AnimationRootNode> node;
Vector2 position;
};
BlendPoint blend_points[MAX_BLEND_POINTS];
int blend_points_used = 0;
struct BlendTriangle {
int points[3] = {};
};
Vector<BlendTriangle> triangles;
StringName blend_position = "blend_position";
StringName closest = "closest";
Vector2 max_space = Vector2(1, 1);
Vector2 min_space = Vector2(-1, -1);
Vector2 snap = Vector2(0.1, 0.1);
String x_label = "x";
String y_label = "y";
BlendMode blend_mode = BLEND_MODE_INTERPOLATED;
void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node);
void _set_triangles(const Vector<int> &p_triangles);
Vector<int> _get_triangles() const;
void _blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights);
bool auto_triangles = true;
bool trianges_dirty = false;
void _update_triangles();
void _queue_auto_triangles();
bool sync = false;
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
virtual void _tree_changed() override;
virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
public:
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
void add_blend_point(const Ref<AnimationRootNode> &p_node, const Vector2 &p_position, int p_at_index = -1);
void set_blend_point_position(int p_point, const Vector2 &p_position);
void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node);
Vector2 get_blend_point_position(int p_point) const;
Ref<AnimationRootNode> get_blend_point_node(int p_point) const;
void remove_blend_point(int p_point);
int get_blend_point_count() const;
bool has_triangle(int p_x, int p_y, int p_z) const;
void add_triangle(int p_x, int p_y, int p_z, int p_at_index = -1);
int get_triangle_point(int p_triangle, int p_point);
void remove_triangle(int p_triangle);
int get_triangle_count() const;
void set_min_space(const Vector2 &p_min);
Vector2 get_min_space() const;
void set_max_space(const Vector2 &p_max);
Vector2 get_max_space() const;
void set_snap(const Vector2 &p_snap);
Vector2 get_snap() const;
void set_x_label(const String &p_label);
String get_x_label() const;
void set_y_label(const String &p_label);
String get_y_label() const;
virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override;
virtual String get_caption() const override;
Vector2 get_closest_point(const Vector2 &p_point);
void set_auto_triangles(bool p_enable);
bool get_auto_triangles() const;
void set_blend_mode(BlendMode p_blend_mode);
BlendMode get_blend_mode() const;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) const override;
AnimationNodeBlendSpace2D();
~AnimationNodeBlendSpace2D();
};
VARIANT_ENUM_CAST(AnimationNodeBlendSpace2D::BlendMode)
#endif // ANIMATION_BLEND_SPACE_2D_H
| |
125680
|
class Control : public CanvasItem {
GDCLASS(Control, CanvasItem);
#ifdef TOOLS_ENABLED
bool saving = false;
#endif
public:
enum Anchor {
ANCHOR_BEGIN = 0,
ANCHOR_END = 1
};
enum GrowDirection {
GROW_DIRECTION_BEGIN,
GROW_DIRECTION_END,
GROW_DIRECTION_BOTH
};
enum FocusMode {
FOCUS_NONE,
FOCUS_CLICK,
FOCUS_ALL
};
enum SizeFlags {
SIZE_SHRINK_BEGIN = 0,
SIZE_FILL = 1,
SIZE_EXPAND = 2,
SIZE_SHRINK_CENTER = 4,
SIZE_SHRINK_END = 8,
SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL,
};
enum MouseFilter {
MOUSE_FILTER_STOP,
MOUSE_FILTER_PASS,
MOUSE_FILTER_IGNORE
};
enum CursorShape {
CURSOR_ARROW,
CURSOR_IBEAM,
CURSOR_POINTING_HAND,
CURSOR_CROSS,
CURSOR_WAIT,
CURSOR_BUSY,
CURSOR_DRAG,
CURSOR_CAN_DROP,
CURSOR_FORBIDDEN,
CURSOR_VSIZE,
CURSOR_HSIZE,
CURSOR_BDIAGSIZE,
CURSOR_FDIAGSIZE,
CURSOR_MOVE,
CURSOR_VSPLIT,
CURSOR_HSPLIT,
CURSOR_HELP,
CURSOR_MAX
};
enum LayoutPreset {
PRESET_TOP_LEFT,
PRESET_TOP_RIGHT,
PRESET_BOTTOM_LEFT,
PRESET_BOTTOM_RIGHT,
PRESET_CENTER_LEFT,
PRESET_CENTER_TOP,
PRESET_CENTER_RIGHT,
PRESET_CENTER_BOTTOM,
PRESET_CENTER,
PRESET_LEFT_WIDE,
PRESET_TOP_WIDE,
PRESET_RIGHT_WIDE,
PRESET_BOTTOM_WIDE,
PRESET_VCENTER_WIDE,
PRESET_HCENTER_WIDE,
PRESET_FULL_RECT
};
enum LayoutPresetMode {
PRESET_MODE_MINSIZE,
PRESET_MODE_KEEP_WIDTH,
PRESET_MODE_KEEP_HEIGHT,
PRESET_MODE_KEEP_SIZE
};
enum LayoutMode {
LAYOUT_MODE_POSITION,
LAYOUT_MODE_ANCHORS,
LAYOUT_MODE_CONTAINER,
LAYOUT_MODE_UNCONTROLLED,
};
enum LayoutDirection {
LAYOUT_DIRECTION_INHERITED,
LAYOUT_DIRECTION_APPLICATION_LOCALE,
LAYOUT_DIRECTION_LTR,
LAYOUT_DIRECTION_RTL,
LAYOUT_DIRECTION_SYSTEM_LOCALE,
LAYOUT_DIRECTION_MAX,
#ifndef DISABLE_DEPRECATED
LAYOUT_DIRECTION_LOCALE = LAYOUT_DIRECTION_APPLICATION_LOCALE,
#endif // DISABLE_DEPRECATED
};
enum TextDirection {
TEXT_DIRECTION_AUTO = TextServer::DIRECTION_AUTO,
TEXT_DIRECTION_LTR = TextServer::DIRECTION_LTR,
TEXT_DIRECTION_RTL = TextServer::DIRECTION_RTL,
TEXT_DIRECTION_INHERITED = TextServer::DIRECTION_INHERITED,
};
private:
struct CComparator {
bool operator()(const Control *p_a, const Control *p_b) const {
if (p_a->get_canvas_layer() == p_b->get_canvas_layer()) {
return p_b->is_greater_than(p_a);
}
return p_a->get_canvas_layer() < p_b->get_canvas_layer();
}
};
// This Data struct is to avoid namespace pollution in derived classes.
struct Data {
bool initialized = false;
// Global relations.
List<Control *>::Element *RI = nullptr;
Control *parent_control = nullptr;
Window *parent_window = nullptr;
CanvasItem *parent_canvas_item = nullptr;
Callable forward_drag;
Callable forward_can_drop;
Callable forward_drop;
// Positioning and sizing.
LayoutMode stored_layout_mode = LayoutMode::LAYOUT_MODE_POSITION;
bool stored_use_custom_anchors = false;
real_t offset[4] = { 0.0, 0.0, 0.0, 0.0 };
real_t anchor[4] = { ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN };
FocusMode focus_mode = FOCUS_NONE;
GrowDirection h_grow = GROW_DIRECTION_END;
GrowDirection v_grow = GROW_DIRECTION_END;
real_t rotation = 0.0;
Vector2 scale = Vector2(1, 1);
Vector2 pivot_offset;
Point2 pos_cache;
Size2 size_cache;
Size2 minimum_size_cache;
bool minimum_size_valid = false;
Size2 last_minimum_size;
bool updating_last_minimum_size = false;
bool block_minimum_size_adjust = false;
bool size_warning = true;
// Container sizing.
BitField<SizeFlags> h_size_flags = SIZE_FILL;
BitField<SizeFlags> v_size_flags = SIZE_FILL;
real_t expand = 1.0;
Point2 custom_minimum_size;
// Input events and rendering.
MouseFilter mouse_filter = MOUSE_FILTER_STOP;
bool force_pass_scroll_events = true;
bool clip_contents = false;
bool disable_visibility_clip = false;
CursorShape default_cursor = CURSOR_ARROW;
// Focus.
NodePath focus_neighbor[4];
NodePath focus_next;
NodePath focus_prev;
ObjectID shortcut_context;
// Theming.
ThemeOwner *theme_owner = nullptr;
Ref<Theme> theme;
StringName theme_type_variation;
bool bulk_theme_override = false;
Theme::ThemeIconMap theme_icon_override;
Theme::ThemeStyleMap theme_style_override;
Theme::ThemeFontMap theme_font_override;
Theme::ThemeFontSizeMap theme_font_size_override;
Theme::ThemeColorMap theme_color_override;
Theme::ThemeConstantMap theme_constant_override;
mutable HashMap<StringName, Theme::ThemeIconMap> theme_icon_cache;
mutable HashMap<StringName, Theme::ThemeStyleMap> theme_style_cache;
mutable HashMap<StringName, Theme::ThemeFontMap> theme_font_cache;
mutable HashMap<StringName, Theme::ThemeFontSizeMap> theme_font_size_cache;
mutable HashMap<StringName, Theme::ThemeColorMap> theme_color_cache;
mutable HashMap<StringName, Theme::ThemeConstantMap> theme_constant_cache;
// Internationalization.
LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;
bool is_rtl_dirty = true;
bool is_rtl = false;
bool localize_numeral_system = true;
// Extra properties.
String tooltip;
AutoTranslateMode tooltip_auto_translate_mode = AUTO_TRANSLATE_MODE_INHERIT;
} data;
// Dynamic properties.
static constexpr unsigned properties_managed_by_container_count = 12;
static String properties_managed_by_container[properties_managed_by_container_count];
// Global relations.
friend class Viewport;
// Positioning and sizing.
void _update_canvas_item_transform();
Transform2D _get_internal_transform() const;
void _set_anchor(Side p_side, real_t p_anchor);
void _set_position(const Point2 &p_point);
void _set_global_position(const Point2 &p_point);
void _set_size(const Size2 &p_size);
void _compute_offsets(Rect2 p_rect, const real_t p_anchors[4], real_t (&r_offsets)[4]);
void _compute_anchors(Rect2 p_rect, const real_t p_offsets[4], real_t (&r_anchors)[4]);
void _set_layout_mode(LayoutMode p_mode);
void _update_layout_mode();
LayoutMode _get_layout_mode() const;
LayoutMode _get_default_layout_mode() const;
void _set_anchors_layout_preset(int p_preset);
int _get_anchors_layout_preset() const;
void _update_minimum_size_cache();
void _update_minimum_size();
void _size_changed();
void _top_level_changed() override {} // Controls don't need to do anything, only other CanvasItems.
void _top_level_changed_on_parent() override;
void _clear_size_warning();
// Input events.
void _call_gui_input(const Ref<InputEvent> &p_event);
// Focus.
void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, real_t p_min, real_t &r_closest_dist, Control **r_closest);
Control *_get_focus_neighbor(Side p_side, int p_count = 0);
// Theming.
void _theme_changed();
void _notify_theme_override_changed();
void _invalidate_theme_cache();
// Extra properties.
static int root_layout_direction;
String get_tooltip_text() const;
protected:
// Dynamic properties.
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _validate_property(PropertyInfo &p_property) const;
bool _property_can_revert(const StringName &p_name) const;
| |
125681
|
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
// Theming.
virtual void _update_theme_item_cache();
// Internationalization.
virtual TypedArray<Vector3i> structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
// Base object overrides.
void _notification(int p_notification);
static void _bind_methods();
// Exposed virtual methods.
GDVIRTUAL1RC(bool, _has_point, Vector2)
GDVIRTUAL2RC(TypedArray<Vector3i>, _structured_text_parser, Array, String)
GDVIRTUAL0RC(Vector2, _get_minimum_size)
GDVIRTUAL1RC(String, _get_tooltip, Vector2)
GDVIRTUAL1R(Variant, _get_drag_data, Vector2)
GDVIRTUAL2RC(bool, _can_drop_data, Vector2, Variant)
GDVIRTUAL2(_drop_data, Vector2, Variant)
GDVIRTUAL1RC(Object *, _make_custom_tooltip, String)
GDVIRTUAL1(_gui_input, Ref<InputEvent>)
public:
enum {
NOTIFICATION_RESIZED = 40,
NOTIFICATION_MOUSE_ENTER = 41,
NOTIFICATION_MOUSE_EXIT = 42,
NOTIFICATION_FOCUS_ENTER = 43,
NOTIFICATION_FOCUS_EXIT = 44,
NOTIFICATION_THEME_CHANGED = 45,
NOTIFICATION_SCROLL_BEGIN = 47,
NOTIFICATION_SCROLL_END = 48,
NOTIFICATION_LAYOUT_DIRECTION_CHANGED = 49,
NOTIFICATION_MOUSE_ENTER_SELF = 60,
NOTIFICATION_MOUSE_EXIT_SELF = 61,
};
// Editor plugin interoperability.
// TODO: Decouple controls from their editor plugin and get rid of this.
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;
virtual void _edit_set_position(const Point2 &p_position) override;
virtual Point2 _edit_get_position() const override;
virtual void _edit_set_scale(const Size2 &p_scale) override;
virtual Size2 _edit_get_scale() const override;
virtual void _edit_set_rect(const Rect2 &p_edit_rect) override;
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
virtual void _edit_set_rotation(real_t p_rotation) override;
virtual real_t _edit_get_rotation() const override;
virtual bool _edit_use_rotation() const override;
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
virtual Size2 _edit_get_minimum_size() const override;
#endif
virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override;
// Editor integration.
static void set_root_layout_direction(int p_root_dir);
PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
virtual bool is_text_field() const;
// Global relations.
bool is_top_level_control() const;
Control *get_parent_control() const;
Window *get_parent_window() const;
Control *get_root_parent_control() const;
Size2 get_parent_area_size() const;
Rect2 get_parent_anchorable_rect() const;
// Positioning and sizing.
virtual Transform2D get_transform() const override;
void set_anchor(Side p_side, real_t p_anchor, bool p_keep_offset = true, bool p_push_opposite_anchor = true);
real_t get_anchor(Side p_side) const;
void set_offset(Side p_side, real_t p_value);
real_t get_offset(Side p_side) const;
void set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos, bool p_push_opposite_anchor = true);
// TODO: Rename to set_begin/end_offsets ?
void set_begin(const Point2 &p_point);
Point2 get_begin() const;
void set_end(const Point2 &p_point);
Point2 get_end() const;
void set_h_grow_direction(GrowDirection p_direction);
GrowDirection get_h_grow_direction() const;
void set_v_grow_direction(GrowDirection p_direction);
GrowDirection get_v_grow_direction() const;
void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true);
void set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
void set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0);
void set_grow_direction_preset(LayoutPreset p_preset);
void set_position(const Point2 &p_point, bool p_keep_offsets = false);
void set_global_position(const Point2 &p_point, bool p_keep_offsets = false);
Point2 get_position() const;
Point2 get_global_position() const;
Point2 get_screen_position() const;
void set_size(const Size2 &p_size, bool p_keep_offsets = false);
Size2 get_size() const;
void reset_size();
void set_rect(const Rect2 &p_rect); // Reset anchors to begin and set rect, for faster container children sorting.
Rect2 get_rect() const;
Rect2 get_global_rect() const;
Rect2 get_screen_rect() const;
Rect2 get_anchorable_rect() const override;
void set_scale(const Vector2 &p_scale);
Vector2 get_scale() const;
void set_rotation(real_t p_radians);
void set_rotation_degrees(real_t p_degrees);
real_t get_rotation() const;
real_t get_rotation_degrees() const;
void set_pivot_offset(const Vector2 &p_pivot);
Vector2 get_pivot_offset() const;
void update_minimum_size();
void set_block_minimum_size_adjust(bool p_block);
virtual Size2 get_minimum_size() const;
virtual Size2 get_combined_minimum_size() const;
void set_custom_minimum_size(const Size2 &p_custom);
Size2 get_custom_minimum_size() const;
// Container sizing.
void set_h_size_flags(BitField<SizeFlags> p_flags);
BitField<SizeFlags> get_h_size_flags() const;
void set_v_size_flags(BitField<SizeFlags> p_flags);
BitField<SizeFlags> get_v_size_flags() const;
void set_stretch_ratio(real_t p_ratio);
real_t get_stretch_ratio() const;
// Input events.
virtual void gui_input(const Ref<InputEvent> &p_event);
void accept_event();
virtual bool has_point(const Point2 &p_point) const;
void set_mouse_filter(MouseFilter p_filter);
MouseFilter get_mouse_filter() const;
void set_force_pass_scroll_events(bool p_force_pass_scroll_events);
bool is_force_pass_scroll_events() const;
void warp_mouse(const Point2 &p_position);
bool is_focus_owner_in_shortcut_context() const;
void set_shortcut_context(const Node *p_node);
Node *get_shortcut_context() const;
// Drag and drop handling.
virtual void set_drag_forwarding(const Callable &p_drag, const Callable &p_can_drop, const Callable &p_drop);
virtual Variant get_drag_data(const Point2 &p_point);
virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
virtual void drop_data(const Point2 &p_point, const Variant &p_data);
void set_drag_preview(Control *p_control);
void force_drag(const Variant &p_data, Control *p_control);
bool is_drag_successful() const;
// Focus.
void set_focus_mode(FocusMode p_focus_mode);
FocusMode get_focus_mode() const;
bool has_focus() const;
void grab_focus();
void grab_click_focus();
void release_focus();
Control *find_next_valid_focus() const;
Control *find_prev_valid_focus() const;
Control *find_valid_focus_neighbor(Side p_size) const;
void set_focus_neighbor(Side p_side, const NodePath &p_neighbor);
NodePath get_focus_neighbor(Side p_side) const;
void set_focus_next(const NodePath &p_next);
NodePath get_focus_next() const;
void set_focus_previous(const NodePath &p_prev);
NodePath get_focus_previous() const;
// Rendering.
void set_default_cursor_shape(CursorShape p_shape);
CursorShape get_default_cursor_shape() const;
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
void set_clip_contents(bool p_clip);
bool is_clipping_contents();
void set_disable_visibility_clip(bool p_ignore);
bool is_visibility_clip_disabled() const;
// Theming.
void set_theme_owner_node(Node *p_node);
Node *get_theme_owner_node() const;
bool has_theme_owner_node() const;
void set_theme_context(ThemeContext *p_context, bool p_propagate = true);
void set_theme(const Ref<Theme> &p_theme);
Ref<Theme> get_theme() const;
void set_theme_type_variation(const StringName &p_theme_type);
StringName get_theme_type_variation() const;
void begin_bulk_theme_override();
void end_bulk_theme_override();
void add_theme_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon);
| |
125682
|
void add_theme_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
void add_theme_font_override(const StringName &p_name, const Ref<Font> &p_font);
void add_theme_font_size_override(const StringName &p_name, int p_font_size);
void add_theme_color_override(const StringName &p_name, const Color &p_color);
void add_theme_constant_override(const StringName &p_name, int p_constant);
void remove_theme_icon_override(const StringName &p_name);
void remove_theme_style_override(const StringName &p_name);
void remove_theme_font_override(const StringName &p_name);
void remove_theme_font_size_override(const StringName &p_name);
void remove_theme_color_override(const StringName &p_name);
void remove_theme_constant_override(const StringName &p_name);
Ref<Texture2D> get_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
Ref<StyleBox> get_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
Ref<Font> get_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
Variant get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type = StringName()) const;
#ifdef TOOLS_ENABLED
Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const;
#endif
bool has_theme_icon_override(const StringName &p_name) const;
bool has_theme_stylebox_override(const StringName &p_name) const;
bool has_theme_font_override(const StringName &p_name) const;
bool has_theme_font_size_override(const StringName &p_name) const;
bool has_theme_color_override(const StringName &p_name) const;
bool has_theme_constant_override(const StringName &p_name) const;
bool has_theme_icon(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
bool has_theme_stylebox(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
bool has_theme_font(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
bool has_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
bool has_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
bool has_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
float get_theme_default_base_scale() const;
Ref<Font> get_theme_default_font() const;
int get_theme_default_font_size() const;
// Internationalization.
void set_layout_direction(LayoutDirection p_direction);
LayoutDirection get_layout_direction() const;
virtual bool is_layout_rtl() const;
void set_localize_numeral_system(bool p_enable);
bool is_localizing_numeral_system() const;
#ifndef DISABLE_DEPRECATED
void set_auto_translate(bool p_enable);
bool is_auto_translating() const;
#endif
void set_tooltip_auto_translate_mode(AutoTranslateMode p_mode);
AutoTranslateMode get_tooltip_auto_translate_mode() const;
// Extra properties.
void set_tooltip_text(const String &text);
virtual String get_tooltip(const Point2 &p_pos) const;
virtual Control *make_custom_tooltip(const String &p_text) const;
Control();
~Control();
};
VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_BITFIELD_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape);
VARIANT_ENUM_CAST(Control::LayoutPreset);
VARIANT_ENUM_CAST(Control::LayoutPresetMode);
VARIANT_ENUM_CAST(Control::MouseFilter);
VARIANT_ENUM_CAST(Control::GrowDirection);
VARIANT_ENUM_CAST(Control::Anchor);
VARIANT_ENUM_CAST(Control::LayoutMode);
VARIANT_ENUM_CAST(Control::LayoutDirection);
VARIANT_ENUM_CAST(Control::TextDirection);
// G = get_drag_data_fw, C = can_drop_data_fw, D = drop_data_fw, U = underscore
#define SET_DRAG_FORWARDING_CD(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
#define SET_DRAG_FORWARDING_CDU(from, to) from->set_drag_forwarding(Callable(), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));
#define SET_DRAG_FORWARDING_GCD(from, to) from->set_drag_forwarding(callable_mp(this, &to::get_drag_data_fw).bind(from), callable_mp(this, &to::can_drop_data_fw).bind(from), callable_mp(this, &to::drop_data_fw).bind(from));
#define SET_DRAG_FORWARDING_GCDU(from, to) from->set_drag_forwarding(callable_mp(this, &to::_get_drag_data_fw).bind(from), callable_mp(this, &to::_can_drop_data_fw).bind(from), callable_mp(this, &to::_drop_data_fw).bind(from));
#endif // CONTROL_H
| |
125780
|
GDVIRTUAL0(_enter_tree)
GDVIRTUAL0(_exit_tree)
GDVIRTUAL0(_ready)
GDVIRTUAL0RC(Vector<String>, _get_configuration_warnings)
GDVIRTUAL1(_input, Ref<InputEvent>)
GDVIRTUAL1(_shortcut_input, Ref<InputEvent>)
GDVIRTUAL1(_unhandled_input, Ref<InputEvent>)
GDVIRTUAL1(_unhandled_key_input, Ref<InputEvent>)
public:
enum {
// You can make your own, but don't use the same numbers as other notifications in other nodes.
NOTIFICATION_ENTER_TREE = 10,
NOTIFICATION_EXIT_TREE = 11,
NOTIFICATION_MOVED_IN_PARENT = 12,
NOTIFICATION_READY = 13,
NOTIFICATION_PAUSED = 14,
NOTIFICATION_UNPAUSED = 15,
NOTIFICATION_PHYSICS_PROCESS = 16,
NOTIFICATION_PROCESS = 17,
NOTIFICATION_PARENTED = 18,
NOTIFICATION_UNPARENTED = 19,
NOTIFICATION_SCENE_INSTANTIATED = 20,
NOTIFICATION_DRAG_BEGIN = 21,
NOTIFICATION_DRAG_END = 22,
NOTIFICATION_PATH_RENAMED = 23,
NOTIFICATION_CHILD_ORDER_CHANGED = 24,
NOTIFICATION_INTERNAL_PROCESS = 25,
NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26,
NOTIFICATION_POST_ENTER_TREE = 27,
NOTIFICATION_DISABLED = 28,
NOTIFICATION_ENABLED = 29,
NOTIFICATION_RESET_PHYSICS_INTERPOLATION = 2001, // A GodotSpace Odyssey.
// Keep these linked to Node.
NOTIFICATION_WM_MOUSE_ENTER = 1002,
NOTIFICATION_WM_MOUSE_EXIT = 1003,
NOTIFICATION_WM_WINDOW_FOCUS_IN = 1004,
NOTIFICATION_WM_WINDOW_FOCUS_OUT = 1005,
NOTIFICATION_WM_CLOSE_REQUEST = 1006,
NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
NOTIFICATION_WM_SIZE_CHANGED = 1008,
NOTIFICATION_WM_DPI_CHANGE = 1009,
NOTIFICATION_VP_MOUSE_ENTER = 1010,
NOTIFICATION_VP_MOUSE_EXIT = 1011,
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
NOTIFICATION_WM_ABOUT = MainLoop::NOTIFICATION_WM_ABOUT,
NOTIFICATION_CRASH = MainLoop::NOTIFICATION_CRASH,
NOTIFICATION_OS_IME_UPDATE = MainLoop::NOTIFICATION_OS_IME_UPDATE,
NOTIFICATION_APPLICATION_RESUMED = MainLoop::NOTIFICATION_APPLICATION_RESUMED,
NOTIFICATION_APPLICATION_PAUSED = MainLoop::NOTIFICATION_APPLICATION_PAUSED,
NOTIFICATION_APPLICATION_FOCUS_IN = MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN,
NOTIFICATION_APPLICATION_FOCUS_OUT = MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT,
NOTIFICATION_TEXT_SERVER_CHANGED = MainLoop::NOTIFICATION_TEXT_SERVER_CHANGED,
// Editor specific node notifications
NOTIFICATION_EDITOR_PRE_SAVE = 9001,
NOTIFICATION_EDITOR_POST_SAVE = 9002,
};
/* NODE/TREE */
StringName get_name() const;
String get_description() const;
void set_name(const String &p_name);
InternalMode get_internal_mode() const;
void add_child(Node *p_child, bool p_force_readable_name = false, InternalMode p_internal = INTERNAL_MODE_DISABLED);
void add_sibling(Node *p_sibling, bool p_force_readable_name = false);
void remove_child(Node *p_child);
int get_child_count(bool p_include_internal = true) const;
Node *get_child(int p_index, bool p_include_internal = true) const;
TypedArray<Node> get_children(bool p_include_internal = true) const;
bool has_node(const NodePath &p_path) const;
Node *get_node(const NodePath &p_path) const;
Node *get_node_or_null(const NodePath &p_path) const;
Node *find_child(const String &p_pattern, bool p_recursive = true, bool p_owned = true) const;
TypedArray<Node> find_children(const String &p_pattern, const String &p_type = "", bool p_recursive = true, bool p_owned = true) const;
bool has_node_and_resource(const NodePath &p_path) const;
Node *get_node_and_resource(const NodePath &p_path, Ref<Resource> &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property = true) const;
virtual void reparent(Node *p_parent, bool p_keep_global_transform = true);
Node *get_parent() const;
Node *find_parent(const String &p_pattern) const;
Window *get_window() const;
Window *get_last_exclusive_window() const;
_FORCE_INLINE_ SceneTree *get_tree() const {
ERR_FAIL_NULL_V(data.tree, nullptr);
return data.tree;
}
_FORCE_INLINE_ bool is_inside_tree() const { return data.inside_tree; }
bool is_ancestor_of(const Node *p_node) const;
bool is_greater_than(const Node *p_node) const;
NodePath get_path() const;
NodePath get_path_to(const Node *p_node, bool p_use_unique_path = false) const;
Node *find_common_parent_with(const Node *p_node) const;
void add_to_group(const StringName &p_identifier, bool p_persistent = false);
void remove_from_group(const StringName &p_identifier);
bool is_in_group(const StringName &p_identifier) const;
struct GroupInfo {
StringName name;
bool persistent = false;
};
void get_groups(List<GroupInfo> *p_groups) const;
int get_persistent_group_count() const;
void move_child(Node *p_child, int p_index);
void _move_child(Node *p_child, int p_index, bool p_ignore_end = false);
void set_owner(Node *p_owner);
Node *get_owner() const;
void get_owned_by(Node *p_by, List<Node *> *p_owned);
void set_unique_name_in_owner(bool p_enabled);
bool is_unique_name_in_owner() const;
_FORCE_INLINE_ int get_index(bool p_include_internal = true) const {
// p_include_internal = false doesn't make sense if the node is internal.
ERR_FAIL_COND_V_MSG(!p_include_internal && data.internal_mode != INTERNAL_MODE_DISABLED, -1, "Node is internal. Can't get index with 'include_internal' being false.");
if (!data.parent) {
return data.index;
}
data.parent->_update_children_cache();
if (!p_include_internal) {
return data.index;
} else {
switch (data.internal_mode) {
case INTERNAL_MODE_DISABLED: {
return data.parent->data.internal_children_front_count_cache + data.index;
} break;
case INTERNAL_MODE_FRONT: {
return data.index;
} break;
case INTERNAL_MODE_BACK: {
return data.parent->data.internal_children_front_count_cache + data.parent->data.external_children_count_cache + data.index;
} break;
}
return -1;
}
}
Ref<Tween> create_tween();
void print_tree();
void print_tree_pretty();
String get_tree_string();
String get_tree_string_pretty();
void set_scene_file_path(const String &p_scene_file_path);
String get_scene_file_path() const;
void set_editor_description(const String &p_editor_description);
String get_editor_description() const;
void set_editable_instance(Node *p_node, bool p_editable);
bool is_editable_instance(const Node *p_node) const;
Node *get_deepest_editable_node(Node *p_start_node) const;
#ifdef TOOLS_ENABLED
void set_property_pinned(const String &p_property, bool p_pinned);
bool is_property_pinned(const StringName &p_property) const;
virtual StringName get_property_store_alias(const StringName &p_property) const;
bool is_part_of_edited_scene() const;
#else
bool is_part_of_edited_scene() const { return false; }
#endif
| |
125786
|
public:
enum {
NOTIFICATION_TRANSFORM_CHANGED = 2000
};
enum GroupCallFlags {
GROUP_CALL_DEFAULT = 0,
GROUP_CALL_REVERSE = 1,
GROUP_CALL_DEFERRED = 2,
GROUP_CALL_UNIQUE = 4,
};
_FORCE_INLINE_ Window *get_root() const { return root; }
void call_group_flagsp(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, const Variant **p_args, int p_argcount);
void notify_group_flags(uint32_t p_call_flags, const StringName &p_group, int p_notification);
void set_group_flags(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value);
// `notify_group()` is immediate by default since Godot 4.0.
void notify_group(const StringName &p_group, int p_notification);
// `set_group()` is immediate by default since Godot 4.0.
void set_group(const StringName &p_group, const String &p_name, const Variant &p_value);
template <typename... VarArgs>
// `call_group()` is immediate by default since Godot 4.0.
void call_group(const StringName &p_group, const StringName &p_function, VarArgs... p_args) {
Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
const Variant *argptrs[sizeof...(p_args) + 1];
for (uint32_t i = 0; i < sizeof...(p_args); i++) {
argptrs[i] = &args[i];
}
call_group_flagsp(GROUP_CALL_DEFAULT, p_group, p_function, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
}
template <typename... VarArgs>
void call_group_flags(uint32_t p_flags, const StringName &p_group, const StringName &p_function, VarArgs... p_args) {
Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
const Variant *argptrs[sizeof...(p_args) + 1];
for (uint32_t i = 0; i < sizeof...(p_args); i++) {
argptrs[i] = &args[i];
}
call_group_flagsp(p_flags, p_group, p_function, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
}
void flush_transform_notifications();
virtual void initialize() override;
virtual void iteration_prepare() override;
virtual bool physics_process(double p_time) override;
virtual void iteration_end() override;
virtual bool process(double p_time) override;
virtual void finalize() override;
bool is_auto_accept_quit() const;
void set_auto_accept_quit(bool p_enable);
bool is_quit_on_go_back() const;
void set_quit_on_go_back(bool p_enable);
void quit(int p_exit_code = EXIT_SUCCESS);
_FORCE_INLINE_ double get_physics_process_time() const { return physics_process_time; }
_FORCE_INLINE_ double get_process_time() const { return process_time; }
void set_pause(bool p_enabled);
bool is_paused() const;
#ifdef DEBUG_ENABLED
void set_debug_collisions_hint(bool p_enabled);
bool is_debugging_collisions_hint() const;
void set_debug_paths_hint(bool p_enabled);
bool is_debugging_paths_hint() const;
void set_debug_navigation_hint(bool p_enabled);
bool is_debugging_navigation_hint() const;
#else
void set_debug_collisions_hint(bool p_enabled) {}
bool is_debugging_collisions_hint() const { return false; }
void set_debug_paths_hint(bool p_enabled) {}
bool is_debugging_paths_hint() const { return false; }
void set_debug_navigation_hint(bool p_enabled) {}
bool is_debugging_navigation_hint() const { return false; }
#endif
void set_debug_collisions_color(const Color &p_color);
Color get_debug_collisions_color() const;
void set_debug_collision_contact_color(const Color &p_color);
Color get_debug_collision_contact_color() const;
void set_debug_paths_color(const Color &p_color);
Color get_debug_paths_color() const;
void set_debug_paths_width(float p_width);
float get_debug_paths_width() const;
Ref<Material> get_debug_paths_material();
Ref<Material> get_debug_collision_material();
Ref<ArrayMesh> get_debug_contact_mesh();
int get_collision_debug_contact_count() { return collision_debug_contacts; }
int64_t get_frame() const;
int get_node_count() const;
void queue_delete(Object *p_object);
void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
Node *get_first_node_in_group(const StringName &p_group);
bool has_group(const StringName &p_identifier) const;
int get_node_count_in_group(const StringName &p_group) const;
//void change_scene(const String& p_path);
//Node *get_loaded_scene();
void set_edited_scene_root(Node *p_node);
Node *get_edited_scene_root() const;
void set_current_scene(Node *p_scene);
Node *get_current_scene() const;
Error change_scene_to_file(const String &p_path);
Error change_scene_to_packed(const Ref<PackedScene> &p_scene);
Error reload_current_scene();
void unload_current_scene();
Ref<SceneTreeTimer> create_timer(double p_delay_sec, bool p_process_always = true, bool p_process_in_physics = false, bool p_ignore_time_scale = false);
Ref<Tween> create_tween();
TypedArray<Tween> get_processed_tweens();
//used by Main::start, don't use otherwise
void add_current_scene(Node *p_current);
static SceneTree *get_singleton() { return singleton; }
#ifdef TOOLS_ENABLED
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
//network API
Ref<MultiplayerAPI> get_multiplayer(const NodePath &p_for_path = NodePath()) const;
void set_multiplayer(Ref<MultiplayerAPI> p_multiplayer, const NodePath &p_root_path = NodePath());
void set_multiplayer_poll_enabled(bool p_enabled);
bool is_multiplayer_poll_enabled() const;
static void add_idle_callback(IdleCallback p_callback);
void set_disable_node_threading(bool p_disable);
//default texture settings
void set_physics_interpolation_enabled(bool p_enabled);
bool is_physics_interpolation_enabled() const;
#ifndef _3D_DISABLED
void client_physics_interpolation_add_node_3d(SelfList<Node3D> *p_elem);
void client_physics_interpolation_remove_node_3d(SelfList<Node3D> *p_elem);
#endif
SceneTree();
~SceneTree();
};
VARIANT_ENUM_CAST(SceneTree::GroupCallFlags);
#endif // SCENE_TREE_H
| |
125798
|
/**************************************************************************/
/* camera_2d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CAMERA_2D_H
#define CAMERA_2D_H
#include "scene/2d/node_2d.h"
class Camera2D : public Node2D {
GDCLASS(Camera2D, Node2D);
public:
enum AnchorMode {
ANCHOR_MODE_FIXED_TOP_LEFT,
ANCHOR_MODE_DRAG_CENTER
};
enum Camera2DProcessCallback {
CAMERA2D_PROCESS_PHYSICS,
CAMERA2D_PROCESS_IDLE
};
protected:
Point2 camera_pos;
Point2 smoothed_camera_pos;
bool first = true;
bool just_exited_tree = false;
ObjectID custom_viewport_id; // to check validity
Viewport *custom_viewport = nullptr;
Viewport *viewport = nullptr;
StringName group_name;
StringName canvas_group_name;
RID canvas;
Vector2 offset;
Vector2 zoom = Vector2(1, 1);
Vector2 zoom_scale = Vector2(1, 1);
AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER;
bool ignore_rotation = true;
bool enabled = true;
real_t position_smoothing_speed = 5.0;
bool position_smoothing_enabled = false;
real_t camera_angle = 0.0;
real_t rotation_smoothing_speed = 5.0;
bool rotation_smoothing_enabled = false;
int limit[4];
bool limit_smoothing_enabled = false;
real_t drag_margin[4];
bool drag_horizontal_enabled = false;
bool drag_vertical_enabled = false;
real_t drag_horizontal_offset = 0.0;
real_t drag_vertical_offset = 0.0;
bool drag_horizontal_offset_changed = false;
bool drag_vertical_offset_changed = false;
Point2 camera_screen_center;
bool _is_editing_in_editor() const;
void _update_process_callback();
void _update_scroll();
#ifdef TOOLS_ENABLED
void _project_settings_changed();
#endif
void _make_current(Object *p_which);
void _reset_just_exited() { just_exited_tree = false; }
void _set_old_smoothing(real_t p_enable);
void _update_process_internal_for_smoothing();
bool screen_drawing_enabled = true;
bool limit_drawing_enabled = false;
bool margin_drawing_enabled = false;
Camera2DProcessCallback process_callback = CAMERA2D_PROCESS_IDLE;
struct InterpolationData {
Transform2D xform_curr;
Transform2D xform_prev;
uint32_t last_update_physics_tick = UINT32_MAX; // Ensure tick 0 is detected as a change.
} _interpolation_data;
void _ensure_update_interpolation_data();
Size2 _get_camera_screen_size() const;
protected:
virtual Transform2D get_camera_transform();
void _notification(int p_what);
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
public:
void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
void set_anchor_mode(AnchorMode p_anchor_mode);
AnchorMode get_anchor_mode() const;
void set_ignore_rotation(bool p_ignore);
bool is_ignoring_rotation() const;
void set_limit(Side p_side, int p_limit);
int get_limit(Side p_side) const;
void set_limit_smoothing_enabled(bool enable);
bool is_limit_smoothing_enabled() const;
void set_drag_horizontal_enabled(bool p_enabled);
bool is_drag_horizontal_enabled() const;
void set_drag_vertical_enabled(bool p_enabled);
bool is_drag_vertical_enabled() const;
void set_drag_margin(Side p_side, real_t p_drag_margin);
real_t get_drag_margin(Side p_side) const;
void set_drag_horizontal_offset(real_t p_offset);
real_t get_drag_horizontal_offset() const;
void set_drag_vertical_offset(real_t p_offset);
real_t get_drag_vertical_offset() const;
void set_position_smoothing_enabled(bool p_enabled);
bool is_position_smoothing_enabled() const;
void set_position_smoothing_speed(real_t p_speed);
real_t get_position_smoothing_speed() const;
void set_rotation_smoothing_speed(real_t p_speed);
real_t get_rotation_smoothing_speed() const;
void set_rotation_smoothing_enabled(bool p_enabled);
bool is_rotation_smoothing_enabled() const;
void set_process_callback(Camera2DProcessCallback p_mode);
Camera2DProcessCallback get_process_callback() const;
void set_enabled(bool p_enabled);
bool is_enabled() const;
void make_current();
void clear_current();
bool is_current() const;
void set_zoom(const Vector2 &p_zoom);
Vector2 get_zoom() const;
Point2 get_camera_screen_center() const;
void set_custom_viewport(Node *p_viewport);
Node *get_custom_viewport() const;
Vector2 get_camera_position() const;
void force_update_scroll();
void reset_smoothing();
void align();
void set_screen_drawing_enabled(bool enable);
bool is_screen_drawing_enabled() const;
void set_limit_drawing_enabled(bool enable);
bool is_limit_drawing_enabled() const;
void set_margin_drawing_enabled(bool enable);
bool is_margin_drawing_enabled() const;
Camera2D();
};
VARIANT_ENUM_CAST(Camera2D::AnchorMode);
VARIANT_ENUM_CAST(Camera2D::Camera2DProcessCallback);
#endif // CAMERA_2D_H
| |
125809
|
/**************************************************************************/
/* animated_sprite_2d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef ANIMATED_SPRITE_2D_H
#define ANIMATED_SPRITE_2D_H
#include "scene/2d/node_2d.h"
#include "scene/resources/sprite_frames.h"
class AnimatedSprite2D : public Node2D {
GDCLASS(AnimatedSprite2D, Node2D);
Ref<SpriteFrames> frames;
String autoplay;
bool playing = false;
StringName animation = "default";
int frame = 0;
float speed_scale = 1.0;
float custom_speed_scale = 1.0;
bool centered = true;
Point2 offset;
real_t frame_speed_scale = 1.0;
real_t frame_progress = 0.0;
bool hflip = false;
bool vflip = false;
void _res_changed();
double _get_frame_duration();
void _calc_frame_speed_scale();
void _stop_internal(bool p_reset);
Rect2 _get_rect() const;
protected:
#ifndef DISABLE_DEPRECATED
bool _set(const StringName &p_name, const Variant &p_value);
#endif
static void _bind_methods();
void _notification(int p_what);
void _validate_property(PropertyInfo &p_property) const;
public:
#ifdef TOOLS_ENABLED
virtual Dictionary _edit_get_state() const override;
virtual void _edit_set_state(const Dictionary &p_state) override;
virtual void _edit_set_pivot(const Point2 &p_pivot) override;
virtual Point2 _edit_get_pivot() const override;
virtual bool _edit_use_pivot() const override;
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_use_rect() const override;
#endif
virtual Rect2 get_anchorable_rect() const override;
void set_sprite_frames(const Ref<SpriteFrames> &p_frames);
Ref<SpriteFrames> get_sprite_frames() const;
void play(const StringName &p_name = StringName(), float p_custom_scale = 1.0, bool p_from_end = false);
void play_backwards(const StringName &p_name = StringName());
void pause();
void stop();
bool is_playing() const;
void set_animation(const StringName &p_name);
StringName get_animation() const;
void set_autoplay(const String &p_name);
String get_autoplay() const;
void set_frame(int p_frame);
int get_frame() const;
void set_frame_progress(real_t p_progress);
real_t get_frame_progress() const;
void set_frame_and_progress(int p_frame, real_t p_progress);
void set_speed_scale(float p_speed_scale);
float get_speed_scale() const;
float get_playing_speed() const;
void set_centered(bool p_center);
bool is_centered() const;
void set_offset(const Point2 &p_offset);
Point2 get_offset() const;
void set_flip_h(bool p_flip);
bool is_flipped_h() const;
void set_flip_v(bool p_flip);
bool is_flipped_v() const;
PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
AnimatedSprite2D();
};
#endif // ANIMATED_SPRITE_2D_H
| |
125832
|
/**************************************************************************/
/* collision_object_2d.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_OBJECT_2D_H
#define COLLISION_OBJECT_2D_H
#include "scene/2d/node_2d.h"
#include "scene/main/viewport.h"
#include "scene/resources/2d/shape_2d.h"
#include "servers/physics_server_2d.h"
class CollisionObject2D : public Node2D {
GDCLASS(CollisionObject2D, Node2D);
public:
enum DisableMode {
DISABLE_MODE_REMOVE,
DISABLE_MODE_MAKE_STATIC,
DISABLE_MODE_KEEP_ACTIVE,
};
private:
uint32_t collision_layer = 1;
uint32_t collision_mask = 1;
real_t collision_priority = 1.0;
bool area = false;
RID rid;
uint32_t callback_lock = 0;
bool pickable = false;
DisableMode disable_mode = DISABLE_MODE_REMOVE;
PhysicsServer2D::BodyMode body_mode = PhysicsServer2D::BODY_MODE_STATIC;
struct ShapeData {
ObjectID owner_id;
Transform2D xform;
struct Shape {
Ref<Shape2D> shape;
int index = 0;
};
Vector<Shape> shapes;
bool disabled = false;
bool one_way_collision = false;
real_t one_way_collision_margin = 0.0;
};
int total_subshapes = 0;
RBMap<uint32_t, ShapeData> shapes;
bool only_update_transform_changes = false; // This is used for sync to physics.
void _apply_disabled();
void _apply_enabled();
protected:
_FORCE_INLINE_ void lock_callback() { callback_lock++; }
_FORCE_INLINE_ void unlock_callback() {
ERR_FAIL_COND(callback_lock == 0);
callback_lock--;
}
CollisionObject2D(RID p_rid, bool p_area);
void _notification(int p_what);
static void _bind_methods();
void _update_pickable();
friend class Viewport;
void _input_event_call(Viewport *p_viewport, const Ref<InputEvent> &p_input_event, int p_shape);
void _mouse_enter();
void _mouse_exit();
void _mouse_shape_enter(int p_shape);
void _mouse_shape_exit(int p_shape);
void set_only_update_transform_changes(bool p_enable);
bool is_only_update_transform_changes_enabled() const;
void set_body_mode(PhysicsServer2D::BodyMode p_mode);
virtual void _space_changed(const RID &p_new_space);
GDVIRTUAL3(_input_event, Viewport *, Ref<InputEvent>, int)
GDVIRTUAL0(_mouse_enter)
GDVIRTUAL0(_mouse_exit)
GDVIRTUAL1(_mouse_shape_enter, int)
GDVIRTUAL1(_mouse_shape_exit, int)
public:
void set_collision_layer(uint32_t p_layer);
uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
void set_collision_layer_value(int p_layer_number, bool p_value);
bool get_collision_layer_value(int p_layer_number) const;
void set_collision_mask_value(int p_layer_number, bool p_value);
bool get_collision_mask_value(int p_layer_number) const;
void set_collision_priority(real_t p_priority);
real_t get_collision_priority() const;
void set_disable_mode(DisableMode p_mode);
DisableMode get_disable_mode() const;
uint32_t create_shape_owner(Object *p_owner);
void remove_shape_owner(uint32_t owner);
void get_shape_owners(List<uint32_t> *r_owners);
PackedInt32Array _get_shape_owners();
void shape_owner_set_transform(uint32_t p_owner, const Transform2D &p_transform);
Transform2D shape_owner_get_transform(uint32_t p_owner) const;
Object *shape_owner_get_owner(uint32_t p_owner) const;
void shape_owner_set_disabled(uint32_t p_owner, bool p_disabled);
bool is_shape_owner_disabled(uint32_t p_owner) const;
void shape_owner_set_one_way_collision(uint32_t p_owner, bool p_enable);
bool is_shape_owner_one_way_collision_enabled(uint32_t p_owner) const;
void shape_owner_set_one_way_collision_margin(uint32_t p_owner, real_t p_margin);
real_t get_shape_owner_one_way_collision_margin(uint32_t p_owner) const;
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
Ref<Shape2D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
void shape_owner_clear_shapes(uint32_t p_owner);
uint32_t shape_find_owner(int p_shape_index) const;
void set_pickable(bool p_enabled);
bool is_pickable() const;
PackedStringArray get_configuration_warnings() const override;
_FORCE_INLINE_ RID get_rid() const { return rid; }
CollisionObject2D();
~CollisionObject2D();
};
VARIANT_ENUM_CAST(CollisionObject2D::DisableMode);
#endif // COLLISION_OBJECT_2D_H
| |
125905
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CSGShape3D" inherits="GeometryInstance3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
The CSG base class.
</brief_description>
<description>
This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
[b]Performance:[/b] CSG nodes are only intended for prototyping as they have a significant CPU performance cost.
Consider baking final CSG operation results into static geometry that replaces the CSG nodes.
Individual CSG root node results can be baked to nodes with static resources with the editor menu that appears when a CSG root node is selected.
Individual CSG root nodes can also be baked to static resources with scripts by calling [method bake_static_mesh] for the visual mesh or [method bake_collision_shape] for the physics collision.
Entire scenes of CSG nodes can be baked to static geometry and exported with the editor gltf scene exporter.
</description>
<tutorials>
<link title="Prototyping levels with CSG">$DOCS_URL/tutorials/3d/csg_tools.html</link>
</tutorials>
<methods>
<method name="bake_collision_shape">
<return type="ConcavePolygonShape3D" />
<description>
Returns a baked physics [ConcavePolygonShape3D] of this node's CSG operation result. Returns an empty shape if the node is not a CSG root node or has no valid geometry.
[b]Performance:[/b] If the CSG operation results in a very detailed geometry with many faces physics performance will be very slow. Concave shapes should in general only be used for static level geometry and not with dynamic objects that are moving.
</description>
</method>
<method name="bake_static_mesh">
<return type="ArrayMesh" />
<description>
Returns a baked static [ArrayMesh] of this node's CSG operation result. Materials from involved CSG nodes are added as extra mesh surfaces. Returns an empty mesh if the node is not a CSG root node or has no valid geometry.
</description>
</method>
<method name="get_collision_layer_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_layer] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
<return type="bool" />
<param index="0" name="layer_number" type="int" />
<description>
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_meshes" qualifiers="const">
<return type="Array" />
<description>
Returns an [Array] with two elements, the first is the [Transform3D] of this node and the second is the root [Mesh] of this node. Only works when this node is the root shape.
</description>
</method>
<method name="is_root_shape" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if this is a root shape and is thus the object that is rendered.
</description>
</method>
<method name="set_collision_layer_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_layer], given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="set_collision_mask_value">
<return type="void" />
<param index="0" name="layer_number" type="int" />
<param index="1" name="value" type="bool" />
<description>
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
</description>
</method>
</methods>
<members>
<member name="calculate_tangents" type="bool" setter="set_calculate_tangents" getter="is_calculating_tangents" default="true">
Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this area is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this CSG shape scans for collisions. Only effective if [member use_collision] is [code]true[/code]. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member>
<member name="collision_priority" type="float" setter="set_collision_priority" getter="get_collision_priority" default="1.0">
The priority used to solve colliding when occurring penetration. Only effective if [member use_collision] is [code]true[/code]. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
</member>
<member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape3D.Operation" default="0">
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
</member>
<member name="snap" type="float" setter="set_snap" getter="get_snap" default="0.001">
Snap makes the mesh vertices snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust. The top-level CSG shape's snap value is used for the entire CSG tree.
</member>
<member name="use_collision" type="bool" setter="set_use_collision" getter="is_using_collision" default="false">
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also [member collision_mask] and [member collision_priority].
</member>
</members>
<constants>
<constant name="OPERATION_UNION" value="0" enum="Operation">
Geometry of both primitives is merged, intersecting geometry is removed.
</constant>
<constant name="OPERATION_INTERSECTION" value="1" enum="Operation">
Only intersecting geometry remains, the rest is removed.
</constant>
<constant name="OPERATION_SUBTRACTION" value="2" enum="Operation">
The second shape is subtracted from the first, leaving a dent with its shape.
</constant>
</constants>
</class>
| |
125906
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CSGMesh3D" inherits="CSGPrimitive3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A CSG Mesh shape that uses a mesh resource.
</brief_description>
<description>
This CSG node allows you to use any mesh resource as a CSG shape, provided it is closed, does not self-intersect, does not contain internal faces and has no edges that connect to more than two faces. See also [CSGPolygon3D] for drawing 2D extruded polygons to be used as CSG nodes.
[b]Note:[/b] CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a [MeshInstance3D] with a [PrimitiveMesh]. Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
</description>
<tutorials>
<link title="Prototyping levels with CSG">$DOCS_URL/tutorials/3d/csg_tools.html</link>
</tutorials>
<members>
<member name="material" type="Material" setter="set_material" getter="get_material">
The [Material] used in drawing the CSG shape.
</member>
<member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh">
The [Mesh] resource to use as a CSG shape.
[b]Note:[/b] When using an [ArrayMesh], all vertex attributes except [constant Mesh.ARRAY_VERTEX], [constant Mesh.ARRAY_NORMAL] and [constant Mesh.ARRAY_TEX_UV] are left unused. Only [constant Mesh.ARRAY_VERTEX] and [constant Mesh.ARRAY_TEX_UV] will be passed to the GPU.
[constant Mesh.ARRAY_NORMAL] is only used to determine which faces require the use of flat shading. By default, CSGMesh will ignore the mesh's vertex normals, recalculate them for each vertex and use a smooth shader. If a flat shader is required for a face, ensure that all vertex normals of the face are approximately equal.
</member>
</members>
</class>
| |
125967
|
# Basic GDScript module architecture
This provides some basic information in how GDScript is implemented and integrates with the rest of the engine. You can learn more about GDScript in the [documentation](https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/index.html). It describes the syntax and user facing systems and concepts, and can be used as a reference for what user expectations are.
## General design
GDScript is:
1. A [gradually typed](https://en.wikipedia.org/wiki/Gradual_typing) language. Type hints are optional and help with static analysis and performance. However, typed code must easily interoperate with untyped code.
2. A tightly designed language. Features are added because they are _needed_, and not because they can be added or are interesting to develop.
3. Primarily an interpreted scripting language: it is compiled to GDScript byte code and interpreted in a GDScript virtual machine. It is meant to be easy to use and develop gameplay in. It is not meant for CPU-intensive algorithms or data processing, and is not optimized for it. For that, [C#](https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html) or [GDExtension](https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/what_is_gdextension.html) may be used.
## Integration into Godot
GDScript is integrated into Godot as a module. Since modules are optional, this means that Godot may be built without GDScript and work perfectly fine without it!
The GDScript module interfaces with Godot's codebase by inheriting from the engine's scripting-related classes. New languages inherit from [`ScriptLanguage`](/core/object/script_language.h), and are registered in Godot's [`ScriptServer`](/core/object/script_language.h). Scripts, referring to a file containing code, are represented in the engine by the `Script` class. Instances of that script, which are used at runtime when actually executing the code, inherit from [`ScriptInstance`](/core/object/script_instance.h).
To access Godot's internal classes, GDScript uses [`ClassDB`](/core/object/class_db.h). `ClassDB` is where Godot registers classes, methods and properties that it wants exposed to its scripting system. This is how GDScript understands that `Node2D` is a class it can use, and that it has a `get_parent()` method.
[Built-in GDScript methods](https://docs.godotengine.org/en/latest/classes/class_@gdscript.html#methods) are defined and exported by [`GDScriptUtilityFunctions`](gdscript_utility_functions.h), whereas [global scope methods](https://docs.godotengine.org/en/latest/classes/class_%2540globalscope.html) are registered in [`Variant::_register_variant_utility_functions()`](/core/variant/variant_utility.cpp).
## Compilation
Scripts can be at different stages of compilation. The process isn't entirely linear, but consists of this general order: tokenizing, parsing, analyzing, and finally compiling. This process is the same for scripts in the editor and scripts in an exported game. Scripts are stored as text files in both cases, and the compilation process must happen in full before the bytecode can be passed to the virtual machine and run.
The main class of the GDScript module is the [`GDScript`](gdscript.h) class, which represents a class defined in GDScript. Each `.gd` file is called a _class file_ because it implicitly defines a class in GDScript, and thus results in an associated `GDScript` object. However, GDScript classes may define [_inner classes_](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#inner-classes), and those are also represented by further `GDScript` objects, even though they are not in files of their own.
The `GDScript` class contains all the information related to the corresponding GDScript class: its name and path, its members like variables, functions, symbols, signals, implicit methods like initializers, etc. This is the main class that the compilation step deals with.
A secondary class is `GDScriptInstance`, defined in the same file, containing _runtime_ information for an instance of a `GDScript`, and is more related to the execution of a script by the virtual machine.
### Loading source code
This mostly happens by calling `GDScript::load_source_code()` on a `GDScript` object. Parsing only requires a `String`, so it is entirely possible to parse a script without a `GDScript` object!
### Tokenizing (see [`GDScriptTokenizer`](gdscript_tokenizer.h))
Tokenizing is the process of converting the source code `String` into a sequence of tokens, which represent language constructs (such as `for` or `if`), identifiers, literals, etc. This happens almost exclusively during the parsing process, which asks for the next token in order to make sense of the source code. The tokenizer is only used outside of the parsing process in very rare exceptions.
### Parsing (see [`GDScriptParser`](gdscript_parser.h))
The parser takes a sequence of tokens and builds [the abstract syntax tree (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree) of the GDScript program. The AST is used in the analyzing and compilation steps, and the source code `String` and sequence of tokens are discarded. The AST-building process finds syntax errors in a GDScript program and reports them to the user.
The parser class also defines all the possible nodes of the AST as subtypes of `GDScriptParser::Node`, not to be confused with Godot's scene tree `Node`. For example, `GDScriptParser::IfNode` has two children nodes, one for the code in the `if` block, and one for the code in the `else` block. A `GDScriptParser::FunctionNode` contains children nodes for its name, parameters, return type, body, etc. The parser also defines typechecking data structures like `GDScriptParser::Datatype`.
The parser was [intentionally designed](https://godotengine.org/article/gdscript-progress-report-writing-new-parser/#less-lookahead) with a look-ahead of a single token. This means that the parser only has access to the current token and the previous token (or, if you prefer, the current token and the next token). This parsing limitation ensures that GDScript will remain syntactically simple and accessible, and that the parsing process cannot become overly complex.
| |
125968
|
### Analysis and typechecking (see [`GDScriptAnalyzer`](gdscript_analyzer.h))
The analyzer takes in the AST of a program and verifies that "everything checks out". For example, when analyzing a method call with three parameters, it will check whether the function definition also contains three parameters. If the code is typed, it will check that argument and parameter types are compatible.
There are two types of functions in the analyzer: `reduce` functions and `resolve` functions. Their parameters always include the AST node that they are attempting to reduce or resolve.
- The `reduce` functions work on GDScript expressions, which return values, and thus their main goal is to populate the `GDScriptParser::Datatype` of the underlying AST node. The datatype is then used to typecheck code that depends on this expression, and gives the compiler necessary information to generate appropriate, safe, and optimized bytecode.
For example, function calls are handled with `reduce_call()`, which must figure out what function is being called and check that the passed arguments match the function's parameters. The type of the underlying `CallNode` will be the return type of the function.
Another example is `reduce_identifier()`, which does _a lot_ of work: given the string of its `IdentifierNode`, it must figure out what that identifier refers to. It could be a local variable, class name, global or class function, function parameter, class or superclass member, or any number of other things. It has to check many different places to find this information!
A secondary goal of the `reduce` functions is to perform [constant folding](https://en.wikipedia.org/wiki/Constant_folding): to determine whether an expression is constant, and if it is, compute its _reduced value_ at this time so it does not need to be computed over and over at runtime!
- The resolve functions work on AST nodes that represent statements, and don't necessarily have values. Their goal is to do work related to program control flow, resolve their child AST nodes, deal with scoping, etc. One of the simplest examples is `resolve_if()`, which reduces the `if` condition, then resolves the `if` body and `else` body if it exists.
The `resolve_for()` function does more work than simply resolving its code block. With `for i in range(10)`, for example, it must also declare and type the new variable `i` within the scope of its code block, as well as make sure `range(10)` is iterable, among other things.
To understand classes and inheritance without introducing cyclic dependency problems that would come from immediate full class code analysis, the analyzer often asks only for class _interfaces_: it needs to know what member variables and methods exist as well as their types, but no more.
This is done through `resolve_class_interface()`, which populates `ClassNode`'s `Datatype` with that information. It first checks for superclass information with `resolve_class_inheritance()`, then populates its member information by calling `resolve_class_member()` on each member. Since this step is only about the class _interface_, methods are resolved with `resolve_function_signature()`, which gets all relevant typing information without resolving the function body!
The remaining steps of resolution, including member variable initialization code, method code, etc, can happen at a later time.
In fully untyped code, very little static analysis is possible. For example, the analyzer cannot know whether `my_var.some_member` exists when it does not know the type of `my_var`. Therefore, it cannot emit a warning or error because `some_member` _could_ exist - or it could not. The analyzer must trust the programmer. If an error does occur, it will be at runtime.
However, GDScript is gradually typed, so all of these analyses must work when parts of the code are typed and others untyped. Static analysis in a gradually typed language is a best-effort situation: suppose there is a typed variable `var x : int`, and an untyped `var y = "some string"`. We can obviously tell this isn't going to work, but the analyzer will accept the assignment `x = y` without warnings or errors: it only knows that `y` is untyped and can therefore be anything, including the `int` that `x` expects. It must once again trust the programmer to have written code that works. In this instance, the code will error at runtime.
In both these cases, the analyzer handles the uncertainty of untyped code by calling `mark_node_unsafe()` on the respective AST node. This means it didn't have enough information to know whether the code was fully safe or necessarily wrong. Lines with unsafe AST nodes are represented by gray line numbers in the GDScript editor. Green line numbers indicate a line of code without any unsafe nodes.
This analysis step is also where dependencies are introduced and that information stored for use later. If class `A` extends class `B` or contains a member with type `B` from some other script file, then the analyzer will attempt to load that second script. If `B` contains references to `A`, then a _cyclic_ dependency is introduced. This is OK in many cases, but impossible to resolve in others.
Clearly, the analyzer is where a lot of the "magic" happens! It determines what constitutes proper code that can actually be compiled, and provides as many safety guarantees as possible with the typing information it is provided with. The more typed the code, the safer and more optimized it will be!
#### Cyclic dependencies and member resolution
Cyclic dependencies from inheritance (`A extends B, B extends A`) are not supported in any programming language. Other cyclic dependencies are supported, such as `A extends B` and `B` uses, contains, or preloads, members of type `A`.
To see why cyclic dependencies are complicated, suppose there is one between classes `A <-> B`. Partially through the analysis of `A`, we will need information about `B`, and therefore trigger its analysis. However, the analysis of `B` will eventually need information from `A`, which is incomplete because we never finished analyzing it. This would result in members not being found when they actually exist!
GDScript supports cyclic dependencies due to a few features of the analyzer:
1. Class interface resolution: when analyzing code of class `A` that depends on some other class `B`, we don't need to resolve the _code_ of `B` (its member initializers, function code, etc). We only need to know what members and methods the class has, as well as their types. These are the only things one class can use to work with, or _interface_ with, another. Because of inheritance, a class's interface depends on its superclass as well, so recursive interface resolution is needed. More details can be found in `GDScriptAnalyzer::resolve_class_interface()`.
2. Out of order member resolution: the analyzer may not even need an entire class interface to be resolved in order to figure out a specific type! For example, if class `A` contains code that references `B.is_alive`, then the analyzer doesn't need to immediately resolve `B`'s entire interface. It may simply check whether `is_alive` exists in `B`, and reduce it for its type information, on-demand.
A fundamental cyclic dependency problem occurs when the types of two different member variables are mutually dependent. This is commonly checked by a pattern that declares a temporary datatype with `GDScriptParser::DataType resolving_datatype;`, followed by `resolving_datatype.kind = GDScriptParser::DataType::RESOLVING;`. If the analyzer attempts to resolve a member on-demand that is already tagged as resolving, then a cyclic dependency problem has been found and can be reported.
| |
125969
|
### Compiling (see [`GDScriptCompiler`](gdscript_compiler.h))
Compiling is the final step in making a GDScript executable in the [virtual machine](gdscript_vm.h) (VM). The compiler takes a `GDScript` object and an AST, and uses another class, [`GDScriptByteCodeGenerator`](gdscript_byte_codegen.h), to generate bytecode corresponding to the class. In doing this, it creates the objects that the VM understands how to run, like [`GDScriptFunction`](gdscript_function.h), and completes a few extra tasks needed for compilation, such as populating runtime class member information.
Importantly, the compilation process of a class, specifically the `GDScriptCompiler::_compile_class()` method, _cannot_ depend on information obtained by calling `GDScriptCompiler::_compile_class()` on another class, for the same cyclic dependency reasons explained in the previous section.
Any information that can only be obtained or populated during the compilation step, when `GDScript` objects become available, must be handled before `GDScriptCompiler::_compile_class()` is called. This process is centralized in `GDScriptCompiler::_prepare_compilation()` which works as the compile-time equivalent of `GDScriptAnalyzer::resolve_class_interface()`: it populates a `GDScript`'s "interface" exclusively with information from the analysis step, and without processing other external classes. This information may then be referenced by other classes without introducing problematic cycles.
The more typing information a GDScript has, the more optimized the compiled bytecode can be. For example, if `my_var` is untyped, the bytecode for `my_var.some_member` will need to go through several layers of indirection to figure out the type of `my_var` at runtime, and from there determine how to obtain `some_member`. This varies depending on whether `my_var` is a dictionary, a script, or a native class. If the type of `my_var` was known at compile time, the bytecode can directly call the type-specific method for obtaining a member.
Similar optimizations are possible for `my_var.some_func()`. With untyped GDScript, the VM will need to resolve `my_var`'s type at runtime, then, depending on the type, use different methods to resolve the function and call it. When the function is fully resolved during static analysis, native function pointers or GDScript function objects can be compiled into the bytecode and directly called by the VM, removing several layers of indirection.
Typed code is safer code and faster code!
## Loading scripts
GDScripts can be loaded in a couple of different ways. The main method, used almost everywhere in the engine, is to load scripts through the `ResourceLoader` singleton. In this way, GDScripts are resources like any others: `ResourceLoader::load()` will simply reroute to `ResourceFormatLoaderGDScript::load()`, found in `gdscript.h/cpp`(gdscript.h). This generates a GDScript object which is compiled and ready to use.
The other method is to manually load the source code, then pass it to a parser, then to an analyzer and then to a compiler. The previous approach does this behind the scenes, alongside some smart caching of scripts and other functionalities. It is used in the [GDScript test runner infrastructure](tests/gdscript_test_runner.h).
### Full and shallow scripts
The `ResourceFormatLoaderGDScript::load()` method simply calls `GDScriptCache::get_full_script()`. The [`GDScriptCache`](gdscript_cache.h) is, as it sounds, a cache for GDScripts. Its two main methods, `get_shallow_script()` and `get_full_script()`, get and cache, respectively, scripts that have been merely parsed, and scripts which have been statically analyzed and fully compiled. Another internal class, `GDScriptParserRef`, found in the same file, provides even more granularity over the different steps of the parsing process, and is used extensively in the analyzer.
Shallow, or "just parsed" scripts, provide information such as defined classes, class members, and so forth. This is sufficient for many purposes, like obtaining a class interface or checking whether a member exists on a specific class. Full scripts, on the other hand, have been analyzed and compiled and are ready to use.
The distinction between full and shallow scripts is very important, as shallow scripts cannot create cyclic dependency problems, whereas full scripts can. The analyzer, for example, never asks for full scripts. Choosing when to request a shallow vs a full script is an important but subtle decision.
In practice, full scripts are simply scripts where `GDScript::reload()` has been called. This critical function is the primary way in which scripts get compiled in Godot, and essentially does all the compilation steps covered so far in order. Whenever a script is loaded, or updated and reloaded in Godot, it will end up going through `GDScript::reload()`, except in very rare circumstances like the test runner. It is an excellent place to start reading and understanding the GDScript module!
## Special types of scripts
Certain types of GDScripts behave slightly differently. For example, autoloads are loaded with `ResourceLoader::load()` during `Main::start()`, very soon after Godot is launched. Many systems aren't initialized at that time, so error reporting is often significantly reduced and may not even show up in the editor.
Tool scripts, declared with the `@tool` annotation on a GDScript file, run in the editor itself as opposed to just when the game is launched. This leads to a significant increase in complexity, as many things that can be changed in the editor may affect a currently executing tool script.
## Other
There are many other classes in the GDScript module. Here is a brief overview of some of them:
- Declaration of GDScript warnings in [`GDScriptWarning`](gdscript_warning.h).
- [`GDScriptFunction`](gdscript_function.h), which represents an executable GDScript function. The relevant file contains both static as well as runtime information.
- The [virtual machine](gdscript_vm.cpp) is essentially defined as calling `GDScriptFunction::call()`.
- Editor-related functions can be found in parts of `GDScriptLanguage`, originally declared in [`gdscript.h`](gdscript.h) but defined in [`gdscript_editor.cpp`](gdscript_editor.cpp). Code highlighting can be found in [`GDScriptSyntaxHighlighter`](editor/gdscript_highlighter.h).
- GDScript decompilation is found in [`gdscript_disassembler.cpp`](gdscript_disassembler.h), defined as `GDScriptFunction::disassemble()`.
- Documentation generation from GDScript comments in [`GDScriptDocGen`](editor/gdscript_docgen.h)
| |
126018
|
class_name Utils
# `assert()` is not evaluated in non-debug builds. Do not use `assert()`
# for anything other than testing the `assert()` itself.
static func check(condition: Variant) -> void:
if not condition:
printerr("Check failed.")
static func get_type(property: Dictionary, is_return: bool = false) -> String:
match property.type:
TYPE_NIL:
if property.usage & PROPERTY_USAGE_NIL_IS_VARIANT:
return "Variant"
return "void" if is_return else "null"
TYPE_INT:
if property.usage & PROPERTY_USAGE_CLASS_IS_ENUM:
if property.class_name == &"":
return "<unknown enum>"
return property.class_name
TYPE_ARRAY:
if property.hint == PROPERTY_HINT_ARRAY_TYPE:
if str(property.hint_string).is_empty():
return "Array[<unknown type>]"
return "Array[%s]" % property.hint_string
TYPE_DICTIONARY:
if property.hint == PROPERTY_HINT_DICTIONARY_TYPE:
if str(property.hint_string).is_empty():
return "Dictionary[<unknown type>, <unknown type>]"
return "Dictionary[%s]" % str(property.hint_string).replace(";", ", ")
TYPE_OBJECT:
if not str(property.class_name).is_empty():
return property.class_name
return type_string(property.type)
static func get_property_signature(property: Dictionary, base: Object = null, is_static: bool = false) -> String:
if property.usage & PROPERTY_USAGE_CATEGORY:
return '@export_category("%s")' % str(property.name).c_escape()
if property.usage & PROPERTY_USAGE_GROUP:
return '@export_group("%s")' % str(property.name).c_escape()
if property.usage & PROPERTY_USAGE_SUBGROUP:
return '@export_subgroup("%s")' % str(property.name).c_escape()
var result: String = ""
if not (property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE):
printerr("Missing `PROPERTY_USAGE_SCRIPT_VARIABLE` flag.")
if is_static:
result += "static "
result += "var " + property.name + ": " + get_type(property)
if is_instance_valid(base):
result += " = " + var_to_str(base.get(property.name))
return result
static func get_human_readable_hint_string(property: Dictionary) -> String:
if property.type >= TYPE_ARRAY and property.hint == PROPERTY_HINT_TYPE_STRING:
var type_hint_prefixes: String = ""
var hint_string: String = property.hint_string
while true:
if not hint_string.contains(":"):
printerr("Invalid PROPERTY_HINT_TYPE_STRING format.")
var elem_type_hint: String = hint_string.get_slice(":", 0)
hint_string = hint_string.substr(elem_type_hint.length() + 1)
var elem_type: int
var elem_hint: int
if elem_type_hint.is_valid_int():
elem_type = elem_type_hint.to_int()
type_hint_prefixes += "<%s>:" % type_string(elem_type)
else:
if elem_type_hint.count("/") != 1:
printerr("Invalid PROPERTY_HINT_TYPE_STRING format.")
elem_type = elem_type_hint.get_slice("/", 0).to_int()
elem_hint = elem_type_hint.get_slice("/", 1).to_int()
type_hint_prefixes += "<%s>/<%s>:" % [
type_string(elem_type),
get_property_hint_name(elem_hint).trim_prefix("PROPERTY_HINT_"),
]
if elem_type < TYPE_ARRAY or hint_string.is_empty():
break
return type_hint_prefixes + hint_string
return property.hint_string
static func print_property_extended_info(property: Dictionary, base: Object = null, is_static: bool = false) -> void:
print(get_property_signature(property, base, is_static))
print(' hint=%s hint_string="%s" usage=%s class_name=&"%s"' % [
get_property_hint_name(property.hint).trim_prefix("PROPERTY_HINT_"),
get_human_readable_hint_string(property).c_escape(),
get_property_usage_string(property.usage).replace("PROPERTY_USAGE_", ""),
property.class_name.c_escape(),
])
static func get_method_signature(method: Dictionary, is_signal: bool = false) -> String:
var result: String = ""
if method.flags & METHOD_FLAG_STATIC:
result += "static "
result += ("signal " if is_signal else "func ") + method.name + "("
var args: Array[Dictionary] = method.args
var default_args: Array = method.default_args
var mandatory_argc: int = args.size() - default_args.size()
for i in args.size():
if i > 0:
result += ", "
var arg: Dictionary = args[i]
result += arg.name + ": " + get_type(arg)
if i >= mandatory_argc:
result += " = " + var_to_str(default_args[i - mandatory_argc])
result += ")"
if is_signal:
if get_type(method.return, true) != "void":
printerr("Signal return type must be `void`.")
else:
result += " -> " + get_type(method.return, true)
return result
static func get_property_hint_name(hint: PropertyHint) -> String:
match hint:
PROPERTY_HINT_NONE:
return "PROPERTY_HINT_NONE"
PROPERTY_HINT_RANGE:
return "PROPERTY_HINT_RANGE"
PROPERTY_HINT_ENUM:
return "PROPERTY_HINT_ENUM"
PROPERTY_HINT_ENUM_SUGGESTION:
return "PROPERTY_HINT_ENUM_SUGGESTION"
PROPERTY_HINT_EXP_EASING:
return "PROPERTY_HINT_EXP_EASING"
PROPERTY_HINT_LINK:
return "PROPERTY_HINT_LINK"
PROPERTY_HINT_FLAGS:
return "PROPERTY_HINT_FLAGS"
PROPERTY_HINT_LAYERS_2D_RENDER:
return "PROPERTY_HINT_LAYERS_2D_RENDER"
PROPERTY_HINT_LAYERS_2D_PHYSICS:
return "PROPERTY_HINT_LAYERS_2D_PHYSICS"
PROPERTY_HINT_LAYERS_2D_NAVIGATION:
return "PROPERTY_HINT_LAYERS_2D_NAVIGATION"
PROPERTY_HINT_LAYERS_3D_RENDER:
return "PROPERTY_HINT_LAYERS_3D_RENDER"
PROPERTY_HINT_LAYERS_3D_PHYSICS:
return "PROPERTY_HINT_LAYERS_3D_PHYSICS"
PROPERTY_HINT_LAYERS_3D_NAVIGATION:
return "PROPERTY_HINT_LAYERS_3D_NAVIGATION"
PROPERTY_HINT_LAYERS_AVOIDANCE:
return "PROPERTY_HINT_LAYERS_AVOIDANCE"
PROPERTY_HINT_FILE:
return "PROPERTY_HINT_FILE"
PROPERTY_HINT_DIR:
return "PROPERTY_HINT_DIR"
PROPERTY_HINT_GLOBAL_FILE:
return "PROPERTY_HINT_GLOBAL_FILE"
PROPERTY_HINT_GLOBAL_DIR:
return "PROPERTY_HINT_GLOBAL_DIR"
PROPERTY_HINT_RESOURCE_TYPE:
return "PROPERTY_HINT_RESOURCE_TYPE"
PROPERTY_HINT_MULTILINE_TEXT:
return "PROPERTY_HINT_MULTILINE_TEXT"
PROPERTY_HINT_EXPRESSION:
return "PROPERTY_HINT_EXPRESSION"
PROPERTY_HINT_PLACEHOLDER_TEXT:
return "PROPERTY_HINT_PLACEHOLDER_TEXT"
PROPERTY_HINT_COLOR_NO_ALPHA:
return "PROPERTY_HINT_COLOR_NO_ALPHA"
PROPERTY_HINT_OBJECT_ID:
return "PROPERTY_HINT_OBJECT_ID"
PROPERTY_HINT_TYPE_STRING:
return "PROPERTY_HINT_TYPE_STRING"
PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE:
return "PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE"
PROPERTY_HINT_OBJECT_TOO_BIG:
return "PROPERTY_HINT_OBJECT_TOO_BIG"
PROPERTY_HINT_NODE_PATH_VALID_TYPES:
return "PROPERTY_HINT_NODE_PATH_VALID_TYPES"
PROPERTY_HINT_SAVE_FILE:
return "PROPERTY_HINT_SAVE_FILE"
PROPERTY_HINT_GLOBAL_SAVE_FILE:
return "PROPERTY_HINT_GLOBAL_SAVE_FILE"
PROPERTY_HINT_INT_IS_OBJECTID:
return "PROPERTY_HINT_INT_IS_OBJECTID"
PROPERTY_HINT_INT_IS_POINTER:
return "PROPERTY_HINT_INT_IS_POINTER"
PROPERTY_HINT_ARRAY_TYPE:
return "PROPERTY_HINT_ARRAY_TYPE"
PROPERTY_HINT_DICTIONARY_TYPE:
return "PROPERTY_HINT_DICTIONARY_TYPE"
PROPERTY_HINT_LOCALE_ID:
return "PROPERTY_HINT_LOCALE_ID"
PROPERTY_HINT_LOCALIZABLE_STRING:
return "PROPERTY_HINT_LOCALIZABLE_STRING"
PROPERTY_HINT_NODE_TYPE:
return "PROPERTY_HINT_NODE_TYPE"
PROPERTY_HINT_HIDE_QUATERNION_EDIT:
return "PROPERTY_HINT_HIDE_QUATERNION_EDIT"
PROPERTY_HINT_PASSWORD:
return "PROPERTY_HINT_PASSWORD"
PROPERTY_HINT_TOOL_BUTTON:
return "PROPERTY_HINT_TOOL_BUTTON"
printerr("Argument `hint` is invalid. Use `PROPERTY_HINT_*` constants.")
return "<invalid hint>"
| |
126029
|
class_name TestMemberInfo
class MyClass:
pass
enum MyEnum {}
static var test_static_var_untyped
static var test_static_var_weak_null = null
static var test_static_var_weak_int = 1
static var test_static_var_hard_int: int
var test_var_untyped
var test_var_weak_null = null
var test_var_weak_int = 1
@export var test_var_weak_int_exported = 1
var test_var_weak_variant_type = TYPE_NIL
@export var test_var_weak_variant_type_exported = TYPE_NIL
var test_var_hard_variant: Variant
var test_var_hard_int: int
var test_var_hard_variant_type: Variant.Type
@export var test_var_hard_variant_type_exported: Variant.Type
var test_var_hard_node_process_mode: Node.ProcessMode
@warning_ignore("enum_variable_without_default")
var test_var_hard_my_enum: MyEnum
var test_var_hard_array: Array
var test_var_hard_array_int: Array[int]
var test_var_hard_array_variant_type: Array[Variant.Type]
var test_var_hard_array_node_process_mode: Array[Node.ProcessMode]
var test_var_hard_array_my_enum: Array[MyEnum]
var test_var_hard_array_resource: Array[Resource]
var test_var_hard_array_this: Array[TestMemberInfo]
var test_var_hard_array_my_class: Array[MyClass]
var test_var_hard_dictionary: Dictionary
var test_var_hard_dictionary_int_variant: Dictionary[int, Variant]
var test_var_hard_dictionary_variant_int: Dictionary[Variant, int]
var test_var_hard_dictionary_int_int: Dictionary[int, int]
var test_var_hard_dictionary_variant_type: Dictionary[Variant.Type, Variant.Type]
var test_var_hard_dictionary_node_process_mode: Dictionary[Node.ProcessMode, Node.ProcessMode]
var test_var_hard_dictionary_my_enum: Dictionary[MyEnum, MyEnum]
var test_var_hard_dictionary_resource: Dictionary[Resource, Resource]
var test_var_hard_dictionary_this: Dictionary[TestMemberInfo, TestMemberInfo]
var test_var_hard_dictionary_my_class: Dictionary[MyClass, MyClass]
var test_var_hard_resource: Resource
var test_var_hard_this: TestMemberInfo
var test_var_hard_my_class: MyClass
static func test_static_func(): pass
func test_func_implicit_void(): pass
func test_func_explicit_void() -> void: pass
func test_func_weak_null(): return null
func test_func_weak_int(): return 1
func test_func_hard_variant() -> Variant: return null
func test_func_hard_int() -> int: return 1
func test_func_args_1(_a: int, _b: Array[int], _c: Dictionary[int, int], _d: int = 1, _e = 2): pass
func test_func_args_2(_a = 1, _b = _a, _c = [2], _d = 3): pass
signal test_signal_1()
signal test_signal_2(a: Variant, b)
signal test_signal_3(a: int, b: Array[int], c: Dictionary[int, int])
signal test_signal_4(a: Variant.Type, b: Array[Variant.Type], c: Dictionary[Variant.Type, Variant.Type])
signal test_signal_5(a: MyEnum, b: Array[MyEnum], c: Dictionary[MyEnum, MyEnum])
signal test_signal_6(a: Resource, b: Array[Resource], c: Dictionary[Resource, Resource])
signal test_signal_7(a: TestMemberInfo, b: Array[TestMemberInfo], c: Dictionary[TestMemberInfo, TestMemberInfo])
signal test_signal_8(a: MyClass, b: Array[MyClass], c: Dictionary[MyClass, MyClass])
func no_exec():
test_signal_1.emit()
test_signal_2.emit()
test_signal_3.emit()
test_signal_4.emit()
test_signal_5.emit()
test_signal_6.emit()
test_signal_7.emit()
test_signal_8.emit()
func test():
var script: Script = get_script()
for property in script.get_property_list():
if str(property.name).begins_with("test_"):
print(Utils.get_property_signature(property, null, true))
for property in get_property_list():
if str(property.name).begins_with("test_"):
print(Utils.get_property_signature(property))
for method in get_method_list():
if str(method.name).begins_with("test_"):
print(Utils.get_method_signature(method))
for method in get_signal_list():
if str(method.name).begins_with("test_"):
print(Utils.get_method_signature(method, true))
| |
126045
|
func get_parse_string(t: Variant):
return t.parse_string
func test():
var a: Callable = JSON.parse_string
var b: Callable = get_parse_string(JSON)
prints(a.call("{\"test\": \"a\"}"), a.is_valid())
prints(b.call("{\"test\": \"b\"}"), b.is_valid())
| |
126078
|
# https://github.com/godotengine/godot/issues/72967
class CustomNode:
extends Node
static func test_custom_node(n: CustomNode):
if not n:
print("null node")
func test():
test_typed_argument_is_null()
func get_custom_node() -> CustomNode:
return null
func test_typed_argument_is_null():
var node: Node = Node.new()
print_node_name(node.get_parent())
node.free()
test_custom_node()
func test_custom_node():
CustomNode.test_custom_node(get_custom_node())
func print_node_name(n: Node):
if not n:
print("null node")
| |
126099
|
# https://github.com/godotengine/godot/issues/90086
class MyObj:
var obj : WeakRef
func test():
var obj_1 = MyObj.new()
var obj_2 = MyObj.new()
Utils.check(obj_2.get_reference_count() == 1)
obj_1.set(&"obj", obj_2)
Utils.check(obj_2.get_reference_count() == 1)
| |
126110
|
# https://github.com/godotengine/godot/issues/89439
signal my_signal
func foo():
print("Foo")
my_signal.emit()
func bar():
print("Bar")
func baz():
print("Baz")
func test():
@warning_ignore("return_value_discarded")
my_signal.connect(foo, CONNECT_ONE_SHOT)
@warning_ignore("return_value_discarded")
my_signal.connect(bar, CONNECT_ONE_SHOT)
@warning_ignore("return_value_discarded")
my_signal.connect(baz)
my_signal.emit()
| |
126177
|
extends Node
func my_func_1(_foo, _bar):
pass
func my_func_2(_foo, _bar, _baz):
pass
static func my_static_func_1(_foo, _bar):
pass
static func my_static_func_2(_foo, _bar, _baz):
pass
@rpc
func my_rpc_func_1(_foo, _bar):
pass
@rpc
func my_rpc_func_2(_foo, _bar, _baz):
pass
func test():
# Test built-in methods.
var builtin_callable_1 : Callable = add_to_group
print(builtin_callable_1.get_argument_count()) # Should print 2.
var builtin_callable_2 : Callable = find_child
print(builtin_callable_2.get_argument_count()) # Should print 3.
# Test built-in vararg methods.
var builtin_vararg_callable_1 : Callable = call_thread_safe
print(builtin_vararg_callable_1.get_argument_count()) # Should print 1.
var builtin_vararg_callable_2 : Callable = rpc_id
print(builtin_vararg_callable_2.get_argument_count()) # Should print 2.
# Test plain methods.
var callable_1 : Callable = my_func_1
print(callable_1.get_argument_count()) # Should print 2.
var callable_2 : Callable = my_func_2
print(callable_2.get_argument_count()) # Should print 3.
# Test static methods.
var static_callable_1 : Callable = my_static_func_1
print(static_callable_1.get_argument_count()) # Should print 2.
var static_callable_2 : Callable = my_static_func_2
print(static_callable_2.get_argument_count()) # Should print 3.
# Test rpc methods.
var rpc_callable_1 : Callable = my_rpc_func_1
print(rpc_callable_1.get_argument_count()) # Should print 2.
var rpc_callable_2 : Callable = my_rpc_func_2
print(rpc_callable_2.get_argument_count()) # Should print 3.
# Test lambdas.
var lambda_callable_1 : Callable = func(_foo, _bar): pass
print(lambda_callable_1.get_argument_count()) # Should print 2.
var lambda_callable_2 : Callable = func(_foo, _bar, _baz): pass
print(lambda_callable_2.get_argument_count()) # Should print 3.
# Test lambdas with self.
var lambda_self_callable_1 : Callable = func(_foo, _bar): return self
print(lambda_self_callable_1.get_argument_count()) # Should print 2.
var lambda_self_callable_2 : Callable = func(_foo, _bar, _baz): return self
print(lambda_self_callable_2.get_argument_count()) # Should print 3.
# Test bind.
var bind_callable_1 : Callable = my_func_2.bind(1)
print(bind_callable_1.get_argument_count()) # Should print 2.
var bind_callable_2 : Callable = my_func_2.bind(1, 2)
print(bind_callable_2.get_argument_count()) # Should print 1.
# Test unbind.
var unbind_callable_1 : Callable = my_func_2.unbind(1)
print(unbind_callable_1.get_argument_count()) # Should print 4.
var unbind_callable_2 : Callable = my_func_2.unbind(2)
print(unbind_callable_2.get_argument_count()) # Should print 5.
# Test variant callables.
var string_tmp := String()
var variant_callable_1 : Callable = string_tmp.replace
print(variant_callable_1.get_argument_count()) # Should print 2.
var variant_callable_2 : Callable = string_tmp.rsplit
print(variant_callable_2.get_argument_count()) # Should print 3.
# Test variant vararg callables.
var callable_tmp := Callable()
var variant_vararg_callable_1 : Callable = callable_tmp.call
print(variant_vararg_callable_1.get_argument_count()) # Should print 0.
var variant_vararg_callable_2 : Callable = callable_tmp.rpc_id
print(variant_vararg_callable_2.get_argument_count()) # Should print 1.
# Test global methods.
var global_callable_1 = is_equal_approx
print(global_callable_1.get_argument_count()) # Should print 2.
var global_callable_2 = inverse_lerp
print(global_callable_2.get_argument_count()) # Should print 3.
# Test GDScript methods.
var gdscript_callable_1 = char
print(gdscript_callable_1.get_argument_count()) # Should print 1.
var gdscript_callable_2 = is_instance_of
print(gdscript_callable_2.get_argument_count()) # Should print 2.
| |
126179
|
extends Node
func test() -> void:
var node1 := Node.new()
node1.name = "_"
var node2 := Node.new()
node2.name = "Child"
var node3 := Node.new()
node3.name = "Child"
add_child(node1)
node1.add_child(node2)
add_child(node3)
Utils.check(get_node("_/Child") == $_/Child)
| |
126180
|
# https://github.com/godotengine/godot/issues/75658
class MyObj:
var callable: Callable
func run():
callable.call()
var prop:
set(value):
callable.call()
get:
callable.call()
return 0
func _on_some_signal():
callable.call()
func _init(p_callable: Callable):
self.callable = p_callable
signal some_signal
var obj: MyObj
func test():
# Call.
obj = MyObj.new(nullify_obj)
obj.run()
print(obj)
# Get.
obj = MyObj.new(nullify_obj)
var _aux = obj.prop
print(obj)
# Set.
obj = MyObj.new(nullify_obj)
obj.prop = 1
print(obj)
# Signal handling.
obj = MyObj.new(nullify_obj)
@warning_ignore("return_value_discarded")
some_signal.connect(obj._on_some_signal)
some_signal.emit()
print(obj)
func nullify_obj():
obj = null
| |
126240
|
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR
>> on function: test()
>> runtime/errors/callable_call_after_free_object.gd
>> 6
>> Attempt to call function 'null::is_inside_tree (Callable)' on a null instance.
| |
126327
|
extends Node
class Inner1 extends Node:
# ^^^^^^ class1 -> class1
var member1 := 42
# ^^^^^^^ class1:member1 -> class1:member1
var member2 : int = 13
# ^^^^^^^ class1:member2 -> class1:member2
var member3 = 1337
# ^^^^^^^ class1:member3 -> class1:member3
signal changed(old, new)
# ^^^^^^^ class1:signal -> class1:signal
func my_func(arg1: int, arg2: String, arg3):
# | | | | | | ^^^^ class1:func:arg3 -> class1:func:arg3
# | | | | ^^^^ class1:func:arg2 -> class1:func:arg2
# | | ^^^^ class1:func:arg1 -> class1:func:arg1
# ^^^^^^^ class1:func -> class1:func
print(arg1, arg2, arg3)
# | | | | ^^^^ -> class1:func:arg3
# | | ^^^^ -> class1:func:arg2
# ^^^^ -> class1:func:arg1
changed.emit(arg1, arg3)
# | | | ^^^^ -> class1:func:arg3
# | ^^^^ -> class1:func:arg1
#<^^^^^ -> class1:signal
return arg1 + arg2.length() + arg3
# | | | | ^^^^ -> class1:func:arg3
# | | ^^^^ -> class1:func:arg2
# ^^^^ -> class1:func:arg1
class Inner2:
# ^^^^^^ class2 -> class2
var member1 := 42
# ^^^^^^^ class2:member1 -> class2:member1
var member2 : int = 13
# ^^^^^^^ class2:member2 -> class2:member2
var member3 = 1337
# ^^^^^^^ class2:member3 -> class2:member3
signal changed(old, new)
# ^^^^^^^ class2:signal -> class2:signal
func my_func(arg1: int, arg2: String, arg3):
# | | | | | | ^^^^ class2:func:arg3 -> class2:func:arg3
# | | | | ^^^^ class2:func:arg2 -> class2:func:arg2
# | | ^^^^ class2:func:arg1 -> class2:func:arg1
# ^^^^^^^ class2:func -> class2:func
print(arg1, arg2, arg3)
# | | | | ^^^^ -> class2:func:arg3
# | | ^^^^ -> class2:func:arg2
# ^^^^ -> class2:func:arg1
changed.emit(arg1, arg3)
# | | | ^^^^ -> class2:func:arg3
# | ^^^^ -> class2:func:arg1
#<^^^^^ -> class2:signal
return arg1 + arg2.length() + arg3
# | | | | ^^^^ -> class2:func:arg3
# | | ^^^^ -> class2:func:arg2
# ^^^^ -> class2:func:arg1
class Inner3 extends Inner2:
# | | ^^^^^^ -> class2
# ^^^^^^ class3 -> class3
var whatever = "foo"
# ^^^^^^^^ class3:whatever -> class3:whatever
func _init():
# ^^^^^ class3:init
# Note: no self-ref check here: resolves to `Object._init`.
# usages of `Inner3.new()` DO resolve to this `_init`
pass
class NestedInInner3:
# ^^^^^^^^^^^^^^ class3:nested1 -> class3:nested1
var some_value := 42
# ^^^^^^^^^^ class3:nested1:some_value -> class3:nested1:some_value
class AnotherNestedInInner3 extends NestedInInner3:
#! | | ^^^^^^^^^^^^^^ -> class3:nested1
# ^^^^^^^^^^^^^^^^^^^^^ class3:nested2 -> class3:nested2
var another_value := 13
# ^^^^^^^^^^^^^ class3:nested2:another_value -> class3:nested2:another_value
func _ready():
var inner1 = Inner1.new()
# | | ^^^^^^ -> class1
# ^^^^^^ func:class1 -> func:class1
var value1 = inner1.my_func(1,"",3)
# | | | | ^^^^^^^ -> class1:func
# | | ^^^^^^ -> func:class1
# ^^^^^^ func:class1:value1 -> func:class1:value1
var value2 = inner1.member3
# | | | | ^^^^^^^ -> class1:member3
# | | ^^^^^^ -> func:class1
# ^^^^^^ func:class1:value2 -> func:class1:value2
print(value1, value2)
# | | ^^^^^^ -> func:class1:value2
# ^^^^^^ -> func:class1:value1
var inner3 = Inner3.new()
# | | | | ^^^ -> class3:init
# | | ^^^^^^ -> class3
# ^^^^^^ func:class3 -> func:class3
print(inner3)
# ^^^^^^ -> func:class3
var nested1 = Inner3.NestedInInner3.new()
# | | | | ^^^^^^^^^^^^^^ -> class3:nested1
# | | ^^^^^^ -> class3
# ^^^^^^^ func:class3:nested1 -> func:class3:nested1
var value_nested1 = nested1.some_value
# | | | | ^^^^^^^^^^ -> class3:nested1:some_value
# | | ^^^^^^^ -> func:class3:nested1
# ^^^^^^^^^^^^^ func:class3:nested1:value
print(value_nested1)
# ^^^^^^^^^^^^^ -> func:class3:nested1:value
var nested2 = Inner3.AnotherNestedInInner3.new()
# | | | | ^^^^^^^^^^^^^^^^^^^^^ -> class3:nested2
# | | ^^^^^^ -> class3
# ^^^^^^^ func:class3:nested2 -> func:class3:nested2
var value_nested2 = nested2.some_value
# | | | | ^^^^^^^^^^ -> class3:nested1:some_value
# | | ^^^^^^^ -> func:class3:nested2
# ^^^^^^^^^^^^^ func:class3:nested2:value
var another_value_nested2 = nested2.another_value
# | | | | ^^^^^^^^^^^^^ -> class3:nested2:another_value
# | | ^^^^^^^ -> func:class3:nested2
# ^^^^^^^^^^^^^^^^^^^^^ func:class3:nested2:another_value_nested
print(value_nested2, another_value_nested2)
# | | ^^^^^^^^^^^^^^^^^^^^^ -> func:class3:nested2:another_value_nested
# ^^^^^^^^^^^^^ -> func:class3:nested2:value
| |
126330
|
extends Node
var prop1 := 42
# ^^^^^ prop1 -> prop1
var prop2 : int = 42
# ^^^^^ prop2 -> prop2
var prop3 := 42:
# ^^^^^ prop3 -> prop3
get:
return prop3 + 13
# ^^^^^ -> prop3
set(value):
# ^^^^^ prop3:value -> prop3:value
prop3 = value - 13
# | ^^^^^ -> prop3:value
#<^^^ -> prop3
var prop4: int:
# ^^^^^ prop4 -> prop4
get:
return 42
var prop5 := 42:
# ^^^^^ prop5 -> prop5
set(value):
# ^^^^^ prop5:value -> prop5:value
prop5 = value - 13
# | ^^^^^ -> prop5:value
#<^^^ -> prop5
var prop6:
# ^^^^^ prop6 -> prop6
get = get_prop6,
# ^^^^^^^^^ -> get_prop6
set = set_prop6
# ^^^^^^^^^ -> set_prop6
func get_prop6():
# ^^^^^^^^^ get_prop6 -> get_prop6
return 42
func set_prop6(value):
# | | ^^^^^ set_prop6:value -> set_prop6:value
# ^^^^^^^^^ set_prop6 -> set_prop6
print(value)
# ^^^^^ -> set_prop6:value
var prop7:
# ^^^^^ prop7 -> prop7
get = get_prop7
# ^^^^^^^^^ -> get_prop7
func get_prop7():
# ^^^^^^^^^ get_prop7 -> get_prop7
return 42
var prop8:
# ^^^^^ prop8 -> prop8
set = set_prop8
# ^^^^^^^^^ -> set_prop8
func set_prop8(value):
# | | ^^^^^ set_prop8:value -> set_prop8:value
# ^^^^^^^^^ set_prop8 -> set_prop8
print(value)
# ^^^^^ -> set_prop8:value
const const_var := 42
# ^^^^^^^^^ const_var -> const_var
static var static_var := 42
# ^^^^^^^^^^ static_var -> static_var
| |
126359
|
extends Node
func test():
var child = Node.new()
child.name = "Child"
@warning_ignore("unsafe_call_argument")
add_child(child)
child.owner = self
var hey = Node.new()
hey.name = "Hey"
@warning_ignore("unsafe_call_argument")
child.add_child(hey)
hey.owner = self
hey.unique_name_in_owner = true
var fake_hey = Node.new()
fake_hey.name = "Hey"
@warning_ignore("unsafe_call_argument")
add_child(fake_hey)
fake_hey.owner = self
var sub_child = Node.new()
sub_child.name = "SubChild"
@warning_ignore("unsafe_call_argument")
hey.add_child(sub_child)
sub_child.owner = self
var howdy = Node.new()
howdy.name = "Howdy"
@warning_ignore("unsafe_call_argument")
sub_child.add_child(howdy)
howdy.owner = self
howdy.unique_name_in_owner = true
print(hey == $Child/Hey)
print(howdy == $Child/Hey/SubChild/Howdy)
print(%Hey == hey)
print($%Hey == hey)
print(%"Hey" == hey)
print($"%Hey" == hey)
print($%"Hey" == hey)
print(%Hey/%Howdy == howdy)
print($%Hey/%Howdy == howdy)
print($"%Hey/%Howdy" == howdy)
print($"%Hey"/"%Howdy" == howdy)
print(%"Hey"/"%Howdy" == howdy)
print($%"Hey"/"%Howdy" == howdy)
print($"%Hey"/%"Howdy" == howdy)
print(%"Hey"/%"Howdy" == howdy)
print($%"Hey"/%"Howdy" == howdy)
print(%"Hey/%Howdy" == howdy)
print($%"Hey/%Howdy" == howdy)
| |
126370
|
class_name ExportVariableTestGlobalClass
extends Node2D
| |
126377
|
@tool
class_name ExportVariableTest
extends Node
const PreloadedGlobalClass = preload("./export_variable_global.notest.gd")
const PreloadedUnnamedClass = preload("./export_variable_unnamed.notest.gd")
# Built-in types.
@export var test_weak_int = 1
@export var test_hard_int: int = 2
@export_range(0, 100) var test_range = 100
@export_range(0, 100, 1) var test_range_step = 101
@export_range(0, 100, 1, "or_greater") var test_range_step_or_greater = 102
@export var test_color: Color
@export_color_no_alpha var test_color_no_alpha: Color
@export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var test_node_path := ^"hello"
# Enums.
@export var test_side: Side
@export var test_atm: AutoTranslateMode
# Resources and nodes.
@export var test_image: Image
@export var test_timer: Timer
# Global custom classes.
@export var test_global_class: ExportVariableTest
@export var test_preloaded_global_class: PreloadedGlobalClass
@export var test_preloaded_unnamed_class: PreloadedUnnamedClass # GH-93168
# Arrays.
@export var test_array: Array
@export var test_array_bool: Array[bool]
@export var test_array_array: Array[Array]
@export var test_array_side: Array[Side]
@export var test_array_atm: Array[AutoTranslateMode]
@export var test_array_image: Array[Image]
@export var test_array_timer: Array[Timer]
# `@export_storage`.
@export_storage var test_storage_untyped
@export_storage var test_storage_weak_int = 3 # Property info still `Variant`, unlike `@export`.
@export_storage var test_storage_hard_int: int = 4
# `@export_custom`.
# NOTE: `PROPERTY_USAGE_NIL_IS_VARIANT` flag will be removed.
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_untyped
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_weak_int = 5
@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_hard_int: int = 6
# `@export_tool_button`.
@export_tool_button("Click me!") var test_tool_button_1: Callable
@export_tool_button("Click me!", "ColorRect") var test_tool_button_2: Callable
func test():
for property in get_property_list():
if str(property.name).begins_with("test_"):
Utils.print_property_extended_info(property, self)
| |
126431
|
hint=TYPE_STRING hint_string="<float>/<EXP_EASING>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_node_path: Array
hint=TYPE_STRING hint_string="<NodePath>/<NODE_PATH_VALID_TYPES>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_color: Array
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_color_packed: PackedColorArray
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_byte_array: PackedByteArray
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_int32_array: PackedInt32Array
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_int64_array: PackedInt64Array
hint=TYPE_STRING hint_string="<int>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_float32_array: PackedFloat32Array
hint=TYPE_STRING hint_string="<float>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_float64_array: PackedFloat64Array
hint=TYPE_STRING hint_string="<float>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_color_array: PackedColorArray
hint=TYPE_STRING hint_string="<Color>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_vector2_array: PackedVector2Array
hint=TYPE_STRING hint_string="<Vector2>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_vector3_array: PackedVector3Array
hint=TYPE_STRING hint_string="<Vector3>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_weak_packed_vector4_array: PackedVector4Array
hint=TYPE_STRING hint_string="<Vector4>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_range_weak_packed_byte_array: PackedByteArray
hint=TYPE_STRING hint_string="<int>/<RANGE>:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_range_weak_packed_int32_array: PackedInt32Array
hint=TYPE_STRING hint_string="<int>/<RANGE>:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_range_weak_packed_int64_array: PackedInt64Array
hint=TYPE_STRING hint_string="<int>/<RANGE>:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_range_weak_packed_float32_array: PackedFloat32Array
hint=TYPE_STRING hint_string="<float>/<RANGE>:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_range_weak_packed_float64_array: PackedFloat64Array
hint=TYPE_STRING hint_string="<float>/<RANGE>:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
var test_noalpha_weak_packed_color_array: PackedColorArray
hint=TYPE_STRING hint_string="<Color>/<COLOR_NO_ALPHA>:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
| |
126554
|
@export_enum("A", "B", "C") var x: Color
func test():
pass
| |
126555
|
@export_enum("A", "B", "C") var x: Array[Color]
func test():
pass
| |
126661
|
func i_return_int() -> int:
return 4
func test():
i_return_int()
preload("../../utils.notest.gd") # `preload` is a function-like keyword.
| |
126682
|
class A:
func int_to_variant(_p: int): pass
func node_to_variant(_p: Node): pass
func node_2d_to_node(_p: Node2D): pass
func variant_to_untyped(_p: Variant): pass
func int_to_untyped(_p: int): pass
func node_to_untyped(_p: Node): pass
class B extends A:
func int_to_variant(_p: Variant): pass
func node_to_variant(_p: Variant): pass
func node_2d_to_node(_p: Node): pass
func variant_to_untyped(_p): pass
func int_to_untyped(_p): pass
func node_to_untyped(_p): pass
func test():
pass
| |
126688
|
class A extends RefCounted:
pass
class B extends A:
pass
func test():
var builtin: Variant = 3
Utils.check((builtin is Variant) == true)
Utils.check((builtin is int) == true)
Utils.check(is_instance_of(builtin, TYPE_INT) == true)
Utils.check((builtin is float) == false)
Utils.check(is_instance_of(builtin, TYPE_FLOAT) == false)
const const_builtin: Variant = 3
Utils.check((const_builtin is Variant) == true)
Utils.check((const_builtin is int) == true)
Utils.check(is_instance_of(const_builtin, TYPE_INT) == true)
Utils.check((const_builtin is float) == false)
Utils.check(is_instance_of(const_builtin, TYPE_FLOAT) == false)
var int_array: Variant = [] as Array[int]
Utils.check((int_array is Variant) == true)
Utils.check((int_array is Array) == true)
Utils.check(is_instance_of(int_array, TYPE_ARRAY) == true)
Utils.check((int_array is Array[int]) == true)
Utils.check((int_array is Array[float]) == false)
Utils.check((int_array is int) == false)
Utils.check(is_instance_of(int_array, TYPE_INT) == false)
var const_int_array: Variant = [] as Array[int]
Utils.check((const_int_array is Variant) == true)
Utils.check((const_int_array is Array) == true)
Utils.check(is_instance_of(const_int_array, TYPE_ARRAY) == true)
Utils.check((const_int_array is Array[int]) == true)
Utils.check((const_int_array is Array[float]) == false)
Utils.check((const_int_array is int) == false)
Utils.check(is_instance_of(const_int_array, TYPE_INT) == false)
var b_array: Variant = [] as Array[B]
Utils.check((b_array is Variant) == true)
Utils.check((b_array is Array) == true)
Utils.check(is_instance_of(b_array, TYPE_ARRAY) == true)
Utils.check((b_array is Array[B]) == true)
Utils.check((b_array is Array[A]) == false)
Utils.check((b_array is Array[int]) == false)
Utils.check((b_array is int) == false)
Utils.check(is_instance_of(b_array, TYPE_INT) == false)
var const_b_array: Variant = [] as Array[B]
Utils.check((const_b_array is Variant) == true)
Utils.check((const_b_array is Array) == true)
Utils.check(is_instance_of(const_b_array, TYPE_ARRAY) == true)
Utils.check((const_b_array is Array[B]) == true)
Utils.check((const_b_array is Array[A]) == false)
Utils.check((const_b_array is Array[int]) == false)
Utils.check((const_b_array is int) == false)
Utils.check(is_instance_of(const_b_array, TYPE_INT) == false)
var native: Variant = RefCounted.new()
Utils.check((native is Variant) == true)
Utils.check((native is Object) == true)
Utils.check(is_instance_of(native, TYPE_OBJECT) == true)
Utils.check(is_instance_of(native, Object) == true)
Utils.check((native is RefCounted) == true)
Utils.check(is_instance_of(native, RefCounted) == true)
Utils.check((native is Node) == false)
Utils.check(is_instance_of(native, Node) == false)
Utils.check((native is int) == false)
Utils.check(is_instance_of(native, TYPE_INT) == false)
var a_script: Variant = A.new()
Utils.check((a_script is Variant) == true)
Utils.check((a_script is Object) == true)
Utils.check(is_instance_of(a_script, TYPE_OBJECT) == true)
Utils.check(is_instance_of(a_script, Object) == true)
Utils.check((a_script is RefCounted) == true)
Utils.check(is_instance_of(a_script, RefCounted) == true)
Utils.check((a_script is A) == true)
Utils.check(is_instance_of(a_script, A) == true)
Utils.check((a_script is B) == false)
Utils.check(is_instance_of(a_script, B) == false)
Utils.check((a_script is Node) == false)
Utils.check(is_instance_of(a_script, Node) == false)
Utils.check((a_script is int) == false)
Utils.check(is_instance_of(a_script, TYPE_INT) == false)
var b_script: Variant = B.new()
Utils.check((b_script is Variant) == true)
Utils.check((b_script is Object) == true)
Utils.check(is_instance_of(b_script, TYPE_OBJECT) == true)
Utils.check(is_instance_of(b_script, Object) == true)
Utils.check((b_script is RefCounted) == true)
Utils.check(is_instance_of(b_script, RefCounted) == true)
Utils.check((b_script is A) == true)
Utils.check(is_instance_of(b_script, A) == true)
Utils.check((b_script is B) == true)
Utils.check(is_instance_of(b_script, B) == true)
Utils.check((b_script is Node) == false)
Utils.check(is_instance_of(b_script, Node) == false)
Utils.check((b_script is int) == false)
Utils.check(is_instance_of(b_script, TYPE_INT) == false)
var var_null: Variant = null
Utils.check((var_null is Variant) == true)
Utils.check((var_null is int) == false)
Utils.check(is_instance_of(var_null, TYPE_INT) == false)
Utils.check((var_null is Object) == false)
Utils.check(is_instance_of(var_null, TYPE_OBJECT) == false)
Utils.check((var_null is RefCounted) == false)
Utils.check(is_instance_of(var_null, RefCounted) == false)
Utils.check((var_null is A) == false)
Utils.check(is_instance_of(var_null, A) == false)
const const_null: Variant = null
Utils.check((const_null is Variant) == true)
Utils.check((const_null is int) == false)
Utils.check(is_instance_of(const_null, TYPE_INT) == false)
Utils.check((const_null is Object) == false)
Utils.check(is_instance_of(const_null, TYPE_OBJECT) == false)
Utils.check((const_null is RefCounted) == false)
Utils.check(is_instance_of(const_null, RefCounted) == false)
Utils.check((const_null is A) == false)
Utils.check(is_instance_of(const_null, A) == false)
print('ok')
| |
126690
|
# Untyped inline property
var prop1:
get:
return prop1
set(value):
prop1 = value
# Typed inline property
var prop2: int:
get:
return prop2
set(value):
prop2 = value
# Typed inline property with default value
var prop3: int = 1:
get:
return prop3
set(value):
prop3 = value
# Typed inline property with backing variable
var _prop4: int = 2
var prop4: int:
get:
return _prop4
set(value):
_prop4 = value
func test():
print(prop1)
print(prop2)
print(prop3)
print(prop4)
print()
prop1 = 1
prop2 = 2
prop3 = 3
prop4 = 4
print(prop1)
print(prop2)
print(prop3)
print(prop4)
| |
126727
|
const Preloaded := preload( 'preload_script_native_type.notest.gd' )
func test() -> void:
var inferred := Preloaded.new()
var inferred_owner := inferred.owner
var typed: Preloaded
typed = Preloaded.new()
var typed_owner := typed.owner
print(typed_owner == inferred_owner)
inferred.free()
typed.free()
print('ok')
| |
126802
|
var Value:int = 8:
get:
return Value
set(v):
Value = v
func test():
var f:float = Value
print(int(f))
| |
126803
|
const A = preload("preload_cyclic_reference_a.notest.gd")
static func test_cyclic_reference():
A.test_cyclic_reference_2()
static func test_cyclic_reference_2():
A.test_cyclic_reference_3()
static func test_cyclic_reference_3():
print(A.WAITING_FOR)
| |
126832
|
extends Node
func test():
var typed: Variant = get_node_or_null("does_not_exist")
var untyped = null
var node_1: Node = typed
var node_2: Node = untyped
var node_3 = typed
var node_4 = untyped
print(typed)
print(untyped)
print(node_1)
print(node_2)
print(node_3)
print(node_4)
| |
126857
|
const preloaded: GDScript = preload("gdscript_to_preload.notest.gd")
func test():
var preloaded_instance: preloaded = preloaded.new()
print(preloaded_instance.something())
| |
126863
|
# https://github.com/godotengine/godot/issues/43221
extends Node
func test():
name = "Node"
print(self["name"])
self["name"] = "Changed"
print(name)
| |
126884
|
var _prop = 1
var prop:
get = get_prop, set = set_prop
func get_prop():
return _prop
func set_prop(value):
_prop = value
func test():
print(prop)
prop = 2
print(prop)
| |
127007
|
var _prop: int
# Inline getter returns int instead of String.
var prop: String:
get:
return _prop
func test():
pass
| |
127063
|
var with_setter := 0:
set(val):
var x: String = val
with_setter = val
func test():
with_setter = 1
print(with_setter)
| |
127105
|
GDTEST_ANALYZER_ERROR
Expression is of type "StringName" so it can't be of type "int".
| |
127278
|
# Doesn't produce the warning:
signal used_as_first_class_signal()
signal used_with_signal_constructor()
signal used_with_signal_emit()
signal used_with_object_emit_signal()
signal used_with_object_connect()
signal used_with_object_disconnect()
signal used_with_self_prefix()
# Produce the warning:
signal used_with_dynamic_name()
signal just_unused()
@warning_ignore("unused_signal")
signal unused_but_ignored()
func no_exec():
print(used_as_first_class_signal)
print(Signal(self, "used_with_signal_constructor"))
used_with_signal_emit.emit()
print(emit_signal("used_with_object_emit_signal"))
print(connect("used_with_object_connect", Callable()))
disconnect("used_with_object_disconnect", Callable())
print(self.emit_signal("used_with_self_prefix"))
var dynamic_name := "used_with_dynamic_name"
print(emit_signal(dynamic_name))
func test():
pass
| |
127295
|
func test():
print("warn")
func get(_property: StringName) -> Variant:
return null
| |
127298
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GDScript" inherits="Script" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A script implemented in the GDScript programming language.
</brief_description>
<description>
A script implemented in the GDScript programming language, saved with the [code].gd[/code] extension. The script extends the functionality of all objects that instantiate it.
Calling [method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
If you are looking for GDScript's built-in functions, see [@GDScript] instead.
</description>
<tutorials>
<link title="GDScript documentation index">$DOCS_URL/tutorials/scripting/gdscript/index.html</link>
</tutorials>
<methods>
<method name="new" qualifiers="vararg">
<return type="Variant" />
<description>
Returns a new instance of the script.
For example:
[codeblock]
var MyClass = load("myclass.gd")
var instance = MyClass.new()
assert(instance.get_script() == MyClass)
[/codeblock]
</description>
</method>
</methods>
</class>
| |
127300
|
ethod name="is_instance_of">
<return type="bool" />
<param index="0" name="value" type="Variant" />
<param index="1" name="type" type="Variant" />
<description>
Returns [code]true[/code] if [param value] is an instance of [param type]. The [param type] value must be one of the following:
- A constant from the [enum Variant.Type] enumeration, for example [constant TYPE_INT].
- An [Object]-derived class which exists in [ClassDB], for example [Node].
- A [Script] (you can use any class, including inner one).
Unlike the right operand of the [code]is[/code] operator, [param type] can be a non-constant value. The [code]is[/code] operator supports more features (such as typed arrays). Use the operator instead of this method if you do not need dynamic type checking.
[b]Examples:[/b]
[codeblock]
print(is_instance_of(a, TYPE_INT))
print(is_instance_of(a, Node))
print(is_instance_of(a, MyClass))
print(is_instance_of(a, MyClass.InnerClass))
[/codeblock]
[b]Note:[/b] If [param value] and/or [param type] are freed objects (see [method @GlobalScope.is_instance_valid]), or [param type] is not one of the above options, this method will raise a runtime error.
See also [method @GlobalScope.typeof], [method type_exists], [method Array.is_same_typed] (and other [Array] methods).
</description>
</method>
<method name="len">
<return type="int" />
<param index="0" name="var" type="Variant" />
<description>
Returns the length of the given Variant [param var]. The length can be the character count of a [String] or [StringName], the element count of any array type, or the size of a [Dictionary]. For every other Variant type, a run-time error is generated and execution is stopped.
[codeblock]
var a = [1, 2, 3, 4]
len(a) # Returns 4
var b = "Hello!"
len(b) # Returns 6
[/codeblock]
</description>
</method>
<method name="load">
<return type="Resource" />
<param index="0" name="path" type="String" />
<description>
Returns a [Resource] from the filesystem located at the absolute [param path]. Unless it's already referenced elsewhere (such as in another script or in the scene), the resource is loaded from disk on function call, which might cause a slight delay, especially when loading large scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload]. This method is equivalent of using [method ResourceLoader.load] with [constant ResourceLoader.CACHE_MODE_REUSE].
[b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script.
[codeblock]
# Load a scene called "main" located in the root of the project directory and cache it in a variable.
var main = load("res://main.tscn") # main will contain a PackedScene resource.
[/codeblock]
[b]Important:[/b] Relative paths are [i]not[/i] relative to the script calling this method, instead it is prefixed with [code]"res://"[/code]. Loading from relative paths might not work as expected.
This function is a simplified version of [method ResourceLoader.load], which can be used for more advanced scenarios.
[b]Note:[/b] Files have to be imported into the engine first to load them using this function. If you want to load [Image]s at run-time, you may use [method Image.load]. If you want to import audio files, you can use the snippet described in [member AudioStreamMP3.data].
[b]Note:[/b] If [member ProjectSettings.editor/export/convert_text_resources_to_binary] is [code]true[/code], [method @GDScript.load] will not be able to read converted files in an exported project. If you rely on run-time loading of files present within the PCK, set [member ProjectSettings.editor/export/convert_text_resources_to_binary] to [code]false[/code].
</description>
</method>
<method name="preload">
<return type="Resource" />
<param index="0" name="path" type="String" />
<description>
Returns a [Resource] from the filesystem located at [param path]. During run-time, the resource is loaded when the script is being parsed. This function effectively acts as a reference to that resource. Note that this function requires [param path] to be a constant [String]. If you want to load a resource from a dynamic/variable path, use [method load].
[b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the Assets Panel and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script.
[codeblock]
# Create instance of a scene.
var diamond = preload("res://diamond.tscn").instantiate()
[/codeblock]
[b]Note:[/b] [method preload] is a keyword, not a function. So you cannot access it as a [Callable].
</description>
</method>
<method name="print_debug" qualifiers="vararg">
<return type="void" />
<description>
Like [method @GlobalScope.print], but includes the current stack frame when running with the debugger turned on.
The output in the console may look like the following:
[codeblock lang=text]
Test print
At: res://test.gd:15:_process()
[/codeblock]
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will instead print the thread ID.
</description>
</method>
<method name="print_stack">
<return type="void" />
<description>
Prints a stack trace at the current code location. See also [method get_stack].
The output in the console may look like the following:
[codeblock lang=text]
Frame 0 - res://test.gd:16 in function '_process'
[/codeblock]
[b]Note:[/b] This function only works if the running instance is connected to a debugging server (i.e. an editor instance). [method print_stack] will not work in projects exported in release mode, or in projects exported in debug mode if not connected to a debugging server.
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will instead print the thread ID.
</description>
</method>
<m
| |
127302
|
nnotations>
<annotation name="@export">
<return type="void" />
<description>
Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property, use the type hint notation.
[codeblock]
extends Node
enum Direction {LEFT, RIGHT, UP, DOWN}
# Built-in types.
@export var string = ""
@export var int_number = 5
@export var float_number: float = 5
# Enums.
@export var type: Variant.Type
@export var format: Image.Format
@export var direction: Direction
# Resources.
@export var image: Image
@export var custom_resource: CustomResource
# Nodes.
@export var node: Node
@export var custom_node: CustomNode
# Typed arrays.
@export var int_array: Array[int]
@export var direction_array: Array[Direction]
@export var image_array: Array[Image]
@export var node_array: Array[Node]
[/codeblock]
[b]Note:[/b] Custom resources and nodes should be registered as global classes using [code]class_name[/code], since the Inspector currently only supports global classes. Otherwise, a less specific type will be exported instead.
[b]Note:[/b] Node export is only supported in [Node]-derived classes and has a number of other limitations.
</description>
</annotation>
<annotation name="@export_category">
<return type="void" />
<param index="0" name="name" type="String" />
<description>
Define a new category for the following exported properties. This helps to organize properties in the Inspector dock.
See also [constant PROPERTY_USAGE_CATEGORY].
[codeblock]
@export_category("Statistics")
@export var hp = 30
@export var speed = 1.25
[/codeblock]
[b]Note:[/b] Categories in the Inspector dock's list usually divide properties coming from different classes (Node, Node2D, Sprite, etc.). For better clarity, it's recommended to use [annotation @export_group] and [annotation @export_subgroup], instead.
</description>
</annotation>
<annotation name="@export_color_no_alpha">
<return type="void" />
<description>
Export a [Color], [Array][lb][Color][rb], or [PackedColorArray] property without allowing its transparency ([member Color.a]) to be edited.
See also [constant PROPERTY_HINT_COLOR_NO_ALPHA].
[codeblock]
@export_color_no_alpha var dye_color: Color
@export_color_no_alpha var dye_colors: Array[Color]
[/codeblock]
</description>
</annotation>
<annotation name="@export_custom">
<return type="void" />
<param index="0" name="hint" type="int" enum="PropertyHint" />
<param index="1" name="hint_string" type="String" />
<param index="2" name="usage" type="int" enum="PropertyUsageFlags" is_bitfield="true" default="6" />
<description>
Allows you to set a custom hint, hint string, and usage flags for the exported property. Note that there's no validation done in GDScript, it will just pass the parameters to the editor.
[codeblock]
@export_custom(PROPERTY_HINT_NONE, "suffix:m") var suffix: Vector3
[/codeblock]
[b]Note:[/b] Regardless of the [param usage] value, the [constant PROPERTY_USAGE_SCRIPT_VARIABLE] flag is always added, as with any explicitly declared script variable.
</description>
</annotation>
<annotation name="@export_dir">
<return type="void" />
<description>
Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as a path to a directory. The path will be limited to the project folder and its subfolders. See [annotation @export_global_dir] to allow picking from the entire filesystem.
See also [constant PROPERTY_HINT_DIR].
[codeblock]
@export_dir var sprite_folder_path: String
@export_dir var sprite_folder_paths: Array[String]
[/codeblock]
</description>
</annotation>
<annotation name="@export_enum" qualifiers="vararg">
<return type="void" />
<param index="0" name="names" type="String" />
<description>
Export an [int], [String], [Array][lb][int][rb], [Array][lb][String][rb], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], or [PackedStringArray] property as an enumerated list of options (or an array of options). If the property is an [int], then the index of the value is stored, in the same order the values are provided. You can add explicit values using a colon. If the property is a [String], then the value is stored.
See also [constant PROPERTY_HINT_ENUM].
[codeblock]
@export_enum("Warrior", "Magician", "Thief") var character_class: int
@export_enum("Slow:30", "Average:60", "Very Fast:200") var character_speed: int
@export_enum("Rebecca", "Mary", "Leah") var character_name: String
@export_enum("Sword", "Spear", "Mace") var character_items: Array[int]
@export_enum("double_jump", "climb", "dash") var character_skills: Array[String]
[/codeblock]
If you want to set an initial value, you must specify it explicitly:
[codeblock]
@export_enum("Rebecca", "Mary", "Leah") var character_name: String = "Rebecca"
[/codeblock]
If you want to use named GDScript enums, then use [annotation @export] instead:
[codeblock]
enum CharacterName {REBECCA, MARY, LEAH}
@export var character_name: CharacterName
enum CharacterItem {SWORD, SPEAR, MACE}
@export var character_items: Array[CharacterItem]
[/codeblock]
</description>
</annotation>
<annotation name="@export_exp_easing" qualifiers="vararg">
<return type="void" />
<param index="0" name="hints" type="String" default="""" />
<description>
Export a floating-point property with an easing editor widget. Additional hints can be provided to adjust the behavior of the widget. [code]"attenuation"[/code] flips the curve, which makes it more intuitive for editing attenuation properties. [code]"positive_only"[/code] limits values to only be greater than or equal to zero.
See also [constant PROPERTY_HINT_EXP_EASING].
[codeblock]
@export_exp_easing var transition_speed
@export_exp_easing("attenuation") var fading_attenuation
@export_exp_easing("positive_only") var effect_power
@export_exp_easing var speeds: Array[float]
[/codeblock]
</description>
</annotation>
<annotation name="@export_file" qualifiers="vararg">
<return type="void" />
<param index="0" name="filter" type="String" default="""" />
<description>
Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as a path to a file. The path will be limited to the project folder and its subfolders. See [annotation @export_global_file] to allow picking from the entire filesystem.
If [param filter] is provided, only matching files will be available for picking.
See also [constant PROPERTY_HINT_FILE].
[codeblock]
@export_file var sound_effect_path: String
@export_file("*.txt") var notes_path: String
@export_file var level_paths: Array[String]
[/codeblock]
</description>
</annotation>
<a
| |
127304
|
nnotation name="@export_group">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="prefix" type="String" default="""" />
<description>
Define a new group for the following exported properties. This helps to organize properties in the Inspector dock. Groups can be added with an optional [param prefix], which would make group to only consider properties that have this prefix. The grouping will break on the first property that doesn't have a prefix. The prefix is also removed from the property's name in the Inspector dock.
If no [param prefix] is provided, then every following property will be added to the group. The group ends when then next group or category is defined. You can also force end a group by using this annotation with empty strings for parameters, [code]@export_group("", "")[/code].
Groups cannot be nested, use [annotation @export_subgroup] to add subgroups within groups.
See also [constant PROPERTY_USAGE_GROUP].
[codeblock]
@export_group("Racer Properties")
@export var nickname = "Nick"
@export var age = 26
@export_group("Car Properties", "car_")
@export var car_label = "Speedy"
@export var car_number = 3
@export_group("", "")
@export var ungrouped_number = 3
[/codeblock]
</description>
</annotation>
<annotation name="@export_multiline">
<return type="void" />
<description>
Export a [String], [Array][lb][String][rb], [PackedStringArray], [Dictionary] or [Array][lb][Dictionary][rb] property with a large [TextEdit] widget instead of a [LineEdit]. This adds support for multiline content and makes it easier to edit large amount of text stored in the property.
See also [constant PROPERTY_HINT_MULTILINE_TEXT].
[codeblock]
@export_multiline var character_biography
@export_multiline var npc_dialogs: Array[String]
[/codeblock]
</description>
</annotation>
<annotation name="@export_node_path" qualifiers="vararg">
<return type="void" />
<param index="0" name="type" type="String" default="""" />
<description>
Export a [NodePath] or [Array][lb][NodePath][rb] property with a filter for allowed node types.
See also [constant PROPERTY_HINT_NODE_PATH_VALID_TYPES].
[codeblock]
@export_node_path("Button", "TouchScreenButton") var some_button
@export_node_path("Button", "TouchScreenButton") var many_buttons: Array[NodePath]
[/codeblock]
[b]Note:[/b] The type must be a native class or a globally registered script (using the [code]class_name[/code] keyword) that inherits [Node].
</description>
</annotation>
<annotation name="@export_placeholder">
<return type="void" />
<param index="0" name="placeholder" type="String" />
<description>
Export a [String], [Array][lb][String][rb], or [PackedStringArray] property with a placeholder text displayed in the editor widget when no value is present.
See also [constant PROPERTY_HINT_PLACEHOLDER_TEXT].
[codeblock]
@export_placeholder("Name in lowercase") var character_id: String
@export_placeholder("Name in lowercase") var friend_ids: Array[String]
[/codeblock]
</description>
</annotation>
<annotation name="@export_range" qualifiers="vararg">
<return type="void" />
<param index="0" name="min" type="float" />
<param index="1" name="max" type="float" />
<param index="2" name="step" type="float" default="1.0" />
<param index="3" name="extra_hints" type="String" default="""" />
<description>
Export an [int], [float], [Array][lb][int][rb], [Array][lb][float][rb], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], [PackedFloat32Array], or [PackedFloat64Array] property as a range value. The range must be defined by [param min] and [param max], as well as an optional [param step] and a variety of extra hints. The [param step] defaults to [code]1[/code] for integer properties. For floating-point numbers this value depends on your [member EditorSettings.interface/inspector/default_float_step] setting.
If hints [code]"or_greater"[/code] and [code]"or_less"[/code] are provided, the editor widget will not cap the value at range boundaries. The [code]"exp"[/code] hint will make the edited values on range to change exponentially. The [code]"hide_slider"[/code] hint will hide the slider element of the editor widget.
Hints also allow to indicate the units for the edited value. Using [code]"radians_as_degrees"[/code] you can specify that the actual value is in radians, but should be displayed in degrees in the Inspector dock (the range values are also in degrees). [code]"degrees"[/code] allows to add a degree sign as a unit suffix (the value is unchanged). Finally, a custom suffix can be provided using [code]"suffix:unit"[/code], where "unit" can be any string.
See also [constant PROPERTY_HINT_RANGE].
[codeblock]
@export_range(0, 20) var number
@export_range(-10, 20) var number
@export_range(-10, 20, 0.2) var number: float
@export_range(0, 20) var numbers: Array[float]
@export_range(0, 100, 1, "or_greater") var power_percent
@export_range(0, 100, 1, "or_greater", "or_less") var health_delta
@export_range(-180, 180, 0.001, "radians_as_degrees") var angle_radians
@export_range(0, 360, 1, "degrees") var angle_degrees
@export_range(-8, 8, 2, "suffix:px") var target_offset
[/codeblock]
</description>
</annotation>
<annotation name="@export_storage">
<return type="void" />
<description>
Export a property with [constant PROPERTY_USAGE_STORAGE] flag. The property is not displayed in the editor, but it is serialized and stored in the scene or resource file. This can be useful for [annotation @tool] scripts. Also the property value is copied when [method Resource.duplicate] or [method Node.duplicate] is called, unlike non-exported variables.
[codeblock]
var a # Not stored in the file, not displayed in the editor.
@export_storage var b # Stored in the file, not displayed in the editor.
@export var c: int # Stored in the file, displayed in the editor.
[/codeblock]
</description>
</annotation>
<annotation name="@export_subgroup">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="prefix" type="String" default="""" />
<description>
Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. Subgroups work exactly like groups, except they need a parent group to exist. See [annotation @export_group].
See also [constant PROPERTY_USAGE_SUBGROUP].
[codeblock]
@export_group("Racer Properties")
@export var nickname = "Nick"
@export var age = 26
@export_subgroup("Car Properties", "car_")
@export var car_label = "Speedy"
@export var car_number = 3
[/codeblock]
[b]Note:[/b] Subgroups cannot be nested, they only provide one extra level of depth. Just like the next group ends the previous group, so do the subsequent subgroups.
</description>
</annotation>
<a
| |
127305
|
nnotation name="@export_tool_button">
<return type="void" />
<param index="0" name="text" type="String" />
<param index="1" name="icon" type="String" default="""" />
<description>
Export a [Callable] property as a clickable button with the label [param text]. When the button is pressed, the callable is called.
If [param icon] is specified, it is used to fetch an icon for the button via [method Control.get_theme_icon], from the [code]"EditorIcons"[/code] theme type. If [param icon] is omitted, the default [code]"Callable"[/code] icon is used instead.
Consider using the [EditorUndoRedoManager] to allow the action to be reverted safely.
See also [constant PROPERTY_HINT_TOOL_BUTTON].
[codeblock]
@tool
extends Sprite2D
@export_tool_button("Hello") var hello_action = hello
@export_tool_button("Randomize the color!", "ColorRect")
var randomize_color_action = randomize_color
func hello():
print("Hello world!")
func randomize_color():
var undo_redo = EditorInterface.get_editor_undo_redo()
undo_redo.create_action("Randomized Sprite2D Color")
undo_redo.add_do_property(self, &"self_modulate", Color(randf(), randf(), randf()))
undo_redo.add_undo_property(self, &"self_modulate", self_modulate)
undo_redo.commit_action()
[/codeblock]
[b]Note:[/b] The property is exported without the [constant PROPERTY_USAGE_STORAGE] flag because a [Callable] cannot be properly serialized and stored in a file.
[b]Note:[/b] In an exported project neither [EditorInterface] nor [EditorUndoRedoManager] exist, which may cause some scripts to break. To prevent this, you can use [method Engine.get_singleton] and omit the static type from the variable declaration:
[codeblock]
var undo_redo = Engine.get_singleton(&"EditorInterface").get_editor_undo_redo()
[/codeblock]
[b]Note:[/b] Avoid storing lambda callables in member variables of [RefCounted]-based classes (e.g. resources), as this can lead to memory leaks. Use only method callables and optionally [method Callable.bind] or [method Callable.unbind].
</description>
</annotation>
<annotation name="@icon">
<return type="void" />
<param index="0" name="icon_path" type="String" />
<description>
Add a custom icon to the current script. The icon specified at [param icon_path] is displayed in the Scene dock for every node of that class, as well as in various editor dialogs.
[codeblock]
@icon("res://path/to/class/icon.svg")
[/codeblock]
[b]Note:[/b] Only the script can have a custom icon. Inner classes are not supported.
[b]Note:[/b] As annotations describe their subject, the [annotation @icon] annotation must be placed before the class definition and inheritance.
[b]Note:[/b] Unlike other annotations, the argument of the [annotation @icon] annotation must be a string literal (constant expressions are not supported).
</description>
</annotation>
<annotation name="@onready">
<return type="void" />
<description>
Mark the following property as assigned when the [Node] is ready. Values for these properties are not assigned immediately when the node is initialized ([method Object._init]), and instead are computed and stored right before [method Node._ready].
[codeblock]
@onready var character_name: Label = $Label
[/codeblock]
</description>
</annotation>
<annotation name="@rpc">
<return type="void" />
<param index="0" name="mode" type="String" default=""authority"" />
<param index="1" name="sync" type="String" default=""call_remote"" />
<param index="2" name="transfer_mode" type="String" default=""unreliable"" />
<param index="3" name="transfer_channel" type="int" default="0" />
<description>
Mark the following method for remote procedure calls. See [url=$DOCS_URL/tutorials/networking/high_level_multiplayer.html]High-level multiplayer[/url].
If [param mode] is set as [code]"any_peer"[/code], allows any peer to call this RPC function. Otherwise, only the authority peer is allowed to call it and [param mode] should be kept as [code]"authority"[/code]. When configuring functions as RPCs with [method Node.rpc_config], each of these modes respectively corresponds to the [constant MultiplayerAPI.RPC_MODE_AUTHORITY] and [constant MultiplayerAPI.RPC_MODE_ANY_PEER] RPC modes. See [enum MultiplayerAPI.RPCMode]. If a peer that is not the authority tries to call a function that is only allowed for the authority, the function will not be executed. If the error can be detected locally (when the RPC configuration is consistent between the local and the remote peer), an error message will be displayed on the sender peer. Otherwise, the remote peer will detect the error and print an error there.
If [param sync] is set as [code]"call_remote"[/code], the function will only be executed on the remote peer, but not locally. To run this function locally too, set [param sync] to [code]"call_local"[/code]. When configuring functions as RPCs with [method Node.rpc_config], this is equivalent to setting [code]call_local[/code] to [code]true[/code].
The [param transfer_mode] accepted values are [code]"unreliable"[/code], [code]"unreliable_ordered"[/code], or [code]"reliable"[/code]. It sets the transfer mode of the underlying [MultiplayerPeer]. See [member MultiplayerPeer.transfer_mode].
The [param transfer_channel] defines the channel of the underlying [MultiplayerPeer]. See [member MultiplayerPeer.transfer_channel].
The order of [param mode], [param sync] and [param transfer_mode] does not matter, but values related to the same argument must not be used more than once. [param transfer_channel] always has to be the 4th argument (you must specify 3 preceding arguments).
[codeblock]
@rpc
func fn(): pass
@rpc("any_peer", "unreliable_ordered")
func fn_update_pos(): pass
@rpc("authority", "call_remote", "unreliable", 0) # Equivalent to @rpc
func fn_default(): pass
[/codeblock]
</description>
</annotation>
<annotation name="@static_unload">
<return type="void" />
<description>
Make a script with static variables to not persist after all references are lost. If the script is loaded again the static variables will revert to their default values.
[b]Note:[/b] As annotations describe their subject, the [annotation @static_unload] annotation must be placed before the class definition and inheritance.
[b]Warning:[/b] Currently, due to a bug, scripts are never freed, even if [annotation @static_unload] annotation is used.
</description>
</annotation>
<annotation name="@tool">
<return type="void" />
<description>
Mark the current script as a tool script, allowing it to be loaded and executed by the editor. See [url=$DOCS_URL/tutorials/plugins/running_code_in_the_editor.html]Running code in the editor[/url].
[codeblock]
@tool
extends Node
[/codeblock]
[b]Note:[/b] As annotations describe their subject, the [annotation @tool] annotation must be placed before the class definition and inheritance.
</description>
</annotation>
<annotation name="@warning_ignore" qualifiers="vararg">
<return type="void" />
<param index="0" name="warning" type="String" />
<description>
Mark the following statement to ignore the specified [param warning]. See [url=$DOCS_URL/tutorials/scripting/gdscript/warning_system.html]GDScript warning system[/url].
[codeblock]
func test():
print("hello")
return
@warning_ignore("unreachable_code")
print("unreachable")
[/codeblock]
</description>
</annotation>
</annotations>
</class>
| |
127316
|
# meta-description: Classic movement for gravity games (FPS, TPS, ...)
extends _BASE_
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
| |
127318
|
# meta-description: Classic movement for gravity games (platformer, ...)
extends _BASE_
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
| |
127565
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GLTFNode" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
glTF node class.
</brief_description>
<description>
Represents a glTF node. glTF nodes may have names, transforms, children (other glTF nodes), and more specialized properties (represented by their own classes).
glTF nodes generally exist inside of [GLTFState] which represents all data of a glTF file. Most of GLTFNode's properties are indices of other data in the glTF file. You can extend a glTF node with additional properties by using [method get_additional_data] and [method set_additional_data].
</description>
<tutorials>
<link title="Runtime file loading and saving">$DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html</link>
<link title="glTF scene and node spec">https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_004_ScenesNodes.md"</link>
</tutorials>
<methods>
<method name="append_child_index">
<return type="void" />
<param index="0" name="child_index" type="int" />
<description>
Appends the given child node index to the [member children] array.
</description>
</method>
<method name="get_additional_data">
<return type="Variant" />
<param index="0" name="extension_name" type="StringName" />
<description>
Gets additional arbitrary data in this [GLTFNode] instance. This can be used to keep per-node state data in [GLTFDocumentExtension] classes, which is important because they are stateless.
The argument should be the [GLTFDocumentExtension] name (does not have to match the extension name in the glTF file), and the return value can be anything you set. If nothing was set, the return value is null.
</description>
</method>
<method name="set_additional_data">
<return type="void" />
<param index="0" name="extension_name" type="StringName" />
<param index="1" name="additional_data" type="Variant" />
<description>
Sets additional arbitrary data in this [GLTFNode] instance. This can be used to keep per-node state data in [GLTFDocumentExtension] classes, which is important because they are stateless.
The first argument should be the [GLTFDocumentExtension] name (does not have to match the extension name in the glTF file), and the second argument can be anything you want.
</description>
</method>
</methods>
<members>
<member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1">
If this glTF node is a camera, the index of the [GLTFCamera] in the [GLTFState] that describes the camera's properties. If -1, this node is not a camera.
</member>
<member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()">
The indices of the child nodes in the [GLTFState]. If this glTF node has no children, this will be an empty array.
</member>
<member name="height" type="int" setter="set_height" getter="get_height" default="-1">
How deep into the node hierarchy this node is. A root node will have a height of 0, its children will have a height of 1, and so on. If -1, the height has not been calculated.
</member>
<member name="light" type="int" setter="set_light" getter="get_light" default="-1">
If this glTF node is a light, the index of the [GLTFLight] in the [GLTFState] that describes the light's properties. If -1, this node is not a light.
</member>
<member name="mesh" type="int" setter="set_mesh" getter="get_mesh" default="-1">
If this glTF node is a mesh, the index of the [GLTFMesh] in the [GLTFState] that describes the mesh's properties. If -1, this node is not a mesh.
</member>
<member name="original_name" type="String" setter="set_original_name" getter="get_original_name" default="""">
The original name of the node.
</member>
<member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1">
The index of the parent node in the [GLTFState]. If -1, this node is a root node.
</member>
<member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)">
The position of the glTF node relative to its parent.
</member>
<member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion(0, 0, 0, 1)">
The rotation of the glTF node relative to its parent.
</member>
<member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)">
The scale of the glTF node relative to its parent.
</member>
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
If this glTF node has a skeleton, the index of the [GLTFSkeleton] in the [GLTFState] that describes the skeleton's properties. If -1, this node does not have a skeleton.
</member>
<member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1">
If this glTF node has a skin, the index of the [GLTFSkin] in the [GLTFState] that describes the skin's properties. If -1, this node does not have a skin.
</member>
<member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
The transform of the glTF node relative to its parent. This property is usually unused since the position, rotation, and scale properties are preferred.
</member>
</members>
</class>
| |
127785
|
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{AEBF0036-DA76-4341-B651-A3F2856AB2FA}</ProjectGuid>
<OutputPath>bin/$(Configuration)</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace>Godot</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<DocumentationFile>$(OutputPath)/$(AssemblyName).xml</DocumentationFile>
<EnableDefaultItems>false</EnableDefaultItems>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>10</LangVersion>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
<PropertyGroup>
<Description>Godot C# Core API.</Description>
<Authors>Godot Engine contributors</Authors>
<PackageId>GodotSharp</PackageId>
<Version>4.4.0</Version>
<PackageVersion>$(PackageVersion_GodotSharp)</PackageVersion>
<RepositoryUrl>https://github.com/godotengine/godot/tree/master/modules/mono/glue/GodotSharp/GodotSharp</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) Godot Engine contributors</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<!-- SdkPackageVersions.props for easy access -->
<None Include="$(GodotSdkPackageVersionsFilePath)">
<Link>SdkPackageVersions.props</Link>
</None>
</ItemGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);GODOT</DefineConstants>
<DefineConstants Condition=" '$(GodotFloat64)' == 'true' ">REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ReflectionAnalyzers" Version="0.1.22-dev" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<!--PackageReference Include="IDisposableAnalyzers" Version="3.4.13" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers" /-->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Godot.SourceGenerators.Internal\Godot.SourceGenerators.Internal.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<!-- Sources -->
<ItemGroup>
<Compile Include="Core\Aabb.cs" />
<Compile Include="Core\Bridge\GodotSerializationInfo.cs" />
<Compile Include="Core\Bridge\MethodInfo.cs" />
<Compile Include="Core\Callable.generics.cs" />
<Compile Include="Core\CustomGCHandle.cs" />
<Compile Include="Core\Array.cs" />
<Compile Include="Core\Attributes\AssemblyHasScriptsAttribute.cs" />
<Compile Include="Core\Attributes\ExportAttribute.cs" />
<Compile Include="Core\Attributes\ExportCategoryAttribute.cs" />
<Compile Include="Core\Attributes\ExportGroupAttribute.cs" />
<Compile Include="Core\Attributes\ExportSubgroupAttribute.cs" />
<Compile Include="Core\Attributes\GlobalClassAttribute.cs" />
<Compile Include="Core\Attributes\GodotClassNameAttribute.cs" />
<Compile Include="Core\Attributes\IconAttribute.cs" />
<Compile Include="Core\Attributes\MustBeVariantAttribute.cs" />
<Compile Include="Core\Attributes\RpcAttribute.cs" />
<Compile Include="Core\Attributes\ScriptPathAttribute.cs" />
<Compile Include="Core\Attributes\SignalAttribute.cs" />
<Compile Include="Core\Attributes\ToolAttribute.cs" />
<Compile Include="Core\Basis.cs" />
<Compile Include="Core\Bridge\CSharpInstanceBridge.cs" />
<Compile Include="Core\Bridge\GCHandleBridge.cs" />
<Compile Include="Core\Bridge\AlcReloadCfg.cs" />
<Compile Include="Core\Bridge\ManagedCallbacks.cs" />
<Compile Include="Core\Bridge\PropertyInfo.cs" />
<Compile Include="Core\Bridge\ScriptManagerBridge.cs" />
<Compile Include="Core\Bridge\ScriptManagerBridge.types.cs" />
<Compile Include="Core\Callable.cs" />
<Compile Include="Core\Color.cs" />
<Compile Include="Core\Colors.cs" />
<Compile Include="Core\DebuggingUtils.cs" />
<Compile Include="Core\DebugView.cs" />
<Compile Include="Core\DelegateUtils.cs" />
<Compile Include="Core\Dictionary.cs" />
<Compile Include="Core\Dispatcher.cs" />
<Compile Include="Core\Extensions\GodotObjectExtensions.cs" />
<Compile Include="Core\Extensions\NodeExtensions.cs" />
<Compile Include="Core\Extensions\PackedSceneExtensions.cs" />
<Compile Include="Core\Extensions\ResourceLoaderExtensions.cs" />
<Compile Include="Core\GD.cs" />
<Compile Include="Core\GodotObject.base.cs" />
<Compile Include="Core\GodotObject.exceptions.cs" />
<Compile Include="Core\GodotSynchronizationContext.cs" />
<Compile Include="Core\GodotTaskScheduler.cs" />
<Compile Include="Core\GodotTraceListener.cs" />
<Compile Include="Core\GodotUnhandledExceptionEvent.cs" />
<Compile Include="Core\DisposablesTracker.cs" />
<Compile Include="Core\Interfaces\IAwaitable.cs" />
<Compile Include="Core\Interfaces\IAwaiter.cs" />
<Compile Include="Core\Interfaces\ISerializationListener.cs" />
<Compile Include="Core\Mathf.cs" />
<Compile Include="Core\MathfEx.cs" />
<Compile Include="Core\NativeInterop\CustomUnsafe.cs" />
<Compile Include="Core\NativeInterop\ExceptionUtils.cs" />
<Compile Include="Core\NativeInterop\GodotDllImportResolver.cs" />
<Compile Include="Core\NativeInterop\InteropUtils.cs" />
<Compile Include="Core\NativeInterop\NativeFuncs.extended.cs" />
<Compile Include="Core\NativeInterop\NativeVariantPtrArgs.cs" />
<Compile Include="Core\NativeInterop\VariantUtils.cs" />
<Compile Include="Core\NativeInterop\VariantUtils.generic.cs" />
<Compile Include="Core\NodePath.cs" />
<Compile Include="Core\Plane.cs" />
<Compile Include="Core\Projection.cs" />
<Compile Include="Core\Quaternion.cs" />
<Compile Include="Core\Rect2.cs" />
<Compile Include="Core\Rect2I.cs" />
<Compile Include="Core\ReflectionUtils.cs" />
<Compile Include="Core\Rid.cs" />
<Compile Include="Core\NativeInterop\NativeFuncs.cs" />
<Compile Include="Core\NativeInterop\InteropStructs.cs" />
<Compile Include="Core\NativeInterop\Marshaling.cs" />
<Compile Include="Core\Signal.cs" />
<Compile Include="Core\SignalAwaiter.cs" />
<Compile Include="Core\StringExtensions.cs" />
<Compile Include="Core\StringName.cs" />
<Compile Include="Core\Transform2D.cs" />
<Compile Include="Core\Transform3D.cs" />
<Compile Include="Core\Variant.cs" />
<Compile Include="Core\Vector2.cs" />
<Compile Include="Core\Vector2I.cs" />
<Compile Include="Core\Vector3.cs" />
<Compile Include="Core\Vector3I.cs" />
<Compile Include="Core\Vector4.cs" />
<Compile Include="Core\Vector4I.cs" />
<Compile Include="GlobalUsings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<!-- Compat Sources -->
<ItemGroup Condition=" '$(GodotNoDeprecated)' == '' ">
<Compile Include="Compat.cs" />
</ItemGroup>
<!--
We import a props file with auto-generated includes. This works well with Rider.
However, Visual Studio and MonoDevelop won't list them in the solution explorer.
We can't use wildcards as there may be undesired old files still hanging around.
Fortunately code completion, go to definition and such still work.
-->
<Import Condition=" '$(GodotSkipGenerated)' == '' " Project="Generated\GeneratedIncludes.props" />
</Project>
| |
127921
|
/**************************************************************************/
/* multiplayer_spawner.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MULTIPLAYER_SPAWNER_H
#define MULTIPLAYER_SPAWNER_H
#include "scene_replication_config.h"
#include "core/templates/local_vector.h"
#include "core/variant/typed_array.h"
#include "scene/main/node.h"
#include "scene/resources/packed_scene.h"
class MultiplayerSpawner : public Node {
GDCLASS(MultiplayerSpawner, Node);
public:
enum {
INVALID_ID = 0xFF,
};
private:
struct SpawnableScene {
String path;
Ref<PackedScene> cache;
};
LocalVector<SpawnableScene> spawnable_scenes;
HashSet<ResourceUID::ID> spawnable_ids;
NodePath spawn_path;
struct SpawnInfo {
Variant args;
int id = INVALID_ID;
SpawnInfo(Variant p_args, int p_id) {
id = p_id;
args = p_args;
}
SpawnInfo() {}
};
ObjectID spawn_node;
HashMap<ObjectID, SpawnInfo> tracked_nodes;
uint32_t spawn_limit = 0;
Callable spawn_function;
void _update_spawn_node();
void _track(Node *p_node, const Variant &p_argument, int p_scene_id = INVALID_ID);
void _node_added(Node *p_node);
void _node_exit(ObjectID p_id);
void _spawn_notify(ObjectID p_id);
Vector<String> _get_spawnable_scenes() const;
void _set_spawnable_scenes(const Vector<String> &p_scenes);
protected:
static void _bind_methods();
void _notification(int p_what);
#ifdef TOOLS_ENABLED
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
#endif
public:
PackedStringArray get_configuration_warnings() const override;
Node *get_spawn_node() const {
return spawn_node.is_valid() ? Object::cast_to<Node>(ObjectDB::get_instance(spawn_node)) : nullptr;
}
void add_spawnable_scene(const String &p_path);
int get_spawnable_scene_count() const;
String get_spawnable_scene(int p_idx) const;
void clear_spawnable_scenes();
NodePath get_spawn_path() const;
void set_spawn_path(const NodePath &p_path);
uint32_t get_spawn_limit() const { return spawn_limit; }
void set_spawn_limit(uint32_t p_limit) { spawn_limit = p_limit; }
void set_spawn_function(Callable p_spawn_function) { spawn_function = p_spawn_function; }
Callable get_spawn_function() const { return spawn_function; }
const Variant get_spawn_argument(const ObjectID &p_id) const;
int find_spawnable_scene_index_from_object(const ObjectID &p_id) const;
int find_spawnable_scene_index_from_path(const String &p_path) const;
Node *spawn(const Variant &p_data = Variant());
Node *instantiate_custom(const Variant &p_data);
Node *instantiate_scene(int p_idx);
MultiplayerSpawner() {}
};
#endif // MULTIPLAYER_SPAWNER_H
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.