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 AntGoober · Sep 19, 2016 at 06:19 PM · listserializationloadingsaving

Serializing / deserializing large lists

I'm having trouble serializing / deserializing a large list I've created, and then saving / loading it when called for.

The list is for 50 characters, with over 15 individual values for each. The individual values can change (so sailor 36's wage could increase etc.) Rather than creating a thousand public variables and using a convoluted method of throwing the data about, I've tried to serialize the list and then save/load, but for the life of me, I can't figure it out.

I've been banging my head against a wall with this for days now, any help would be greatly appreciated.

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using System;
 using System.Collections.Generic;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.IO;
 using System.Linq;
 
 public class Stats : MonoBehaviour
 {
 
     public List<Sailor> sailors = new List<Sailor>();
     
     public int selectedSailorIndex = 1;
 
     public Text selectedSailorsTstat1;
 
     
     void Start()
     {
         MakeSailorList();
     }
 
     
 
     public void MakeSailorList()
     {
 
         sailors.Add(new Sailor("ABRAHAM", "DIFFORD", 5, 20, 11, 15, 7, 9, 22, 30, 12, 6, 44, 12, 120, "IDLE", true));
         sailors.Add(new Sailor("ABNER", "GOODING", 6, 14, 16, 20, 10, 10, 29, 13, 7, 51, 10, 9, 150, "IDLE", true));
 
         // 50 sailors in total - etc...
 
 
     }
 
     public void Add_sTstat1()
     {
         sailors[selectedSailorIndex].sTstat1 += 1;
 
     }
 
     //more functions similair to this for rest of stats...
 
     public void UpdateTextFields() {
         selectedSailorsTstat1.text = sailors[selectedSailorIndex].sTstat1.ToString();
     }
 
  
 
 
 }
 
 [Serializable()]
 public class Sailor
 {
 
     public string sName1, sName2, sTask;
     public int sTstat1, sFstat1, sHstat1, sSstat1, sTstat2, sFstat2, sHstat2, sSstat2, sTstat3, sFstat3, sHstat3, sSstat3, sWage;
     public bool sAlive;
 
     public Sailor(string newName1, string newName2, int newTstat1, int newFstat1, int newHstat1, int newSstat1, int newTstat2, int newFstat2, int newHstat2, int newSstat2, int newTstat3, int newFstat3, int newHstat3, int newSstat3, int newWage, string newTask, bool newAlive)
     {
         sName1 = newName1; sName2 = newName2; sTask = newTask; sWage = newWage; sAlive = newAlive;
         sTstat1 = newTstat1; sFstat1 = newFstat1; sHstat1 = newHstat1; sSstat1 = newSstat1;
         sTstat2 = newTstat2; sFstat2 = newFstat2; sHstat2 = newHstat2; sSstat2 = newSstat2;
         sTstat3 = newTstat3; sFstat3 = newFstat3; sHstat3 = newHstat3; sSstat3 = newSstat3;
 
     }
 
 
 }



Comment
Add comment
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Save/Load Animation State of Instantiated Prefabs 0 Answers

Serialization Location 1 Answer

Serializing a graph 2 Answers

Importing and exporting save files. 0 Answers

how to properly save an int value ? 2 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