- Home /
Save cloned prefabs
For my Final Project. I have a game where when the player presses a button, it clones a prefab into a random position. I tries using player prefs to save the cloned object's position but it doesn't work. How do I save the cloned prefabs? Also how can I save if the prefab is destroyed? Thanks
Answer by hameed-ullah-jan · Apr 08, 2019 at 12:50 PM
you can use these things to save a value or position permanently : 1. you can write the position of the prefab to a txt file (see file handling in unity) 2. you can save to json file 3. you can also user playerprefes, but for each position you have to use 3 float playerprefs: something like this: PlayerPrefes.Setfloat("x", your x-axis value); PlayerPrefes.Setfloat("y", your y-axis value); PlayerPrefes.Setfloat("z", your z-axis value);
when i am click first(image) button then spawning some images, when i am click second button(images) then replace with the first images?? (fetch the data of json)
I have the playerprefs saver for position, but when I restart the game, they dissapear. how would I save if the prefab is cloned or destroyed and load or dont load it again on start? thanks
Your answer
Follow this Question
Related Questions
Is it safe to save values in a prefab instead of using PlayerPrefs? 0 Answers
Instantiate a prefab just one time 1 Answer
Playerprefs save player position 3 Answers
high scores scene 2 Answers
PlayerPrefs for FPS? 1 Answer