Closed legend1923 closed 4 years ago
Hi,
Edited your message for better readability.
Could you please say, in what situation you encountered the error? A list of steps to reproduce it would be great.
I have to say, I will probably not have much free time at the moment to debug this project, but I'll try to help. If you happen to find a fix yourself, PRs are welcome!
Thanks!
Hi , Thank you . First I downloaded from Github I tried to open it with Unity 2019.2.12 I fixed GoogleSheet api and i try only run this codes. GoogleSheet and Card model okey because its says 200. But then i see
NullReferenceException: Object reference not set to an instance of an object
DeckSwipe.Gamestate.GameProgress.AttachReferences (DeckSwipe.Gamestate.CardStorage cardStorage) (at Assets/DeckSwipe/Gamestate/GameProgress.cs:24)
Thanks
I think I have identified the problem.
You've only just started working with the project, so, most likely, you don't have the progress persistence file yet. The game attempts to locate the file at Application.persistentDataPath + "/progress.json"
. On Linux, that's ~/.config/unity3d/GruzWorks/DeckSwipe/progress.json
. On Windows, it's going to be somewhere under AppData
in your user directory.
That is perfectly normal, and the expected behaviour is that the game would just create a new, fresh GameProgress
structure for you, and then save it whenever it would usually save your progress.
However, I missed a detail in the implementation. When the file doesn't exist, ProgressStorage
gets a null
from await LoadLocally();
on this line. It then notices that, and creates a new GameProgress
. The next step is to call AttachReferences()
on it. At the very beginning of that method, we try iterating over a list:
public void AttachReferences(CardStorage cardStorage) {
foreach (CardProgress entry in cardProgress) {
But we haven't initialised that list! So foreach
wants to get an iterator from a list object that doesn't exist.
What's missing is a default constructor for GameProgress
that would initialise the lists, or a = new List<...>()
in the declaration of each. This is a very simple fix, so if you want to, you're more than welcome to fork the repository, implement the fix, and submit a pull request. If not, I'll probably provide the fix myself, but it might take longer until it's available, because I'm a bit busy.
Thank you for the report!
Hi, Was there a fix provided for this by chance? I'm a novice here; managed to get through the Google API items, but stuck at this step without technical acumen to implement solution from scratch. Any more pointers? Thank you.
I have just pushed the fix, in commit f2c0388. The project should run out of the box now.
Hi , I have a error This Line ->
Card card = cardStorage.ForId(entry.id);