- Home /
Remove content in an Array
Currently I use an Array to manage ingame chat and commands. How could I remove content from the Array without clearing the whole thing, or replace parts of the array with an alternate text? The script is written in js and in unity 4.3.2.
You should almost never use Array
s. Use List
s ins$$anonymous$$d. They are faster, typed and easier to work with.
Answer by KellyThomas · Dec 22, 2013 at 07:28 AM
var array = new Array ();
array.Push("Apple");
array.Push("Bean");
array.Push("Corn");
Debug.Log(array); // Apple, Bean, Corn
array[1] = "Dill";
Debug.Log(array); // Apple, Dill, Corn
array.RemoveAt(1);
Debug.Log(array); // Apple, Corn
Please see the documentation here.
Your answer
Follow this Question
Related Questions
SOLVED - String replace % with " in C# 1 Answer
Want replace a current object with one inside array the object being replaced with is prefab 1 Answer
Get all GameObjects by variable value 2 Answers
How to replace materials in the materials array 3 Answers
Varying number of variables depending on power type? 0 Answers