Question: unity/c# question: NullReferenceException: Object reference not set to an instance of an object Deck.AddPips (.Card card) (at Assets/__Scripts/Deck.cs:239) what is this error and how can

 unity/c# question: NullReferenceException: Object reference not set to an instance of

unity/c# question:

NullReferenceException: Object reference not set to an instance of an object

Deck.AddPips (.Card card) (at Assets/__Scripts/Deck.cs:239)

what is this error and how can I fix it?

private void AddPips (Card card) For each of the pips in the definition... foreach( Decorator pip in card.def.pips) ...Instantiate a Sprite GameObject tG0 = Instantiate ( prefabSprite ) as GameObject; /1 Set the parent to be the card GameObject tG0.transform.SetParent( card.transform) // Set the position to that specified in the XML // Flip it if necessary if (pip.flip) tGO. transform. rotation Quaternion. Euler(0,0, 180); /1 Scale it if necessary (only for the Ace) if (pip . scale != 1) { tGO.transform .loca Scale = Vector3 . one * pp. Scale; // Give this GameObject a name tG0.name"pip" // Get the SpriteRenderer Component tSR_tG0.GetComponent ); // Set the Sprite to the proper suit tSR, sprite = dictsuits [card . suit]; // Set sortingOrder so the pip is rendered above the Card_Front tSR. sort ingOrder 1; // Add this to the Card's list of pips card.pipG0s.Add (_tG0); private void AddPips (Card card) For each of the pips in the definition... foreach( Decorator pip in card.def.pips) ...Instantiate a Sprite GameObject tG0 = Instantiate ( prefabSprite ) as GameObject; /1 Set the parent to be the card GameObject tG0.transform.SetParent( card.transform) // Set the position to that specified in the XML // Flip it if necessary if (pip.flip) tGO. transform. rotation Quaternion. Euler(0,0, 180); /1 Scale it if necessary (only for the Ace) if (pip . scale != 1) { tGO.transform .loca Scale = Vector3 . one * pp. Scale; // Give this GameObject a name tG0.name"pip" // Get the SpriteRenderer Component tSR_tG0.GetComponent ); // Set the Sprite to the proper suit tSR, sprite = dictsuits [card . suit]; // Set sortingOrder so the pip is rendered above the Card_Front tSR. sort ingOrder 1; // Add this to the Card's list of pips card.pipG0s.Add (_tG0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!