字典和项目在 Unity3d 5.3.1 中受保护的键控集合的成员
本文关键字:受保护 成员 集合 项目 Unity3d 字典 | 更新日期: 2023-09-27 18:32:10
我已经使用Unity 5一年了,一切都很好,直到上周我们想到了将IDE更新到5.3.1版本的想法。
现在编译器显示两个错误:
The name `Dictionary' does not exist in the current context.
The name `Items' does not exist in the current context.
两者都本地化在一个简单的KeyedCollection中
public class CommandProcessQueueCollection : KeyedCollection<int, CommandProcessQueue>
{
public bool TryGetQueue(int id, out CommandProcessQueue queue)
{
if (Dictionary != null)
{
return Dictionary.TryGetValue(id, out queue);
}
foreach (var i in Items)
{
var k = GetKeyForItem(i);
if (Comparer.Equals(id, k))
{
queue = i;
return true;
}
}
queue = default(CommandProcessQueue);
return false;
}
protected override int GetKeyForItem(CommandProcessQueue queue)
{
return queue.Id;
}
}
经过几次尝试,事情变得更加棘手,因为完全相同的代码已经在安装了 5.3.1 的 5 台不同的机器上编译。
好吧,事实证明,2 个中有 5 个可以编译而没有任何错误。
此外,msbuild似乎也没有任何错误地编译代码。
机器之间可能存在差异。Mono 用于编译的 NetFramework。
你对这个奇怪的问题有任何想法吗?
PS:我正在添加using System.Collections.ObjectModel
,并且我当前在Unity编辑器中的API兼容性选项设置为.NET 2.0。
好的,我的团队解决了。
在这些机器中,Windows对编辑器5.3.1f1的支持没有安装,因此Webplayer的标准模块正在运行,并且很少有.NET的API不可用。