From the course: Unity: Working with Google Firebase
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Different write methods
From the course: Unity: Working with Google Firebase
Different write methods
When we saved our player data, we used the SetRawJsonValueAsync method, but this isn't the only way to handle saving or updating data in our database. For starters, the SetValueAsync method acts largely the same as the SetRawJson in that it takes in a value and puts it at the reference path. You can also use the push method which will generate an automatic key for the data entry, similar to what we did with storing our players under their unique IDs. With the SetValue and the SetRawJsonValueAsync methods, it's important to understand that all data at that reference path will be overwritten, so be careful when using them. Both of these are good for nonconcurrent data saving, and while you can use them to update data within nodes, it's easier and less error-prone to use the UpdateChildrenAsync or transaction methods. The UpdateChildrenAsync takes dictionaries of paths and data and only updates the given nodes without overwriting other data at that node. In our game, this would be a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.