public void loadFromTextFile(string filename) { if (!prepareLoading()) { return; } StreamReader reader = new StreamReader(filename); string data = reader.ReadToEnd(); reader.Close(); finishLoading(Object2PropertiesMappingWrapper.DeSerializeObject(data)); }
public string saveToTextStream() { if (!precacheGameobjects) { StartCoroutine(startShowPrecachingMandatoryMessage(8.5f)); return(null); } stop(); Object2PropertiesMappingWrapper o2pMappingListW = new Object2PropertiesMappingWrapper(); foreach (var entry in gOs2propMappings) { o2pMappingListW.addMapping(entry.Value); } o2pMappingListW.recordingInterval = recordingInterval; return(o2pMappingListW.SerializeObject()); }
void finishLoading(Object2PropertiesMappingWrapper deserialized) { gOs2propMappings.Clear(); maxPositions = 0; recordingInterval = deserialized.recordingInterval; //if you load a replay with a different recording interval, //you have to reset it to the earlier value afterwards YOURSELF! if (deserialized.EZR_VERSION != EZR_VERSION) { if (showWarnings) { Debug.LogWarning("EZReplayManager WARNING: The EZReplayManager version with which the file has been created differs from your version of the EZReplayManager. This can cause unintended behaviour."); } } //TODO: combine with switchModeTo() sendCallback2All("__EZR_replay_prepare", null); foreach (var entry in deserialized.object2PropertiesMappings) { if (entry.isParent()) { entry.prepareObjectForReplay(); GameObject goClone = entry.getGameObjectClone(); gOs2propMappings.Add(goClone, entry); foreach (KeyValuePair <int, SavedState> stateEntry in entry.savedStates) { if (stateEntry.Key > maxPositions) { maxPositions = stateEntry.Key; } } } } foreach (var entry in deserialized.object2PropertiesMappings) { if (!entry.isParent()) { entry.prepareObjectForReplay(); GameObject goClone = entry.getGameObjectClone(); gOs2propMappings.Add(goClone, entry); } foreach (KeyValuePair <int, SavedState> stateEntry in entry.savedStates) { if (stateEntry.Key > maxPositions) { maxPositions = stateEntry.Key; } } } currentMode = ViewMode.REPLAY; //because of this switchModeTo is avoided in play(); recorderPosition = getLowestFrame(); sendCallback2All("__EZR_replay_ready", null); play(0); }