示例#1
0
    void Awake()
    {
        Debug.Log("test");
        var gbxmap = new GbxMap();

        gbxmap.Load();
        foreach (var block in gbxmap.mapBlocks)
        {
            if (!stats.ContainsKey(block.BlockName))
            {
                stats.Add(block.BlockName, null);
            }
        }
        foreach (var b in stats.ToDictionary())
        {
            if (b.Value == null)
            {
                var o = ml.models.FirstOrDefault(a => a.name.ToLower().Contains(b.Key.ToLower().Substring(7)));
                if (o != null)
                {
                    var replace = o.path.Substring(0, o.path.LastIndexOf('.')).Replace('\\', '/');
                    stats[b.Key] = (GameObject)Resources.Load(replace);
                    Debug.Log("Found " + o.name);
                }
            }
        }
    }
    public static Dictionary <string, float> Load(string saved)
    {
//			Debug.Log ("we are trying to load this string as a dictionary: " + saved);
        serverDict = new Dictionary <string, float>();
        StatDictonary postLike = new StatDictonary();

        postLike = JsonUtility.FromJson <StatDictonary>(saved);
//		string data = "";
//		foreach (KeyValuePair<string,float> derp in postLike) {
//			data += "POST: " + derp.Key + " LIKE: " + derp.Value;
//		}
//		Debug.Log (data);
        serverDict = postLike.ToDictionary();

//		foreach(KeyValuePair<string,float> kvp in serverDict)
//			{
//
//				//Debug.Log ("KEy: " + kvp.Key + " VALUEL: " + kvp.Value);
//			}
//		for (int i = 0; i < serverDict.Count; i++)
//			{
//				string dlPost = postLike.post [i];
//				int dlLike = postLike.like [i];
//
//				serverDict.Add (dlPost, dlLike);
//				//Debug.Log ("POST: "+postLike.post[i] + " LIKES: " + postLike.like[i]);
//			}

        return(serverDict);
    }