Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 seandolan · Feb 27, 2018 at 05:09 AM · savingdatamapstorage

Save array of GameObjects and their variables from an attached script under a parent

I have built a map editor for my game. It consists of an array of 3d blocks on a flat plane (x,0,z positions). Each of these blocks have a script attached to them that store the following values:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class BlankTile : MonoBehaviour {
 
     public int x = 0;
     public int y = 0;
     public int tileStyle = 0;
     public int walkable = 0;
     public int wall = 0;
     public int spawnCreature = 0;
     public int spawnObject = 0;
     public int spawnInteractive = 0;
     public int triggerId = 0;
 
 }
 

I have the values getting set fine, the blocks getting displayed and editable fine. But I want to save this data to a file (that isn't easy to modify) to create all my game levels. So I need to save the location (also stored in the public x and y of the script) and be able to load them whenever I need to recreate the block locations and values. I would also like to give it a file name from the text box above Load and Save buttons Any help would be really appreciated.

He

loadsave.jpg (369.2 kB)
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 seandolan · Feb 27, 2018 at 02:01 PM 0
Share

Are there any asset store items that do saving/loading of this type?

1 Reply

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

Answer by FuzzyLogic · Feb 27, 2018 at 02:48 PM

This tutorial provides a good introduction to a basic save and load mechanism.

http://catlikecoding.com/unity/tutorials/hex-map/part-12/

It is part 12 of a much larger series (which I highly recommend) so it assumes that you have already completed the previous 11 parts, though I think the information is explained well enough that one should be able to cherry-pick the information.

The method described is meant to be simple for learning purposes so is not the best way but there's nothing really wrong with it either and should be sufficient for a semi-simple game.

Comment
Add comment · Show 2 · 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
avatar image seandolan · Feb 27, 2018 at 03:27 PM 0
Share

Nice mate! This has everything I need. I will have to run through it step by step but viewing each of the steps on the fly encompasses all components of what I am trying to achieve.

avatar image FuzzyLogic seandolan · Feb 27, 2018 at 04:12 PM 1
Share

You can download the working unity project from the bottom of that page to follow along with that part of the tutorial and see how its actually implemented in code. http://catlikecoding.com/unity/tutorials/hex-map/part-12/smaller-file-size/smaller-file-size.unitypackage

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

76 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[Closed] Place to store user data 1 Answer

What is this data that keeps saving when i load my game? 0 Answers

Efficient data saving? PlayerPrefs vs. XMLSerialization 1 Answer

How would you store this data 1 Answer

Save model to a file from Unity app in Android 0 Answers


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