class_reference.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Reference.xml.
  6. .. _class_Reference:
  7. Reference
  8. =========
  9. **Inherits:** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`AESContext<class_AESContext>`, :ref:`AnimationTrackEditPlugin<class_AnimationTrackEditPlugin>`, :ref:`ARVRInterface<class_ARVRInterface>`, :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>`, :ref:`AStar<class_AStar>`, :ref:`AStar2D<class_AStar2D>`, :ref:`AudioEffectInstance<class_AudioEffectInstance>`, :ref:`AudioStreamPlayback<class_AudioStreamPlayback>`, :ref:`CameraFeed<class_CameraFeed>`, :ref:`CharFXTransform<class_CharFXTransform>`, :ref:`ConfigFile<class_ConfigFile>`, :ref:`Crypto<class_Crypto>`, :ref:`Directory<class_Directory>`, :ref:`DTLSServer<class_DTLSServer>`, :ref:`EditorExportPlugin<class_EditorExportPlugin>`, :ref:`EditorFeatureProfile<class_EditorFeatureProfile>`, :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>`, :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>`, :ref:`EditorResourcePreviewGenerator<class_EditorResourcePreviewGenerator>`, :ref:`EditorSceneImporter<class_EditorSceneImporter>`, :ref:`EditorScenePostImport<class_EditorScenePostImport>`, :ref:`EditorScript<class_EditorScript>`, :ref:`EncodedObjectAsID<class_EncodedObjectAsID>`, :ref:`Expression<class_Expression>`, :ref:`File<class_File>`, :ref:`FuncRef<class_FuncRef>`, :ref:`GDNative<class_GDNative>`, :ref:`GDScriptFunctionState<class_GDScriptFunctionState>`, :ref:`HashingContext<class_HashingContext>`, :ref:`HMACContext<class_HMACContext>`, :ref:`HTTPClient<class_HTTPClient>`, :ref:`JavaClass<class_JavaClass>`, :ref:`JavaScriptObject<class_JavaScriptObject>`, :ref:`JSONParseResult<class_JSONParseResult>`, :ref:`KinematicCollision<class_KinematicCollision>`, :ref:`KinematicCollision2D<class_KinematicCollision2D>`, :ref:`MeshDataTool<class_MeshDataTool>`, :ref:`MultiplayerAPI<class_MultiplayerAPI>`, :ref:`Mutex<class_Mutex>`, :ref:`PackedDataContainerRef<class_PackedDataContainerRef>`, :ref:`PacketPeer<class_PacketPeer>`, :ref:`PCKPacker<class_PCKPacker>`, :ref:`Physics2DShapeQueryParameters<class_Physics2DShapeQueryParameters>`, :ref:`Physics2DTestMotionResult<class_Physics2DTestMotionResult>`, :ref:`PhysicsShapeQueryParameters<class_PhysicsShapeQueryParameters>`, :ref:`PhysicsTestMotionResult<class_PhysicsTestMotionResult>`, :ref:`RandomNumberGenerator<class_RandomNumberGenerator>`, :ref:`RegEx<class_RegEx>`, :ref:`RegExMatch<class_RegExMatch>`, :ref:`Resource<class_Resource>`, :ref:`ResourceFormatLoader<class_ResourceFormatLoader>`, :ref:`ResourceFormatSaver<class_ResourceFormatSaver>`, :ref:`ResourceImporter<class_ResourceImporter>`, :ref:`ResourceInteractiveLoader<class_ResourceInteractiveLoader>`, :ref:`SceneState<class_SceneState>`, :ref:`SceneTreeTimer<class_SceneTreeTimer>`, :ref:`SceneTreeTween<class_SceneTreeTween>`, :ref:`Semaphore<class_Semaphore>`, :ref:`SkinReference<class_SkinReference>`, :ref:`SpatialGizmo<class_SpatialGizmo>`, :ref:`SpatialVelocityTracker<class_SpatialVelocityTracker>`, :ref:`StreamPeer<class_StreamPeer>`, :ref:`SurfaceTool<class_SurfaceTool>`, :ref:`TCP_Server<class_TCP_Server>`, :ref:`Thread<class_Thread>`, :ref:`TriangleMesh<class_TriangleMesh>`, :ref:`Tweener<class_Tweener>`, :ref:`UDPServer<class_UDPServer>`, :ref:`UPNP<class_UPNP>`, :ref:`UPNPDevice<class_UPNPDevice>`, :ref:`VisualScriptFunctionState<class_VisualScriptFunctionState>`, :ref:`WeakRef<class_WeakRef>`, :ref:`WebRTCPeerConnection<class_WebRTCPeerConnection>`, :ref:`XMLParser<class_XMLParser>`
  11. Base class for reference-counted objects.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Base class for any object that keeps a reference count. :ref:`Resource<class_Resource>` and many other helper objects inherit this class.
  16. Unlike other :ref:`Object<class_Object>` types, 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<class_Object_method_free>`.
  17. 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.
  18. \ **Note:** In C#, references will not be freed instantly after they are no longer in use. Instead, garbage collection will run periodically and will free references that are no longer in use. This means that unused references will linger on for a while before being removed.
  19. .. rst-class:: classref-introduction-group
  20. Tutorials
  21. ---------
  22. - :doc:`When and how to avoid using nodes for everything <../tutorials/best_practices/node_alternatives>`
  23. .. rst-class:: classref-reftable-group
  24. Methods
  25. -------
  26. .. table::
  27. :widths: auto
  28. +-------------------------+--------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`init_ref<class_Reference_method_init_ref>` **(** **)** |
  30. +-------------------------+--------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`reference<class_Reference_method_reference>` **(** **)** |
  32. +-------------------------+--------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`unreference<class_Reference_method_unreference>` **(** **)** |
  34. +-------------------------+--------------------------------------------------------------------+
  35. .. rst-class:: classref-section-separator
  36. ----
  37. .. rst-class:: classref-descriptions-group
  38. Method Descriptions
  39. -------------------
  40. .. _class_Reference_method_init_ref:
  41. .. rst-class:: classref-method
  42. :ref:`bool<class_bool>` **init_ref** **(** **)**
  43. Initializes the internal reference counter. Use this only if you really know what you are doing.
  44. Returns whether the initialization was successful.
  45. .. rst-class:: classref-item-separator
  46. ----
  47. .. _class_Reference_method_reference:
  48. .. rst-class:: classref-method
  49. :ref:`bool<class_bool>` **reference** **(** **)**
  50. Increments the internal reference counter. Use this only if you really know what you are doing.
  51. Returns ``true`` if the increment was successful, ``false`` otherwise.
  52. .. rst-class:: classref-item-separator
  53. ----
  54. .. _class_Reference_method_unreference:
  55. .. rst-class:: classref-method
  56. :ref:`bool<class_bool>` **unreference** **(** **)**
  57. Decrements the internal reference counter. Use this only if you really know what you are doing.
  58. Returns ``true`` if the decrement was successful, ``false`` otherwise.
  59. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  60. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  61. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  62. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`