Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by GHM_Games · Jul 11, 2016 at 12:03 AM · saveloading

Save Data Doubled

I have been following this saving and loading tutorial using XML, I have spent all day trying to fix an issue I am having. I know that it will be hard to diagnose, but any help would be much appreciated.

https://www.youtube.com/watch?v=Y8Di-Q6qpU4&list=LLyz8M113feE2UY5kwTDs2gA∈dex=4

The issue I am having is that I can save, then load, but when I save again, my save data is doubled, resulting in duplicates of my objects. I have determined it is not a filemode issue, because when I save multiple times, it does not double multiple times, only once. And I have tried filemode.Open, and filemode.Create, and gotten the same results. I think it is something with the ActorContainer saving objects from the first save that were deleted when loading, but that did not seem to be the issue either, due to issue occurring even if I reloaded the scene each time I saved. I am really at my wits end with this, and honestly I am not expecting to have this answered, I just cannot think of anything else to try.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GHM_Games · Jul 11, 2016 at 08:32 PM 0
Share

I FIXED IT, to anyone else following this tutorial, to fix this issue, run ClearActors(); before and after OnBeforeSave(); and add public static void RemoveActorData(ActorData data) { actorContainer.actors.Remove(data); } to your SaveData.cs and also, on your actor component, add a void OnDestroy(), and use SaveData.OnBeforeSave += delegate { SaveData.RemoveActorData(data); }; ins$$anonymous$$d of SaveData.OnBeforeSave -= delegate { SaveData.AddActorData(data); };

for both OnDestroy() and OnDisable(),

this fixes the issue of the actors not being removed hence "doubling" data. Also I suggest deleting all of your actor objects BEFORE loading new ones, example : loadButton.onClick.AddListener(delegate { DeleteAll(); }); BEFORE loadButton.onClick.AddListener(delegate { SaveData.Load(dataPath); });

and having a DeleteAll () function just search for all objects with the actor component and destroy them.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GHM_Games · Jul 11, 2016 at 12:08 AM

If it is a file error, is there a way to erase the data from my file before it is doubled, hence making the "doubled" data singular?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GHM_Games · Jul 11, 2016 at 07:54 PM 0
Share

I know I won't get an answer for this but I just want to rant for a second here, I downloaded my tutorial's project and tested it out and got the exact same error. You cannot save in a loaded game, if you do, everything is doubled. This is a huge error and practically ruins the whole function of saving due to the ability to only save once. Did they not notice this? Unity also has documentation that uses the same code and most likely has the same issue? Why advertise this as a working saving solution, it doesn't work at all! I have tried for two days straight now anything I can think of and I still get the same issue. It is extremely frustrating and a huge waste of my time, I am very disappointed.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

61 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Teleport Objects to original position 1 Answer

Save and load player position in main scene 1 Answer

PlayerPrefs working on PC but not on Android. [2020] 0 Answers

Loading Images on iOS vs Standalone Build 0 Answers

How can I save level progression 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges