Decode() public static method

Decodes a FlowchartData object and uses it to restore the state of a Flowchart in the scene.
public static Decode ( FlowchartData flowchartData ) : void
flowchartData FlowchartData
return void
Example #1
0
        /// <summary>
        /// Decodes the loaded list of SaveDataItems to restore the saved game state.
        /// </summary>
        public virtual void Decode(List <SaveDataItem> saveDataItems)
        {
            for (int i = 0; i < saveDataItems.Count; i++)
            {
                var saveDataItem = saveDataItems[i];
                if (saveDataItem == null)
                {
                    continue;
                }

                if (saveDataItem.DataType == FlowchartDataKey)
                {
                    var flowchartData = JsonUtility.FromJson <FlowchartData>(saveDataItem.Data);
                    if (flowchartData == null)
                    {
                        Debug.LogError("Failed to decode Flowchart save data item");
                        return;
                    }

                    FlowchartData.Decode(flowchartData);
                }

                if (saveDataItem.DataType == NarrativeLogKey)
                {
                    FungusManager.Instance.NarrativeLog.LoadHistory(saveDataItem.Data);
                }
            }
        }