Skip to content

Fix Unity stripping ISaveDataLocation classes in some cases#33

Closed
NoixDeXydre wants to merge 1 commit into
CarterGames:contributionfrom
Gardens-Lies:fix-save
Closed

Fix Unity stripping ISaveDataLocation classes in some cases#33
NoixDeXydre wants to merge 1 commit into
CarterGames:contributionfrom
Gardens-Lies:fix-save

Conversation

@NoixDeXydre
Copy link
Copy Markdown
Contributor

@NoixDeXydre NoixDeXydre commented May 14, 2026

When using SaveManager.SaveGame(), this error can occur in runtime :

[GetDefinedType]: Failed to generate type from stored data. If you have refactored the class selected, please reselect it to update the record.

It appears that with further research, the LocationHandler class is null revealing that there is no save location set (even through there is.)
Seems like Unity strips (if enabled in Project Settings) the ISaveDataLocation classes for some reason. This is fixed by adding the [Preserve] decoration from UnityEngine.Scripting

I think it needs more testing because I couldn't reproduce this issue with Unity 6.4 (it's happening for my project in Unity 6.6 Alpha.)
If this true in any versions of Unity, it should be documented as well to avoid confusions.

@JonathanMCarter JonathanMCarter self-assigned this May 14, 2026
@JonathanMCarter JonathanMCarter added bug Something isn't working 3.x Anything related to the 3.x.x versions of the asset. enhancement New feature or request labels May 14, 2026
@JonathanMCarter
Copy link
Copy Markdown
Member

JonathanMCarter commented May 14, 2026

Hi

This is a good spot, will likely get a little time this evening to look at it proper.

Thanks for flagging

J,

@NoixDeXydre
Copy link
Copy Markdown
Contributor Author

NoixDeXydre commented May 14, 2026

Hm I might commit again to this PR because I think #34 null issue is linked to ISaveBackupLocation inclusion.
I still don't know why code is stripped tho.

@JonathanMCarter
Copy link
Copy Markdown
Member

Cool, #34 is fine regardless as its a good safety check to have if the user randomly has no backup handler assigned. So I'm happy to have that either way xD

As for this. I think I may sort a global link.xml file to sort this. Just reading up on it now, as it'd avoid having to place attributes in a load of places in most cases.

@NoixDeXydre
Copy link
Copy Markdown
Contributor Author

Oh alright ^^
I agree with you, relying on link.xml looks much cleaner than using my solution.

@JonathanMCarter
Copy link
Copy Markdown
Member

Changes are in for the next release: https://github.com/CarterGames/SaveManager/tree/release/3.0.6
Probs releasing on the weekend proper when I get the time, I'm a bit busy tomorrow xD

@JonathanMCarter
Copy link
Copy Markdown
Member

Release now out, closing this PR as the link.xml bits are in there and should work....

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

Labels

3.x Anything related to the 3.x.x versions of the asset. bug Something isn't working enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

2 participants