Thank you soooo much. I was trying to figure out how to stop my tutorial after switching from one scene back to the original and this method helped me out.
Hey there - this is actually a very bad way to do things. This will not work in a build. If you want to use scriptable objects to reference persistent data, you will need a way to save and load the values from disk and into the instanced copy of the SO in memory.
This tutorial isn't about persisting data to disk, it's about having some data that can easily live between scenes. You could load values from disk to initialize the data in OnEnable, or some other place.
@@RestfulCoder I'm sorry to say, it still will not retain data. The moment the scene is unloaded, it will unload the SO from memory, then when the scene is loaded again, it will revert to it's default state. A better example for this video would be to have a singleton which is told not to destroy on load that holds an instance of the SO. Then in this SO it can hold an array of LevelInfo structs which store things such as visit state, score, time played etc. Then when a level loads, it could query the singleton.LevelInfo[id] - this would still show a good use case for scriptable objects, and be more relevent. This example you have shown will not work in a build.
Yep. This will only work throughout the editor. Once you go to build the game -- the SO will never be persistently updated & saved. SO in a build will only retain the information it had when the game was built. The reason this works in the editor is because it updates in the editor. That goes away completely once you build the game. I know this because my group ran into this issue towards the end of the semester thinking that we had everything working until we went to build the game... Our whole character creation system never actually retained the updated data after closing the game.
As a software engineer who has always been curious about creating pixel games, this is incredible. Please keep up with this series! I'd love to see how you add things like menus and sprite animations. btw, just subbed to your channel.
Nice tutorial video sir, i see there is a script that support the switching scene feature. Do you have any video that teach about how to moving scenes in Unity ? Love the way u setup the entrance and the exir
Thanks a lot for this tutorial but this isn’t the best way to store game data. This should be use to set variables to gameObject and it will check if it is true or equal to an number. Using “Files” in binary is the best way to store your data. But this is the best way to store data for beginners. This method works still but not the best :)
That could be the case, I'm not sure. It's worth looking into more if you're far enough along that you're making regular builds. I no longer use Unity so can't advise.
@Pixelgraft I got tired of learning a framework that kept changing and getting slower. I've been focusing on C++ and SDL2 which are straightforward programming and unlikely to change.
Great video. I used don't destroyOnLoad in my games project, I will use scriptable object now. Also, what's the name of the autocompltion add-on you are using?
Note: This is NOT a solution for permanently saving game data. This only holds onto state in memory.
what would a good solution be? singletons or dont destroyonload?
Thank you soooo much. I was trying to figure out how to stop my tutorial after switching from one scene back to the original and this method helped me out.
Hey there - this is actually a very bad way to do things. This will not work in a build. If you want to use scriptable objects to reference persistent data, you will need a way to save and load the values from disk and into the instanced copy of the SO in memory.
This tutorial isn't about persisting data to disk, it's about having some data that can easily live between scenes. You could load values from disk to initialize the data in OnEnable, or some other place.
@@RestfulCoder I'm sorry to say, it still will not retain data. The moment the scene is unloaded, it will unload the SO from memory, then when the scene is loaded again, it will revert to it's default state. A better example for this video would be to have a singleton which is told not to destroy on load that holds an instance of the SO. Then in this SO it can hold an array of LevelInfo structs which store things such as visit state, score, time played etc. Then when a level loads, it could query the singleton.LevelInfo[id] - this would still show a good use case for scriptable objects, and be more relevent. This example you have shown will not work in a build.
Yep. This will only work throughout the editor. Once you go to build the game -- the SO will never be persistently updated & saved. SO in a build will only retain the information it had when the game was built. The reason this works in the editor is because it updates in the editor. That goes away completely once you build the game. I know this because my group ran into this issue towards the end of the semester thinking that we had everything working until we went to build the game... Our whole character creation system never actually retained the updated data after closing the game.
As a software engineer who has always been curious about creating pixel games, this is incredible. Please keep up with this series! I'd love to see how you add things like menus and sprite animations.
btw, just subbed to your channel.
Thanks!
Nice tutorial video sir, i see there is a script that support the switching scene feature. Do you have any video that teach about how to moving scenes in Unity ? Love the way u setup the entrance and the exir
Thanks a lot for this tutorial but this isn’t the best way to store game data. This should be use to set variables to gameObject and it will check if it is true or equal to an number. Using “Files” in binary is the best way to store your data. But this is the best way to store data for beginners. This method works still but not the best :)
thx you helped me with my challange but i had some troubles because i made a cutscene be a another scene
This was super helpful! Thank you for sharing this.
I heard that scriptable objects aren't meant to have their data changed, and will cause errors when running the built game.
That could be the case, I'm not sure. It's worth looking into more if you're far enough along that you're making regular builds. I no longer use Unity so can't advise.
Great tutorial. Why are you not using Unity any longer? Switch to something else?@@RestfulCoder
@Pixelgraft I got tired of learning a framework that kept changing and getting slower. I've been focusing on C++ and SDL2 which are straightforward programming and unlikely to change.
Great video. I used don't destroyOnLoad in my games project, I will use scriptable object now. Also, what's the name of the autocompltion add-on you are using?
my project trouble camera was change everytime while it start
i use u script and method
I no longer use Unity so can't advise.
Hi ? i hope you can reply to me i want to know how can i follow the camera to my player after changing scene
Look into "dontdestroyonload" and you will find the answer to your questions. It saves a gameobject between scenes.
Not good my friend