:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Reference.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Reference: Reference ========= **Inherits:** :ref:`Object` **Inherited By:** :ref:`ARVRInterface`, :ref:`AStar`, :ref:`AStar2D`, :ref:`AnimationTrackEditPlugin`, :ref:`AudioEffectInstance`, :ref:`AudioStreamPlayback`, :ref:`CameraFeed`, :ref:`CharFXTransform`, :ref:`ConfigFile`, :ref:`Crypto`, :ref:`DTLSServer`, :ref:`Directory`, :ref:`EditorExportPlugin`, :ref:`EditorFeatureProfile`, :ref:`EditorInspectorPlugin`, :ref:`EditorResourceConversionPlugin`, :ref:`EditorResourcePreviewGenerator`, :ref:`EditorSceneImporter`, :ref:`EditorScenePostImport`, :ref:`EditorScript`, :ref:`EncodedObjectAsID`, :ref:`Expression`, :ref:`File`, :ref:`FuncRef`, :ref:`GDNative`, :ref:`GDScriptFunctionState`, :ref:`HTTPClient`, :ref:`HashingContext`, :ref:`JSONParseResult`, :ref:`JavaClass`, :ref:`KinematicCollision`, :ref:`KinematicCollision2D`, :ref:`MeshDataTool`, :ref:`MultiplayerAPI`, :ref:`Mutex`, :ref:`PCKPacker`, :ref:`PackedDataContainerRef`, :ref:`PacketPeer`, :ref:`Physics2DShapeQueryParameters`, :ref:`Physics2DShapeQueryResult`, :ref:`Physics2DTestMotionResult`, :ref:`PhysicsShapeQueryParameters`, :ref:`PhysicsShapeQueryResult`, :ref:`RandomNumberGenerator`, :ref:`RegEx`, :ref:`RegExMatch`, :ref:`Resource`, :ref:`ResourceFormatLoader`, :ref:`ResourceFormatSaver`, :ref:`ResourceImporter`, :ref:`ResourceInteractiveLoader`, :ref:`SceneState`, :ref:`SceneTreeTimer`, :ref:`Semaphore`, :ref:`SkinReference`, :ref:`SpatialGizmo`, :ref:`SpatialVelocityTracker`, :ref:`StreamPeer`, :ref:`SurfaceTool`, :ref:`TCP_Server`, :ref:`Thread`, :ref:`TriangleMesh`, :ref:`UDPServer`, :ref:`UPNP`, :ref:`UPNPDevice`, :ref:`VisualScriptFunctionState`, :ref:`WeakRef`, :ref:`WebRTCPeerConnection`, :ref:`XMLParser` Base class for reference-counted objects. Description ----------- Base class for any object that keeps a reference count. :ref:`Resource` and many other helper objects inherit this class. Unlike :ref:`Object`\ s, References keep an internal reference counter so that they are automatically released when no longer in use, and only then. References therefore do not need to be freed manually with :ref:`Object.free`. In the vast majority of use cases, instantiating and using ``Reference``-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. Tutorials --------- - :doc:`../getting_started/workflow/best_practices/node_alternatives` Methods ------- +-------------------------+--------------------------------------------------------------------+ | :ref:`bool` | :ref:`init_ref` **(** **)** | +-------------------------+--------------------------------------------------------------------+ | :ref:`bool` | :ref:`reference` **(** **)** | +-------------------------+--------------------------------------------------------------------+ | :ref:`bool` | :ref:`unreference` **(** **)** | +-------------------------+--------------------------------------------------------------------+ Method Descriptions ------------------- .. _class_Reference_method_init_ref: - :ref:`bool` **init_ref** **(** **)** Initializes the internal reference counter. Use this only if you really know what you are doing. Returns whether the initialization was successful. ---- .. _class_Reference_method_reference: - :ref:`bool` **reference** **(** **)** Increments the internal reference counter. Use this only if you really know what you are doing. Returns ``true`` if the increment was successful, ``false`` otherwise. ---- .. _class_Reference_method_unreference: - :ref:`bool` **unreference** **(** **)** Decrements the internal reference counter. Use this only if you really know what you are doing. Returns ``true`` if the decrement was successful, ``false`` otherwise. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`