下面的腳本是我開始研究的,它需要一個TextAsset並分割線條並將其與各種字符串進行比較。但是我的檢查函數只返回false。有什麼重大的我想念,統一不會拋出任何錯誤,所以我不知道該怎麼做來解決這個問題。bool isItem(TextAsset f)總是返回false
internal sealed class Checker {
private string AssetType(TextAsset fileToBeChecked) {
string[] line = fileToBeChecked.text.Split (new char[] { '\n' });
return line [0];
}
public bool isItem(TextAsset file) {
string type = AssetType (file).ToLower();
if (type == "helmet" || type == "cuirass" || type == "gauntlets" || type == "gloves" || type == "boots" || type == "leggings" || type == "shield" || type == "robes" || type == "shirt" || type == "pants" || type == "shoes" || type == "hood" || type == "staff" || type == "stave" || type == "sword" || type == "greatsword" || type == "dagger" || type == "mace" || type == "warhammer" || type == "axe" || type == "waraxe" || type == "bow" || type == "misc") {
return true;
} else {
return false;
}
}
}
}
我的測試文件如下:
Helmet
1
Dragon's Vale
0
10
0
14
1280
調試
那麼,什麼是'type'當您調試呢? –
這應該很容易使用調試器解決。我們不知道'AssetType(file).ToLower()'返回的是什麼,因爲我們不知道你的上下文。那麼我們應該怎麼知道爲什麼這些條件永遠不會通過? – HimBromBeere
@EvanTrimboli包含信息狀態頭盔的文件,當我有功能給我的價值後拉它說頭盔。但是當它與「頭盔」相比時,它返回了錯誤。 –