【发布时间】:2014-08-24 06:41:54
【问题描述】:
我有一个 ConnectionTesterStatus 类型的变量。当我在 switch 块中比较它时,我收到一个错误:
运算符“==”不能与“UnityEngine.ConnectionTesterStatus”类型的左侧和“System.Object”类型的右侧一起使用。
private var natCapable : ConnectionTesterStatus = ConnectionTesterStatus.Undetermined;
function TestConnection()
{
// Start/Poll the connection test, report the results in a
// label and react to the results accordingly
natCapable = Network.TestConnection();
switch(natCapable) // Error
{
case ConnectionTesterStatus.Error:
//...
break;
//...
}
}
【问题讨论】:
-
我对 Unityscript 了解不多,但第一行的变量声明看起来很奇怪。尝试将其替换为 Network scripting api 参考中的声明。还要检查 TestConnection 的返回类型。
标签: networking unity3d unityscript