Forráskód Böngészése

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 <[email protected]>
Co-authored-by: A Thousand Ships <[email protected]>
j4d3blooded 1 éve
szülő
commit
47427a526c
1 módosított fájl, 6 hozzáadás és 0 törlés
  1. 6 0
      tutorials/scripting/resources.rst

+ 6 - 0
tutorials/scripting/resources.rst

@@ -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]