Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by carter-carl30 · Jun 21, 2012 at 09:35 PM · positionprefabssaveloadstate

Help with Object position and state, save and load.

Hi, I have a number of "brick" prefabs in my scene (cubes with explosion script and scoretrigger scripts)

I have 4 prefabs, (all the bricks have been manually placed into my scene): bluebrick, greenbrick, redbrick & yellowbrick. Each are tagged with "brick".

What I want to be able to do is, when the player saves (from my pause menu), it stores each brick's position on screen and if it is destroyed or still there.

for example; if the player is playing and destroys 25/100 bricks and then saves the game, quits and reloads, the level will load and the 25/100 bricks will still be destroyed.

I have been searching for about a week and i'm just lost. Is there a way using PlayerPrefs to just save:

1) the position of the bricks. 2) whether it is there in scene or already been destroyed.

The latest thing I tried was using this script:

http://gamingirresponsibly.com/megabite-24-saving-and-loading

as you can see from my comment this didn't work out lol arrrgh!

please help

Comment
Add comment · Show 22
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 whydoidoit · Jun 21, 2012 at 09:46 PM 0
Share

Did you try out my Unity Serializer? I could help you trying to get that to work...

avatar image carter-carl30 · Jun 21, 2012 at 09:51 PM 0
Share

I had a look at it (i think it'd work) I watched your new video earlier. But I don't know how i'd fit it in with my save button on my pausemenu etc. I'm importing it now going to have a go at it :)

avatar image carter-carl30 · Jun 21, 2012 at 09:56 PM 0
Share

got this error when i imported it:

VerificationException: Error verifying TransformExtensions:LastAncestorOfType (UnityEngine.GameObject): Invalid generic method instantiation of method .Radical::FindImplementor (generic args don't respect target's constraints) at 0x001e UniqueIdentifier.FixName () (at Assets/Plugins/Serialization/UniqueIdentifier.cs:90) EditorNameFixer.Update () (at Assets/Plugins/Serialization/EditorNameFixer.cs:32)

avatar image whydoidoit · Jun 21, 2012 at 09:58 PM 0
Share

What from the asset store version???? Ugh - that's not supposed to have that file :(

avatar image whydoidoit · Jun 21, 2012 at 11:35 PM 1
Share

Sorry - I also added a damn mod to the code on that Asset Store package :( Right so just make it:

  LevelSerializer.SaveGame("BrickGame", false, null);
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by whydoidoit · Jun 21, 2012 at 11:57 PM

Solved by using Unity Serializer to store the position and existence of the bricks and added script to the pause menu to save and load the game.

 var paused : boolean = false; 
 var pausedGUI : GUITexture;  
 
 pausedGUI.enabled = false;
 
 function Update () 
 { 
     if(Input.GetKeyUp(KeyCode.P))
     { 
        paused = !paused;
 
         if(paused == true){
             Time.timeScale = 0.0;
             pausedGUI.enabled = true;
         } else {
             Time.timeScale = 1.0;
             pausedGUI.enabled = false;
         }
    }
 }
 
 function OnGUI() {
     if(!paused)
        return;
 
     var box : GUIStyle = "box";   
     GUILayout.BeginArea(Rect( Screen.width/2 - 200,Screen.height/2 - 300, 400, 600), box);
 
     GUILayout.BeginVertical(); 
     GUILayout.FlexibleSpace();
     if(GUILayout.Button("Save Game"))
     {
        LevelSerializer.SaveGame("BrickGame", false, null);
     }
     GUILayout.Space(60);
     for(var sg in LevelSerializer.SavedGames[LevelSerializer.PlayerName]) { 
        if(GUILayout.Button(sg.Caption)) { 
          sg.Load(); 
          Time.timeScale = 1;
          } 
     } 
     GUILayout.FlexibleSpace();
     GUILayout.EndVertical();
     GUILayout.EndArea();
 
 
 }
Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Character Positions Not Serializing or Loading Properly? 1 Answer

saving the game in position 1 Answer

How can I save and load a player's position? 5 Answers

how to save last position for the player before he die 2 Answers

How can playerprefs save my tower model and its position? 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