The World Doesn't Have To End

Custom C# Resources in Godot

Godot Nov 11, 2021

When trying to create a custom resource with gdscript in Godot, the steps are thoroughly documented, few, and easy to follow and remember. If the same steps are followed using C# as your language of choice, then it does not work. You will never be able to create a new instance of that custom resource... unless....

Create your C# Resource is the same manner that you would a gdscript version. Create a C# script that inherits from Resource and then hit the Create button to save it where you want.

Godot Custom C# Resource Script Creation
Create Custom C# Resource Script

Open the new Custom C# Resource and set it up as needed. I will make a simple one here that has a few fields in it. Save it when done.

Custom Player C# Resource Script

Hit the build button in the top right of Godot to compile your new resource.

Resource Inspector Menu Buttons

Now when you right-click in the FileSystem area and select "New Resource...", The Create New Resource Window pops up, but you can not find your new Custom C# Resource in the list.

Select the Basic Resource instead. Name it want you want and save it.

Creating a Resouce in Godot

Select your new Resource so that it loads up in the Inspector on the right (right is the default placement for the inspector in Godot).

Now you can use the dropdown menu for the Script property to load your Custom C# Resource script, or simply drag and drop it in to the box labeled "empty".

Custom Resource Inspector

Make sure to rave the Resource once done by clicking that little disk icon in the inspector.

Save Custom Resource Icon

Now you have an instance of your Custom C# Resource, but also the knowledge on how to make as many more as your hearts desire. While I have not had any problems doing it this way, this is not the official way of creating Custom Resource and problems may arise.

Join me in crossing your fingers I guess.

YouTube Video For the Visual Learners.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.