• 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 Creeper_Math · Jan 07, 2017 at 03:04 PM · c#savingfileswrite dataram

Saving File from "RAM" string array only saving one file

I have a custom RAM string array that only loads "files" to it when another script accesses that file. I also have a script that looks for all the files loaded on the RAM and saves it every 5 seconds. Here's the script that is on an InvokeRepeating for every 5 seconds

Format of the RAM Data: File Separator is marked by "RAMFileFormatHeader" (w$$anonymous$$ch currently is ========== ) Next is the file that the Data is followed by T$$anonymous$$rd is the time before the file is unloaded from RAM Last is all the data

 void SaveAllRam() {
         // Get all the names in ram
         string[] RAMNames = new string[0];
         int Selection = 0;
         foreach (string item in RAM) {
             if (item == RAMFileFormatHeader) {
                 RAMNames = Command.ArrayAddString(RAMNames, RAM[Selection + 1]);
                 Debug.Log("Found File on RAM '" + RAM[Selection + 1] + "'");
             }
             Selection += 1;
         }
         foreach (string item in RAMNames) {
             
             SaveRAMData(item);
             Debug.Log("Saved File From Ram '" + item + "'");
         }
     }

Here is the File Saving Script that it uses

 // THE "GetData" has been updated as I rewrote it
 static public string[] GetData(string FilePath, bool UpdateData = true, float TimeToLoadFor = 10) {
     LoadDataToRam(FilePath, UpdateData, TimeToLoadFor);
     string[] Data = new string[0];
     int RAMSelector = 0;
     foreach (string item in RAM) {
         if (item == RAMFileFormatHeader && RAM[RAMSelector + 1] == FilePath) {
             for (int WriteSelector = RAMSelector + 4; RAM[WriteSelector] != RAMFileFormatHeader; WriteSelector++) {
                 Data = Command.ArrayAddString(Data, RAM[WriteSelector]);
             }
             return (Data);
         }
     }
     return (new string[0]);
 }


 static public void SaveRAMData(string FilePath) {
     int Selection = 0;
     foreach (string item in RAM) {
         if (item == RAMFileFormatHeader && RAM[Selection + 1] == FilePath) {
             SaveFile(RAM[Selection + 1], GetData(RAM[Selection + 1]));
         }
     }
 }

What is happening is that when I go into debug and look at what files were "successfully saved"... The only file that is saved is "Settings.txt", and none of the others (like "GameData.txt, w$$anonymous$$ch is constantly updated to a string that does not match what's on the file)

Any and ALL help appreciated...

If need be, I can post my other custom voids or functions if you need, incase it is any of those

Comment
Add comment · Show 8
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 Glurth · Jan 07, 2017 at 06:30 PM 0
Share
avatar image Creeper_Math Glurth · Jan 07, 2017 at 06:50 PM 0
Share
avatar image Glurth Creeper_Math · Jan 07, 2017 at 07:07 PM 1
Share
Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

267 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 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 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 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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Problem when saving and loading 1 Answer

Don't Destroy on Load Object and GameData 1 Answer

How do you save the position of clone prefabs in a text file? 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