- Home /
Question by
bob 6 · May 14, 2011 at 11:14 AM ·
javascriptarrayslicingbce0048
Javascript remove object from array.
I played with the code and have now solved it. *var list = new Array ();
function OnGUI() {
if(GUI.Button(Rect(100,100,100,100), remove) {
list.Remove[i];
}
}
I have an array of an object that contains variables with string (Javascript), int and gui styles. When I put a button to "remove" one of the elements of the arraylist it gives the error (i is used from looping in an arraylist, imagine it is a 0):
Type 'callable(Object) as void' does not support slicing.not support slicing. I tried to change it into an arraylist and tried using RemoveAt[i] but still get the same error about slicing. What am I doing wrong?*
I played with the code and have now solved it.
Comment
When you solve the problem, post it as an answer. Also, don't use Array anymore; use List (there are several posts here about that).
Your answer
![](https://koobas.hobune.stream/wayback/20220613134142im_/https://answers.unity.com/themes/thub/images/avi.jpg)