Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Cant Load Custom resources. #45631

Closed
nonunknown opened this issue Feb 1, 2021 · 2 comments
Closed

C# Cant Load Custom resources. #45631

nonunknown opened this issue Feb 1, 2021 · 2 comments

Comments

@nonunknown
Copy link
Contributor

nonunknown commented Feb 1, 2021

Godot version:
3.2.4 beta 6 mono

OS/device including version:
Windows 10 x64

Issue description:
I've created a custom resource, but when loading, got a casting or invalid class name error.

image

Steps to reproduce:

  • Create a custom resource:
public class RStatistics : Resource
{
    
    [Export]
    public float timeAlive;

    [Export]
    public int kills,killStreak,oneHitKills,deaths,id;
}
  • On a scene, create a script, save and load it:
public class Test : Control
{
    public override void _Ready()
    {
        RStatistics r = new RStatistics();
        r.kills = 100;
        ResourceSaver.Save("test.tres",r);
        var loaded = ResourceLoader.Load("res://test.tres") as RStatistics; // also tried with ResourceLoader.Load<Rstatistics>() same error
        GD.Print(loaded.kills);
    }

}

Minimal reproduction project:

New Game Projects.zip

@paulloz
Copy link
Member

paulloz commented Feb 19, 2021

Hey 👋
This is not really a loading issue. It's the ResourceSave.Save miss handling the serialisation: #38191.

@akien-mga
Copy link
Member

Duplicate of #38191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants