Can't add component GUITexture


I'm trying to create GUITextures on the fly but I keep on getting this error ->

"Can't add component 'GUITexture' to something different because such a component is already added to the game obejct!"

Here is an example of test code what I'm trying to accomplish

GUITexture textureTest1 = gameObject.AddComponent<GUITexture>() as GUITexture;

GUITexture textureTest2 = gameObject.AddComponent<GUITexture>() as GUITexture;

the error appears when gameObject adds a component the second time.

I don't really understand because you can attach many GUITextures components through the editor?

I would really appreciate if some one could possibly explain to me why this does not work.

Kind Regards

You can't add multiple GUITextures to a single GameObject in the editor either

If you're doing GameObject > Create Other > GUI Text, it's creating a new GameObject each time

What you could do is something like this:

GameObject go1 = new GameObject("1"); 
GUITexture textureTest1 = go1.AddComponent<GUITexture>();

GameObject go2 = new GameObject("2");
GUITexture textureTest2 = go2.AddComponent<GUITexture>();