After making changes to a Prefab i get this strange error

NullReferenceException
UnityEngine.Transform.FindChild (System.String name) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/UnityEngineTransform.cs:366)
Card.SetImage (UnityEngine.Texture texture)
CardManager.Start ()

Strangest thing is that the the debug breakpoint doesnt work anymore. I cant get it to break to debug.

This is in a prefab called Card. It looks like this.

  • Card
    • CardSides
      • Front
      • Back

All the code happens in Card. So i have a reference to CardSides which rotation.Y i am trying to SLERP. But the effect is very weird. Kind of the opposite to if i SLERP the rotation of Card. CardSides is just a container and everything is set to 0 so i dont understand why.

Here is the method where the problem occurs.
void Start ()
{

				canCardBeFlipped = true;

				/* LOAD TEXTURES */
				var objects = Resources.LoadAll ("Cards/");
				foreach (var o in objects) {
						textures.Add (o as Texture);
				}
				//Debug.Log ("I have loaded this many images: " + textures.Count);

				
				/* INSTANTIATE CARDS */
				for (int i = 0; i < startingCards; i++) {
						var prefab = Instantiate (Resources.Load ("Prefabs/Card")) as GameObject;
						var card = prefab.GetComponent<Card> ();
						var texture = (textures [Random.Range (0, textures.Count)]);//randomly set cards image
						var width = texture.width / pixelsPerMeter;
						var height = texture.height / pixelsPerMeter;
						card.SetImage (texture);//HERE IS THE PROBLEM
						var cardX = cardStartingX + (width * i) + (cardMargin * i); 
						var cardY = 20;
						card.transform.Translate (cardX, cardY, 0);			

				}	
		}

Card.SetTexture

	public void SetImage (Texture texture)
		{				
				var front = cardSides.FindChild ("Front");
				
				front.renderer.material.mainTexture = texture;

				cardName = texture.name;
		}

Please try replacing Card.SetImage() with this test version.

I think we will confirm cardSides is the culprit. Just check the console for messages while the game runs.

public void SetImage (Texture texture){
      if (!cardSides) Debug.Log("cardSides is null");
      var front = cardSides.FindChild ("Front");

      if (!front) Debug.Log("front is null");
      front.renderer.material.mainTexture = texture;

      cardName = texture.name;
}

If cardSides is null you will have to look are where it should be initialized.

Ive solved this. It had to do with several things with the setup of the Gamoe Object hierarchy. Sorry for troubling you.