###前提・実現したいこと
はじめまして。
Unityにて各キャラクターのステータスデータをCSVで取り込み、dictionaryに各々格納したものをGUI表示用のクラスから呼び出そうとしましたが、KeyNotFoundExceptionが出てしまいました。ステータスデータを読み込んでるクラス内でdictionary内にある値を取り出し、表示することは出来ましたがなぜ外部のからは呼び出せないのでしょうか?自分でも調べてみましたがちょっとわからなかったためこちらで質問します。
###発生している問題・エラーメッセージ
エラーメッセージ KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.String,System.Int32].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) readCSV.ibuki_HPSet () (at Assets/Script/readCSV.cs:65) ibuki_Status.Start () (at Assets/Script/ibuki_Status.cs:17)
###該当のソースコード
C#
1 2//Read.cs 3 Dictionary<string, int> map = new Dictionary<string, int>(); 4 5//DIctionaryにCSVのデータを取り込む処理は省略。 6 7 public int HPSet() 8 { 9 return map["HP"]; 10 } 11 12----------------------------------------------------------------------------- 13 14 15
C#
1 2//Status.cs 3 4 int HP; 5 6 Read read = GetComponent<Read>(); 7 HP = read.HPSet(); 8
###試したこと
Read.cs内ではdictionaryの値を呼び出すことは出来ました。
以上、よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/06 13:20
2016/08/06 13:52