- Home /
 
 
               Question by 
               RuneSoegaard · May 18, 2018 at 10:40 AM · 
                c#serializationdictionarynested  
              
 
              Nested Dictionary data lost after playmode
Hi there! I am very new to the subject of Serialization and I would like to save data from a "nested" dictionary, after I have added them in playmode.
I am trying to use Odin Serializer to save my data from a dictionary within a dictionary, but when I add a new dictionary inside the other dictionary at play mode, it is gone when I exit play mode again. The nested dictionary data is added when I use the function while I am in playmode.
Am I approaching it the right way, or do I need something else to keep this data after I close the session and the app?
Thanks a lot for your help!
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using Sirenix.OdinInspector;
 using Sirenix.Serialization;
  
  
 public class SavedFacialExpressions : SerializedMonoBehaviour {
  
     [DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)]
     [OdinSerialize]
     public Dictionary<string, Dictionary<string, float>> FacialExpressionDictionary;
  
  
 CharacterRig characterRig;
  
     void Start()
     {
         characterRig = GetComponent<CharacterRig>();
  
     }
  
     public void SaveExpression ()
     {
         ExpressionName = FacialExpressionDictionary.Count.ToString();
  
  
  
  
         FacialExpressionDictionary.Add (ExpressionName, new Dictionary<string, float>());
  
         FacialExpressionDictionary [ExpressionName].Add ("UpperEyeLidsPos", characterRig.UpperEyeLidsPos);
         FacialExpressionDictionary [ExpressionName].Add ("LowerEyeLidsPos", characterRig.LowerEyeLidsPos);
         FacialExpressionDictionary [ExpressionName].Add ("Squinch", characterRig.Squinch);
         FacialExpressionDictionary [ExpressionName].Add ("Wrath", characterRig.Wrath);
  
  
     }
        
 }
 
              
               Comment
              
 
               
              Your answer