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 /
avatar image
1
Question by valdelievre · Jan 14, 2013 at 04:40 PM · sceneserializationjsonxml

[SCREENSHOTS]Save scenes using XML/json descriptor

Hello,

I have a concern with the game i have created and the way i load all the levels. The game is on playstore here so you can understand the concept and what i want to achieve. It is a physic game where a sheep needs to eat all the mushrooms. Each level is really simple, it contains

  • Some bars

  • Mushrooms

  • A sheep( the Hero )

  • Some Objects which move like Bombs

  • Moving Enemies

For the moment, When you want to Play with Level 1-1,see below what's happening:

  • Application.Load("level_1_1");

  • In each level(each scene), i have an object called LoadLevelAddictive containing a script calling Application.LoadLevelAdditive("commonObjects"); This is a scene including all the common objects between all my 45 levels like, a leaderboard , some common panel, some backgrounds

PROS to do it that way

  • I design all my levels using the editor.

  • When i am happy with a level i have created, i save it through the editor like Save As 'Level_1_2.unity'. It is really straightforward.

CONS to do it that way

  • I have realized this is extremely slow to load a level( like 2sec ) on a device.

  • When a user wants to restart the level, i use Application.Load("level_1_1"), slow, it should be instant.

  • I also wanted to do a level editor but since my levels are saved in a scene format, i won't be able to achieve that.

Questions:

  1. What are the steps to migrate my existing level system ( scene based ) using json/XML descriptor ? (This look promising)

  2. If i finally manage to save my levels in json/XML, how to design/view my levels ?

I have attached 2 screenshots so everybody will understand what is my current solution.

  • Level_1_1.unity.jpg is the level 1 of the world 1 of the game. This only includes what differs between each level

  • CommonObjects.jpg is the scene that includes all my common objects.

If someone has a solution design or some ideas, it would be greatly appreciated

alt text alt text

commonobjects.jpg (345.6 kB)
level_1_1.jpg (228.1 kB)
Comment
Add comment · Show 2
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 · Jan 15, 2013 at 09:41 AM 0
Share

(@valdelievre has P$$anonymous$$'d me to ask if UnitySerializer fits this use case)

So you certainly could use UnitySerializer to save these levels - but there are several caveats:

  • Unity Serializer in normal "save everything mode" does a level load at the beginning of resu$$anonymous$$g the data to get the original clean state back (obviously this is normally a pretty empty level if you are building a level designer and hence not too slow).

  • Anything that saves/loads individual objects has to then instantiate them on resumption and this can be costly in terms of performance

The time it takes to load a level is mostly in the setup and instantiation after the file is loaded into memory - I've yet to get a clear idea of what this is doing precisely from Unity, but if you do a LoadLevelAsync there is still usually a big pause if there is much going on with the level.

If you use Unity Serializer you would be better off using Binary mode for performance, the resulting files are not human readable (or really parsable with anything except Unity) but work as efficiently as they can without being specific to the individual project.

I'd be interested to know how many things exist in a level than takes a long time to load and whether you have any feeling for which items are impacting the performance. You can use Unity Serializer to reset individual objects for instance (without the need for it reloading the whole level, but this would be quite intricate work).

avatar image valdelievre · Jan 15, 2013 at 11:25 AM 0
Share

Hello $$anonymous$$ike,

Thank you very much for your answer. In a near future, i wanted to implement few things :

  • Faster loading between levels

I don't think UnitySerializer will help me to do that. I need to understand where is the cumbersome. What i was thinking is to put all the objects from "commonObjects" scene in one prefab. It will be slow to load the first time ( 2sec ), then i would just need to DontDestroyOnLoad this prefab each time the user change the level. What do you reckon ?

  • Instant level restart

I think UnitySerializer could have an important part in here. When the user want to play with level_1_1, i won't use Application.Load but rather your deserialization process. As far as i understood, UnitySerializer will load the scene level_1_1.unity automatically. What i need to do is to save each scenes using UnitySerializer ( binary, xml or whatetever your tool allows me to do ) When the end user wants to restart the level, I think it will automatically deserialize, resetting the level to his initial state, it should almost be instant. Do you agree ?

  • A level editor where people can create and share their own levels.

I think it will almost works like my previous point. The end-user design the levels, Press Save and it will serialize the level in a file

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

What are the pros and cons of ScriptableObjects vs. JSON for data files? 2 Answers

Deserializing dictionary with 'Json.Net' for Unity returns a null object. 0 Answers

Is it possible to serialize UnityEvent through reflection? 1 Answer

Parsing "complex" json 1 Answer

Best Practice for Language System 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