- Home /
Gameobject can not save variable attached to it ?
Hello ! I have trouble that I cant save gameobject data. When i restart unity all data attached to gameobject will be lost.
When i save it and restart unity. Something like this happen
I dont know if there is connection. But i have some error like "Parser Failure at line 51: Expect ':' between key and value within mapping". But i dont know what is it ! Sorry for my bad english ! Thanks for Advice!
Have you tried to remove the component, restart Unity and attach the component again?
The serializer of Unity may have failed to serialize the gameObject and/or its components attached.
It looks more like a YA$$anonymous$$L parsing problem than the C# compilation problem that GubaLord is suggesting.
What version of Unity are you on? A quick google found this which could be relevant...
https://forum.unity.com/threads/case-1161290-parser-failure-at-line-x-expect-between-key-and-value-within-in-2019-3-0.695074/
Answer by GubaLord · Oct 11, 2019 at 10:46 AM
Yes it has connection.
Looks like you have a syntax error in your code at line 51. Find that line in the script (you can double click on the error and unity will take you there). Try to fix the error, or paste your code here so someone can try to fix it for you.
Until you have compile error in your scripts (even if it is only one) unity wont save the assigned fields (Or just wont load them until the errors are fixed? I do not remember, so correct me if I'm wrong).
Thanks you! But how to find the line in my code ? I try to double click on error but nothing happen. And I dont know, but seem like it only happen with string. When i try to not put string in object. (other int, button ,... have) it seem like save. But when i put 1 string in. Everything is fly away
The error should describe which script throws it. You can open that script with a coding program or with notepad (not advised). Then you can find line 57 by the line numbers on the left (or counting to it if you use notepad).
To be honest, I looked over your description a little hastily, and I have made a little mistake. Now I see that your error comes in runtime, not at compile. In this case I am not so sure about the connection of it to the field reseting. But fixing an error is never a bad thing :)
Thanks you! but my error look like this : "Unable to parse file Assets/Scenes/1773.unity: [Parser Failure at line 1954: Expect ':' between key and value within mapping]". I think the error happen to scene not Scripts ? $$anonymous$$y 1773 is a name of scene.