Esempio n. 1
0
        private void DrawEntity(PPEntity entity)
        {
            GUILayout.BeginVertical("Box");

            if (entity.Id != PlayerPrefsMapper.SingleEntityId)
            {
                GUILayout.Label("Id: " + entity.Id);
            }

            foreach (string propertyName in entity.GetSortedKeys())
            {
                DrawRecord(propertyName, entity.PPKeys[propertyName], entity.Values[propertyName]);
            }

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Delete", GUILayout.Width(50)))
            {
                DeleteEntity(entity);
                PlayerPrefs.Save();
                Refresh();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Esempio n. 2
0
 private void DeleteEntity(PPEntity entity)
 {
     foreach (string ppKey in entity.PPKeys.Values)
     {
         PlayerPrefs.DeleteKey(ppKey);
     }
 }
Esempio n. 3
0
        private List <PPEntity> GroupByEntities(Dictionary <string, object> keyValueDic)
        {
            List <PPEntity> entities = new List <PPEntity>();

            foreach (string ppKey in keyValueDic.Keys)
            {
                if (ppKey.StartsWith(PlayerPrefsMapper.EntityKeyPrefix))
                {
                    string[] parts = ppKey.Split('.');

                    string   type   = parts[1];
                    string   id     = parts[2];
                    PPEntity entity = entities.SingleOrDefault(_ => _.Type == type && _.Id == id);

                    if (entity == null)
                    {
                        entity = new PPEntity(type, id);
                        entities.Add(entity);
                    }

                    string propertyName = parts[3];
                    object value        = keyValueDic[ppKey];
                    entity.AddValue(propertyName, value, ppKey);
                }
            }
            return(entities);
        }