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
0
Question by Jeremy 2 · Jun 19, 2010 at 05:27 PM · terrainsaveloaddataheight

Saving a randomly generated Terrain

I have a randomly generated terrain and a functional Save/Load system using XML. In order to save the generated terrain, I tried serializing the heights in XML but it gives me an error (2d arrays aren't accepted as primitives). This is basically what I did :

var heights;

var xRes = Terrain.activeTerrain.terrainData.heightmapWidth; var yRes = Terrain.activeTerrain.terrainData.heightmapHeight; heights = Terrain.activeTerrain.terrainData.GetHeights(0, 0, xRes, yRes);

And then the data is serialized.

I tried serializing other types like int, string or even Array() and it works, so it's not the Saving system that causes the problem.

Are there any other methods to save this type of data? Would exporting the heightmap on the hard drive and importing it when loading the game work? If so, how can I export the heightmap from script?

For reference, this is the Save/Load code I'm using : http://www.unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML

Thanks for any answers.

Comment
Add comment · Show 1
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 qJake · Jun 19, 2010 at 05:58 PM 0
Share

That script can't handle 2D array serialization, obviously, so you'd either need to modify the script, or write your own serialization for it.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tetrad · Jun 19, 2010 at 11:15 PM

You could use .NET's built-in serialization.

http://msdn.microsoft.com/en-us/library/4abbf6k0(v=VS.71).aspx

Basically, save your data using BinaryFormatter.

Example here: http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx

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

No one has followed this question yet.

Related Questions

How to save data with the webplayer avaiable to all users? 1 Answer

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

Saving/Loading data to Windows Phone 8 3 Answers

Saving and Loading and assinging to gameobject 0 Answers

What are the basics of saving and loading game? 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