Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

A workaround for the limitation of the missing `class_name` from gdscript.

License

Notifications You must be signed in to change notification settings

m50/Godot-CSharp-Node-Exports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# class_name for Godot

In gdscript in Godot, you can use class_name Name, "res://path/to/icon.png" and the class will export into the editor. However, in C# this isn't really possible.

As such, this can be used to work around that issue.

Example:

using ClassName.Attributes;
using Godot;

[ClassName, Icon("res://Path/To/PlantIcon.png")]
public class Plant : Sprite
{
    //...
}

Screenshot of editor

As you can see here, we have exported the MySprite type and added an icon to it.

Another example:

using ClassName.Attributes;
using Godot;

[ClassName, Icon("res://Path/To/Icon.png")]
public class MyResource : Resource
{
    //...
}

Reloads happen whenever a resource is saved (though, this is undocumented in Godot so can't guarantee how it works), or can be done manually in Project > Tools > Reload C# Resources.

Since this plugin interacts with the rest of your code, it is required to be referenced in your csproj file.

<Compile Include="addons/**/*.cs" Condition=" '$(Configuration)' == 'Debug' " />

Thanks To:

  • Spartan322 - For the code review and help cleaning up the API.

About

A workaround for the limitation of the missing `class_name` from gdscript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages