mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user