簡體   English   中英

存在的方法沒有方法異常

[英]No Method Exception on a method that exists

我試圖在數組中定位一個變量,因為它最初是從數組中獲取的,但是在UnityScript中,這並不像我希望的那樣直觀。

這是我找到索引的代碼:

function nextArea() {
    var tmp = Array.IndexOf(areas, currentArea);
    tmp++;
    currentArea = areas[tmp];
    initNewArea();
}

但是,每當我在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) 

如果您可以修復它並擁有github帳戶,則在這里打開了一個問題: GitHub

可能您想要這樣:

var arr = new System.Collections.ArrayList ();

// Add elements
arr.Add ("Hello");
arr.Add("World");

Debug.Log(arr.IndexOf("World"));

您也可以嘗試System.Collections.Generic.List<T> ,它還包含IndexOf函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM