2014-03-31 42 views
0

我從Parse.com導入圖像輪廓到我的團結項目,將它們插入到與特定的用戶id作爲關鍵和圖像(的Texture2D)作爲這樣的價值詞典列表:保存的Texture2D在字典和檢索它之後

public Dictionary<string, string> oppimageslinks = new Dictionary<string, string>(); 
public Dictionary<string, Texture2D> oppimages = new Dictionary<string, Texture2D>(); 

foreach(KeyValuePair<string, string> image in oppimageslinks){ 

    var oppImageRequest = new WWW(image.Value); 
    yield return oppImageRequest; 
    oppimages.Add(image.Key,oppImageRequest.texture); 

} 

這部分工作得很好。現在,我的問題是如何將Texture2D放入我的gameObject中?這裏是我如何去做:

if(oppimages.ContainsKey(game.Value[2])){ 
    UITexture picture = GameObject.Find("Game"+mc+"/Background/ProfileImg").GetComponent<UITexture>(); 
    picture.mainTexture = oppimages.Value; 
} 

game.Value [2]是當前的對手userid。

我當試圖做到這一點得到這個錯誤:

類型System.Collections.Generic.Dictionary<string,UnityEngine.Texture2D>' does not contain a definition for價值「沒有擴展方法Value' of type System.Collections.Generic.Dictionary」可以找到(是否缺少using指令或程序集引用?)

我不知道如何解決這個問題,並希望在這件事上一定的幫助。

回答

2

我不知道發生了什麼事。也許你可以試試這個?

if(oppimages.ContainsKey(game.Value[2])){ 
UITexture picture = GameObject.Find("Game"+mc+"/Background/ProfileImg").GetComponent<UITexture>(); 
picture.mainTexture = oppimages[game.Value[2]]; 
}