您好,我正在尝试找出在 unityscript 中使用 LINQ 从类列表中获取总和的正确语法
var totalCount: int;
class munsters {
var beast: String;
var min: int = 1;
var max: int =1;
}
var wilds: List.<munsters>;
//this gives me the error --
//InvalidProgramException: Invalid IL code in OppSpawnTester:OnDrawGizmos (): IL_0007: ldarg.1
totalCount = wilds.Sum(function(a) a.max);
totalCount = wilds.Select(function(a : munsters) a.max).ToList().Sum();
对于仍然持有 unityscript 的其他人:)