[英]No Method Exception on a method that exists
I am attempting to locate a varible in an array, as it was taken originally from the array, but in UnityScript this is not as straighforward as I hoped. 我试图在数组中定位一个变量,因为它最初是从数组中获取的,但是在UnityScript中,这并不像我希望的那样直观。
Here is my code for finding the index: 这是我找到索引的代码:
function nextArea() {
var tmp = Array.IndexOf(areas, currentArea);
tmp++;
currentArea = areas[tmp];
initNewArea();
}
Yet whenever I run it in Unity I get this error: 但是,每当我在Unity中运行它时,都会出现此错误:
MissingMethodException: UnityScript.Lang.Array.IndexOf
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher(System.Object target, System.Type targetType, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args)
If you can fix it and have a github account I've opened an issue here: GitHub 如果您可以修复它并拥有github帐户,则在这里打开了一个问题: GitHub
Probably you want like this: 可能您想要这样:
var arr = new System.Collections.ArrayList ();
// Add elements
arr.Add ("Hello");
arr.Add("World");
Debug.Log(arr.IndexOf("World"));
You can also try System.Collections.Generic.List<T>
, it also contains IndexOf function. 您也可以尝试System.Collections.Generic.List<T>
,它还包含IndexOf函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.