RefCounted
Base class for reference-counted objects.
RefCounted.swift:20class RefCounted
Base class for any object that keeps a reference count. Resource
and many other helper objects inherit this class.
Unlike other Object
types, RefCounted
s keep an internal reference counter so that they are automatically released when no longer in use, and only then. RefCounted
s therefore do not need to be freed manually with Object/free()
.
RefCounted
instances caught in a cyclic reference will not be freed automatically. For example, if a node holds a reference to instance A
, which directly or indirectly holds a reference back to A
, A
’s reference count will be 2. Destruction of the node will leave A
dangling with a reference count of 1, and there will be a memory leak. To prevent this, one of the references in the cycle can be made weak with @GlobalScope.weakref
.
In the vast majority of use cases, instantiating and using RefCounted
-derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused.
Superclasses
class Object
Base class for all other classes in the engine.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
func getReferenceCount(
) -> Int32 Returns the current reference count.
func initRef(
) -> Bool Initializes the internal reference counter. Use this only if you really know what you are doing.
func reference(
) -> Bool Increments the internal reference counter. Use this only if you really know what you are doing.
func unreference(
) -> Bool Decrements the internal reference counter. Use this only if you really know what you are doing.
Show implementation details (1)
Hide implementation details
func _exp_unref(
) Decrements the internal reference counter. Deletes underlying object if it goes to zero..
Subclasses
class AESContext
Provides access to AES encryption/decryption of raw data.
class AStar2D
An implementation of A* for finding the shortest path between two vertices on a connected graph in 2D space.
class AStar3D
An implementation of A* for finding the shortest path between two vertices on a connected graph in 3D space.
class AStarGrid2D
An implementation of A* for finding the shortest path between two points on a partial 2D grid.
class AudioEffectInstance
class AudioStreamPlayback
Meta class for playing back audio.
class CameraFeed
A camera feed gives you access to a single physical camera attached to your device.
class CharFXTransform
Controls how an individual character will be displayed in a
RichTextEffect
.class ConfigFile
Helper class to handle INI-style files.
class Crypto
Provides access to advanced cryptographic functionalities.
class DTLSServer
Helper class to implement a DTLS server.
class DirAccess
Provides methods for managing directories and their content.
class ENetConnection
A wrapper class for an ENetHost.
class EditorDebuggerPlugin
A base class to implement debugger plugins.
class EditorDebuggerSession
A class to interact with the editor debugger.
class EditorExportPlatform
Identifies a supported export platform, and internally provides the functionality of exporting to that platform.
class EditorExportPlugin
A script that is executed when exporting the project.
class EditorFeatureProfile
An editor feature profile which can be used to disable specific features.
class EditorFileSystemImportFormatSupportQuery
Used to query and configure import format support.
class EditorInspectorPlugin
Plugin for adding custom property editors on the inspector.
class EditorResourceConversionPlugin
Plugin for adding custom converters from one resource format to another in the editor resource picker context menu; for example, converting a
StandardMaterial3D
to aShaderMaterial
.class EditorResourcePreviewGenerator
Custom generator of previews.
class EditorResourceTooltipPlugin
A plugin that advanced tooltip for its handled resource type.
class EditorSceneFormatImporter
Imports scenes from third-parties’ 3D files.
class EditorScenePostImport
Post-processes scenes after import.
class EditorScenePostImportPlugin
Plugin to control and modifying the process of importing a scene.
class EditorScript
Base script that can be used to add extension functions to the editor.
class EditorTranslationParserPlugin
Plugin for adding custom parsers to extract strings that are to be translated from custom files (.csv, .json etc.).
class EncodedObjectAsID
Holds a reference to an
Object
’s instance ID.class EngineProfiler
Base class for creating custom profilers.
class Expression
A class that stores an expression you can execute.
class FileAccess
Provides methods for file reading and writing operations.
class HMACContext
Used to create an HMAC for a message using a key.
class HTTPClient
Low-level hyper-text transfer protocol client.
class HashingContext
Provides functionality for computing cryptographic hashes chunk by chunk.
class ImageFormatLoader
Base class to add support for specific image formats.
class JavaClass
class JavaScriptObject
A wrapper class for web native JavaScript objects.
class KinematicCollision2D
Holds collision data from the movement of a
PhysicsBody2D
.class KinematicCollision3D
Holds collision data from the movement of a
PhysicsBody3D
.class Lightmapper
Abstract class extended by lightmappers, for use in
LightmapGI
.class MeshConvexDecompositionSettings
Parameters to be used with a
Mesh
convex decomposition operation.class MeshDataTool
Helper tool to access and edit
Mesh
data.class MultiplayerAPI
High-level multiplayer API interface.
class Mutex
class Node3DGizmo
Abstract class to expose editor gizmos for
Node3D
.class OggPacketSequencePlayback
class OpenXRAPIExtension
Makes the OpenXR API available for GDExtension.
class PCKPacker
Creates packages that can be loaded into a running project.
class PackedDataContainerRef
An internal class used by
PackedDataContainer
to pack nested arrays and dictionaries.class PacketPeer
Abstraction and base class for packet-based protocols.
class PhysicsPointQueryParameters2D
Provides parameters for
intersectPoint(parameters:maxResults:)
.class PhysicsPointQueryParameters3D
Provides parameters for
intersectPoint(parameters:maxResults:)
.class PhysicsRayQueryParameters2D
Provides parameters for
intersectRay(parameters:)
.class PhysicsRayQueryParameters3D
Provides parameters for
intersectRay(parameters:)
.class PhysicsShapeQueryParameters2D
Provides parameters for
intersectShape(parameters:maxResults:)
.class PhysicsShapeQueryParameters3D
Provides parameters for
intersectShape(parameters:maxResults:)
.class PhysicsTestMotionParameters2D
Provides parameters for
bodyTestMotion(body:parameters:result:)
.class PhysicsTestMotionParameters3D
Provides parameters for
bodyTestMotion(body:parameters:result:)
.class PhysicsTestMotionResult2D
Describes the motion and collision result from
bodyTestMotion(body:parameters:result:)
.class PhysicsTestMotionResult3D
Describes the motion and collision result from
bodyTestMotion(body:parameters:result:)
.class RDAttachmentFormat
Attachment format (used by
RenderingDevice
).class RDFramebufferPass
Framebuffer pass attachment description (used by
RenderingDevice
).class RDPipelineColorBlendState
Pipeline color blend state (used by
RenderingDevice
).class RDPipelineColorBlendStateAttachment
Pipeline color blend state attachment (used by
RenderingDevice
).class RDPipelineDepthStencilState
Pipeline depth/stencil state (used by
RenderingDevice
).class RDPipelineMultisampleState
Pipeline multisample state (used by
RenderingDevice
).class RDPipelineRasterizationState
Pipeline rasterization state (used by
RenderingDevice
).class RDPipelineSpecializationConstant
Pipeline specialization constant (used by
RenderingDevice
).class RDSamplerState
Sampler state (used by
RenderingDevice
).class RDShaderSource
Shader source code (used by
RenderingDevice
).class RDTextureFormat
Texture format (used by
RenderingDevice
).class RDTextureView
Texture view (used by
RenderingDevice
).class RDUniform
Shader uniform (used by
RenderingDevice
).class RDVertexAttribute
Vertex attribute (used by
RenderingDevice
).class RandomNumberGenerator
Provides methods for generating pseudo-random numbers.
class RegEx
Class for searching text for patterns using regular expressions.
class RegExMatch
Contains the results of a
RegEx
search.class RenderSceneBuffers
Abstract scene buffers object, created for each viewport for which 3D rendering is done.
class RenderSceneBuffersConfiguration
Configuration object used to setup a
RenderSceneBuffers
object.class Resource
Base class for serializable objects.
class ResourceFormatLoader
Loads a specific resource type from a file.
class ResourceFormatSaver
Saves a specific resource type to a file.
class ResourceImporter
Base class for resource importers.
class SceneState
Provides access to a scene file’s information.
class SceneTreeTimer
One-shot timer.
class Semaphore
A synchronization mechanism used to control access to a shared resource by
Thread
s.class SkinReference
class StreamPeer
Abstract base class for interacting with streams.
class SurfaceTool
Helper tool to create geometry.
class TCPServer
A TCP server.
class TLSOptions
TLS configuration for clients and servers.
class TextLine
Holds a line of text.
class TextParagraph
Holds a paragraph of text.
class TextServer
A server interface for font management and text rendering.
class Thread
A unit of execution in a process.
class TriangleMesh
Internal mesh type.
class Tween
Lightweight object used for general-purpose animation via script, using
Tweener
s.class Tweener
Abstract class for all Tweeners used by
Tween
.class UDPServer
Helper class to implement a UDP server.
class UPNP
Universal Plug and Play (UPnP) functions for network device discovery, querying and port forwarding.
class UPNPDevice
Universal Plug and Play (UPnP) device.
class WeakRef
Holds an
Object
. If the object isRefCounted
, it doesn’t update the reference count.class WebRTCPeerConnection
Interface to a WebRTC peer connection.
class XMLParser
Provides a low-level interface for creating parsers for XML files.
class XRInterface
Base class for an XR interface implementation.
class XRPose
This object contains all data related to a pose on a tracked object.
class XRPositionalTracker
A tracked object.
class ZIPPacker
Allows the creation of zip files.
class ZIPReader
Allows reading the content of a zip file.