I've created a custom resource script and would like to create an instance of it in my Filesystem. According to the docs, it seems I just need to create a class that extends Resource and the Godot editor should be able to find it. However, I've tried both compiling my code and restarting the editor and my resource is just not appearing in the Create New Resource menu that you get from clicking the New Resource icon in the Inspector menu. The language I'm using is C# and Godot version 3.3.4.

Am I missing something?

using Godot;
using System;

public class InventoryItem : Resource
{
    public string id = "";
    public string name = "";
    public string icon = "";
}


    Is the name of the file that the resource is in called InventoryItem.cs? When I’ve done some plugin work with C# I found the file name had to match the class name exactly or it wouldn’t work correctly with instancing in the Godot editor.

    Yes, the filename is an exact match, including case.

    Looks like there is a work around. If you create a basic Resource, you can then manually set it's Script parameter to your C# script and it will allow you to set the fields.

    There has been a bug filed about this but it has been open for a while now and it does not look like it will be fixed any time soon: https://github.com/godotengine/godot/issues/27470

    @kitfox said: Looks like there is a work around. If you create a basic Resource, you can then manually set it's Script parameter to your C# script and it will allow you to set the fields.

    There has been a bug filed about this but it has been open for a while now and it does not look like it will be fixed any time soon: https://github.com/godotengine/godot/issues/27470

    Good to know and thanks for sharing the workaround! Hopefully the bug will be fixed in the future so a workaround isn't required.

    a year later
    9 months later

    kitfox

    Add on top of Class [GlobalClass] It shows without any Addons.

    To like this
    using Godot;
    using System;
    [GlobalClass]
    public class InventoryItem : Resource
    {
    public string id = "";
    public string name = "";
    public string icon = "";
    }

    After that build a game and it will show you in Inspector window;
    Also dont forget to [export] varibles as id name etc before build.