Update Resources tutorial to mention and use the GlobalClass annotation for C# (#9278)

* Updated Resources tutorial to mention and use the GlobalClass annotation for C#

The previous version of this page didn't mention using the `[GlobalClass]` annotation. Following this tutorial results in the user not finding their resource in the Create a new resource menu without any understanding as to why

---------

Co-authored-by: Paul Joannon <437025+paulloz@users.noreply.github.com>
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
This commit is contained in:
j4d3blooded
2024-04-30 03:16:52 +01:00
committed by GitHub
parent 63a9187c35
commit 47427a526c

View File

@@ -208,6 +208,9 @@ It should appear in your file tab with the full name ``bot_stats.tres``.
Without a script, it's useless, so let's add some data and logic!
Attach a script to it named ``bot_stats.gd`` (or just create a new script, and then drag it to it).
.. note::
If you're using C#, you need to annotate your Resource class with the ``[GlobalClass]`` attribute for it to show up in the create resource GUI.
.. tabs::
.. code-tab:: gdscript GDScript
@@ -232,6 +235,7 @@ Attach a script to it named ``bot_stats.gd`` (or just create a new script, and t
namespace ExampleProject
{
[GlobalClass]
public partial class BotStats : Resource
{
[Export]
@@ -330,6 +334,7 @@ Now, select the :ref:`CharacterBody3D <class_CharacterBody3D>` node which we nam
using Godot;
[GlobalClass]
public partial class BotStatsTable : Resource
{
private Godot.Dictionary<string, BotStats> _stats = new Godot.Dictionary<string, BotStats>();
@@ -384,6 +389,7 @@ Now, select the :ref:`CharacterBody3D <class_CharacterBody3D>` node which we nam
public partial class MyNode : Node
{
[GlobalClass]
public partial class MyResource : Resource
{
[Export]