I took the mini-challenge and wrote my own RestoreState before Sam, and found out as the lesson went on that what I wrote was different than what the course teaches.
I’m of course rewriting to match the taught script, but for learning purposes I’d like to ask if what I came up with is total gibberish, or if it has any bug or shortcoming compared to the one in the video.
Dictionary<string, object> stateDictionary = (Dictionary<string, object>)state;
foreach (KeyValuePair<string, object> entry in stateDictionary)
{
ISavable component = (ISavable)GetComponent(entry.Key);
if (component != null)
{
component.RestoreState(entry.Value);
}
}