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 /
This question was closed Feb 15, 2018 at 01:36 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by plumel · Mar 18, 2016 at 12:25 PM · arraypluginsavefiledictionary

Can Vexe.FastSave save dictionaries to files?

I'm trying to get two variables in the dictionary, PlayerName and count to be saved in an array in the file so that I can sort the file and have it in score order and have the names relevant to the score.

I've just come across the Vexe plugin and have only seen examples of it saving gameobjects.

Anyone know?

@vexe pls :)

using UnityEngine; using System.Collections; using System.Collections.Generic; using System.IO; using Vexe.FastSave; using Vexe.Runtime.Types;

public class GUI_Button : MonoBehaviour {

 public PlayerMovement GUIScript;
 public RandomSpawn GUIScript1;
 private int count = RandomSpawn.count;
 public string PlayerName = "Enter name";
 public string fileName = "leaderboard.txt";

 [show] void OnGUI ()
 {
     if (PlayerMovement.livess <= 0) 
     {
         GUI.Button (new Rect (400, 200, 300, 200), "Score:" + (count+10));
         PlayerName = GUI.TextField (new Rect (400, 400, 300, 100), PlayerName);
         Dictionary<string, int> dictionary = new Dictionary<string, int> ();
         string dictPath { Get { return Application.dataPath + "/" + fileName; } };
         dictionary.Add (PlayerName, count);
     }
 }
 [show] void Save()
 {
     Save.DictionaryToFile(
         Application.dataPath + "Plum/Desktop/Pixel Ninjav3.3/Assets/leaderboard", target);
 }

}

Thanks in advance

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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by vexe · Mar 18, 2016 at 01:41 PM

It's been a while, but IIRC you need to add a strongly-typed dictionary serializer, so you say FSCommon.Serializer.AddStrongDictionary(...) and then you could say Save.ObjectToFile(..) and it should pick up that dictionary serializer you specified if you pass it the same dictionary type with the generic parameters you specified in that AddStringDictionary function. I can't remember exactly how you do it but I think you just say

 var dictSer = new DictionarySerializer<string, int>();
 FSCommon.Serializer.AddStrongDictionary(dictSer.StrongSerialize, dictSer.StrongDeserialize);
 Save.ObjectToFile(...);

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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Can I save a whole Dictionary? 4 Answers

Saving Array Objects in Android. 0 Answers

Sharing Violation On Path 1 Answer

Save GUI List to my Text File 0 Answers

What is the c# equivelant of 'map' in Javascript? 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