Setting Textures causes GameObject Material to turn black?

I have no idea why setting materials causes my GameObjects to show up as black (does that mean it is null? But the inspector says otherwise). Could this be a bug in Unity or is there a problem with my logic? What I am trying to do is to set a texture on a created GameObject plane through scripting (and depending on what inputs I put in will show a different texture (example: a playing card face texture)). I also want to avoid using Instanciate (unless it can’t be avoided…) because the “sharedMaterial” variable has caused me problems on making duplicate textures on cards that have different variable information. Here is what I have:

for(int i = currentDeck.deck.Length - 1; i > 0; i--)
		{
			//Create the card holder (holds the front and back of the card)
			GameObject cardClone = new GameObject(i + ": " + currentDeck.deck*.cardName);*
  •  	//Create the card front as well as transform, rotation, scale, and parenting it*
    
  •  	GameObject cardCloneFront = GameObject.CreatePrimitive(PrimitiveType.Plane);*
    
  •  	cardCloneFront.transform.parent = cardClone.transform;*
    
  •  	cardCloneFront.transform.rotation = Quaternion.Euler(90f, 0f, 0f);*
    
  •  	cardCloneFront.transform.localScale = new Vector3(0.225f, 0f, 0.325f);*
    
  •  	//Create the card back as well as transform, rotation, scale, and parenting it*
    
  •  	GameObject cardCloneBack = GameObject.CreatePrimitive(PrimitiveType.Plane);*
    
  •  	cardCloneBack.transform.parent = cardClone.transform;*
    
  •  	cardCloneBack.transform.rotation = Quaternion.Euler(270f, 0f, 0f);*
    
  •  	cardCloneBack.transform.localScale = new Vector3(0.225f, 0f, 0.325f);*
    
  •  	//Place the card holder where it needs to be located (with rotation)*
    

_ cardClone.transform.position = new Vector3(currentDeck.transform.position.x, currentDeck.transform.position.y + (i * 0.02f), currentDeck.transform.position.z);_

  •  	cardClone.transform.rotation = Quaternion.Euler(90f, 0f, 0f);*
    
  •  	//Add components and set card properties*
    
  •  	cardClone.AddComponent<Card>();*
    

_ cardClone.GetComponent().SetCard(currentDeck.deck*);*_

* cardClone.GetComponent().front = cardCloneFront;*

* Material myNewMaterial = new Material(Shader.Find(“Diffuse”));*
* cardCloneFront.GetComponent().material = myNewMaterial;*
_ //cardClone.GetComponent().SetCardFront(currentDeck.deck*.frontTexture);_
cardCloneFront.GetComponent().material.SetTexture(“_MainTex”, currentDeck.deck.frontTexture);*

* cardClone.GetComponent().back = cardCloneBack;*
_ cardClone.GetComponent().SetCardBack(currentDeck.deck*.backTexture);*_

_ //card.GetComponent().SetCard(currentDeck.deck*);
//GameObject cardClone = (GameObject)Instantiate(card, new Vector3(currentDeck.transform.position.x, currentDeck.transform.position.y + (i * 0.02f), currentDeck.transform.position.z), Quaternion.Euler(90, 0, 0));
//GameObject test = (GameObject)Instantiate(cardClone, new Vector3(currentDeck.transform.position.x, currentDeck.transform.position.y + (i * 0.02f), currentDeck.transform.position.z), Quaternion.Euler(90, 0, 0));
}
If my code looks like that it is all over the place, it is because I was trying 3 different attempts at trying to get this to work. Here is what it looks like currently:
[49179-deckofcards.jpg*
|49179]*

The above picture is the deck of cards separated by some space. The below picture is a separate card.
[49180-card.jpg|49180]
This has effected both sides of the cards as seen above. Those are the cards with (what looks like) missing textures, but the inspector says that these textures exist. So what is causing this?

_*

Ok, after tinkering with the code a little bit, I found out that I can just have a clone with Instantiating it AND making a separate material for it (thus stopping the duplicated materials on all the cards).

            Material myNewMaterialFront = new Material(Shader.Find("Diffuse"));
			Material myNewMaterialBack = new Material(Shader.Find("Diffuse"));
			
			GameObject cardClone = (GameObject)Instantiate(card, new Vector3(currentDeck.transform.position.x, currentDeck.transform.position.y + (i * 0.02f), currentDeck.transform.position.z), Quaternion.Euler(90, 0, 0));
			cardClone.GetComponent<Card>().SetCard(currentDeck.deck*);*
  •  	GameObject cardCloneFront = cardClone.transform.GetChild(0).gameObject;*
    
  •  	cardCloneFront.GetComponent<Renderer>().material = myNewMaterialFront;*
    

cardCloneFront.GetComponent().material.SetTexture(“MainTex", currentDeck.deck*.frontTexture);
_
GameObject cardCloneBack = cardClone.transform.GetChild(1).gameObject;*

* cardCloneBack.GetComponent().material = myNewMaterialBack;*
cardCloneBack.GetComponent().material.SetTexture(”_MainTex", currentDeck.deck*.backTexture);*