Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation on exportable C# native arrays #10332

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tutorials/scripting/c_sharp/c_sharp_exports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,14 @@ The default value of Godot dictionaries is null. A different default can be spec
Exporting C# arrays
^^^^^^^^^^^^^^^^^^^

C# arrays can exported as long as the element type is a :ref:`Variant-compatible type <c_sharp_variant_compatible_types>`.
..
See Godot.SourceGenerators.MarshalUtils.ConvertManagedTypeToMarshalType for the function which determines what can be marshalled

C# arrays can exported as long as it not multi-dimensional, and the element type is one of the following:

* A native C# ``byte``, ``int``/``Int32``, ``Int64``, ``float``, ``double``, or ``string``.
* Anything derived from ``GodotObject``.
* Godot's ``Vector2``, ``Vector3``, ``Vector4``, ``Color``, ``StringName``, ``NodePath``, or ``Rid``.

.. code-block:: csharp

Expand All @@ -583,6 +590,9 @@ C# arrays can exported as long as the element type is a :ref:`Variant-compatible
[Export]
public NodePath[] NodePaths { get; set; }

Other element types, even other :ref:`Variant-compatible types <c_sharp_variant_compatible_types>` such as ``Plane`` or ``Transform2D``, will not work.
If you get a :ref:`GD0102 <doc_c_sharp_diagnostics_gd0102>` error, use a ``Godot.Collections.Array`` instead.

The default value of C# arrays is null. A different default can be specified:

.. code-block:: csharp
Expand Down
2 changes: 2 additions & 0 deletions tutorials/scripting/c_sharp/diagnostics/GD0102.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _doc_c_sharp_diagnostics_gd0102:

GD0102: The type of the exported member is not supported
========================================================

Expand Down