Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions