# Is it possible to remove elements from a Texture2D array?

**URL:** https://discussions.unity.com/t/is-it-possible-to-remove-elements-from-a-texture2d-array/66931
**Category:** Questions & Answers
**Created:** [March 26, 2013, 4:41am UTC](https://discussions.unity.com/t/is-it-possible-to-remove-elements-from-a-texture2d-array/66931 "2013-03-26T04:41:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Kynge](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@Kynge](https://discussions.unity.com/u/Kynge)
#### Post date: [March 26, 2013, 4:41am UTC](https://discussions.unity.com/t/is-it-possible-to-remove-elements-from-a-texture2d-array/66931/1 "2013-03-26T04:41:44Z")

</div>

Hello! I am working on a simple card game to practice my unity skills. I have an array that holds 52 images, representing the deck.

Upon the start of the game, I pull four random cards and attach them to a GUITexture on my game screen. No problems there.

However, I would like to remove these ‘used’ cards from my array but after much googling, I cannot find a good answer. Any opinions or ideas?

Here is the applicable code:

```
#pragma strict

//Card Array

var cards : Texture2D[];

var PlayerCards : Texture2D[];

var targetGUI1 : GUITexture;
var targetGUI2 : GUITexture;
var targetGUI3 : GUITexture;
var targetGUI4 : GUITexture;

function Start () 
{	
	for(var i = 0; i < 4; i++)
	{
		var myElement = cards[Random.Range(0, cards.Length)];
		
		PlayerCards *= myElement;*

```

- }\*

- targetGUI1.texture = PlayerCards[0];\*

- targetGUI2.texture = PlayerCards[1];\*

- targetGUI3.texture = PlayerCards[2];\*

- targetGUI4.texture = PlayerCards[3];\*  
_}_  
_Again, no problems filling each texture with a random card. I would like to know if it’s possible to remove the chosen cards from this Texture2D array._

---

<div class="post-metadata">

### Author: ![Eric5h5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/eric5h5/32/44225_2.png) [@Eric5h5](https://discussions.unity.com/u/Eric5h5)
#### Post date: [March 26, 2013, 4:49am UTC](https://discussions.unity.com/t/is-it-possible-to-remove-elements-from-a-texture2d-array/66931/2 "2013-03-26T04:49:37Z")

</div>

Built-in arrays are a fixed size and have no facility for removing elements. Use a generic List instead. (Do not use the Array class, or ArrayList.) [http://wiki.unity3d.com/index.php?title=Which\_Kind\_Of\_Array\_Or\_Collection\_Should\_I\_Use?#Generic\_List](http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use?#Generic_List)
