Cannot add a script to any Entity in Game Studio

I have been making a small game in Xenko for the past few weeks but have just come accross a problem that I cannot seem to fix. If I attempt to add a script to an Entity in Game Studio then it does not work. Further more if I try to save the project immediatley after I get the following error: XenkoError
I think the project gets somehow corrupted when a script is added because deleting that problem entity will allow me to save the project again. Everything was working nicley until I made some code changes in visual studio to the inheritance structure of some scripts which were already attached to entities and when I came back into Game Studio all scripts had disappeared.

Things I have tried:

  • Undoing the code changes to how things were before the problems started
  • Creating a new project with a very simple test script and the problems somehow remain.
  • Reinstalled the latest version of Xenko from the launcher. Did not fix the problems.

Any suggestions to fix this problem? I am using Xenko 3.1.0.1 and am starting to run out of things to try.

Well it looks like I found the problem. I defined a public property in one of my scripts:

    public bool Visible
    {
        get { return sprite.Enabled; }
        set { sprite.Enabled = value; }
    }

Commenting out this property appears to fix all issues so I am guessing it is a name clashing issue or similar. I guess I should submit a bug report?

I have reported an issue on github here.

You should mark that property as non serialized. Otherwise you will have a NullReferenceException in the setter.

Yes I have made it non-serialized now and everything is back to normal and working fine. The reason I reported the bug though is that this piece of code essentially broke Game Studio by causing all scripts to be removed and preventing them from being re-added (Causing Game Stuido crashes in some cases). If the property throws an exception for some reason I would simply expect it to be ignored and an error logged or something similar. Also the reason I didn’t add null checks initially is that I am coming from a Unity background and forgot that properties were serialized in Xenko so I thought the code would only be executed at runtime when everything was initialized. I won’t be making that mistake again :expressionless: