589425 (1) [Avatar] Offline
#1
Hello!
At first thank you for the wonderfull book! I can't stop me to read it more and more.

There is a little problem with a SceneController.
Cards replace themselves but not by the code of their positions:
float posX = (offsetX * i) + startPos.x;
float posY = -(offsetY * j) + startPos.y;
card.transform.position = new Vector3(posX, posY, startPos.z);


they replace themselves like startPos is allways null:
image
image

There is no errors in code, but only two green underlines , with messages that originalCard and images Array have no value and therefore they have null.
I made all by the book's instruction... Do you have any ideas, what can it be, please?
jhocking (200) [Avatar] Offline
#2
From the screenshot it does appear that the cards are positioned in two rows of 4 (as opposed to all stacked in one spot) but they are too close together and thus overlapping. Either the cards are too big (perhaps the import settings for the sprites got screwed up) or the offset values used to space them apart needs to be bigger.


by the way, as for this part:
589425 wrote:
There is no errors in code, but only two green underlines , with messages that originalCard and images Array have no value and therefore they have null.


This green underline warning is because the values of originalCard and the Images array are set in Unity's Inspector, and Visual Studio knows nothing about the Inspector. Since Visual Studio doesn't see any place where those values are set, it warns you that those values aren't set.