字典和项目保护 Unity3d 5.3.1 中 KeyedCollection 的成员?
Dictionary and Items protected members of a KeyedCollection in Unity3d 5.3.1?
我已经使用 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 台安装了 5.3.1 的不同机器上编译了完全相同的代码。
好吧,5 个中有 2 个被证明可以编译 没有任何错误。
此外,msbuild 似乎也可以毫无错误地编译代码。
可能是机器之间存在差异,Mono编译时使用的.NetFramework。
你知道这个奇怪的问题吗?
PS:我正在添加 using System.Collections.ObjectModel
并且我当前在 Unity 编辑器中的 API 兼容性选项设置为 .NET 2.0。
好的,我的团队解决了。
在那些机器上 Windows 没有安装对 Editor 5.3.1f1 的支持,因此 webplayer 的标准模块是 运行 并且很少 API 的 .NET 不可用。
我已经使用 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 台安装了 5.3.1 的不同机器上编译了完全相同的代码。
好吧,5 个中有 2 个被证明可以编译 没有任何错误。
此外,msbuild 似乎也可以毫无错误地编译代码。
可能是机器之间存在差异,Mono编译时使用的.NetFramework。
你知道这个奇怪的问题吗?
PS:我正在添加 using System.Collections.ObjectModel
并且我当前在 Unity 编辑器中的 API 兼容性选项设置为 .NET 2.0。
好的,我的团队解决了。
在那些机器上 Windows 没有安装对 Editor 5.3.1f1 的支持,因此 webplayer 的标准模块是 运行 并且很少 API 的 .NET 不可用。