public SerializedSaveGame(SerializationInfo info, StreamingContext context) { _name = (string)info.GetValue("Name", typeof(string)); _playerData = (SerializedPlayerData)info.GetValue("PlayerData", typeof(SerializedPlayerData)); _riftLocation = (string)info.GetValue("RiftLocation", typeof(string)); _riftLevel = (int)info.GetValue("RiftLevel", typeof(int)); _playerPosition = (SerializedTransform)info.GetValue("PlayerPosition", typeof(SerializedTransform)); _mapData = (List <SerializedGenericData>)info.GetValue("MapData", typeof(List <SerializedGenericData>)); //_activePooled = (List<SerializedGameObject>)info.GetValue("ActivePooled", typeof(List<SerializedGameObject>)); //_level = (List<SerializedGameObject>) info.GetValue("Level", typeof(List<SerializedGameObject>)); }
public SerializedGameObject(SerializationInfo info, StreamingContext context) { _name = (string)info.GetValue("Name", typeof(string)); _tr = (SerializedTransform)info.GetValue("Tr", typeof(SerializedTransform)); _metadata = (SerializedMetaData)info.GetValue("Metadata", typeof(SerializedMetaData)); if (_metadata == null || !_metadata.HasValidSerializedId) { _components = (List <IUnitySerializable>)info.GetValue("Components", typeof(List <IUnitySerializable>)); } _children = (List <SerializedGameObject>)info.GetValue("Children", typeof(List <SerializedGameObject>)); }
public SerializedGameObject(GameObject root, PrefabEntity dataHolder) { _name = root.name; _components = new List <IUnitySerializable>(); if (dataHolder == null) { SetupCreated(root); } else { _metadata = dataHolder.Metadata; _metadata.SetDatabaseEntry(dataHolder); } _metadata.UpdateSerializedId(); _tr = new SerializedTransform(); _tr.Set(root.transform); _children = new List <SerializedGameObject>(); foreach (Transform child in root.transform) { if (!child.gameObject.activeSelf) { continue; } var entity = child.GetComponent <PrefabEntity>(); if (entity == null) { continue; } _children.Add(new SerializedGameObject(child.gameObject, entity)); } if (Application.isPlaying) { var savedData = root.GetComponentsInChildren <ISavedData>(); for (int i = 0; i < savedData.Length; i++) { savedData[i].SaveMetaData(_metadata); } } #if UNITY_EDITOR if (Application.isPlaying || UnityEditor.PrefabUtility.GetPrefabType(root) == PrefabType.None) { return; } var mods = UnityEditor.PrefabUtility.GetPropertyModifications(root); if (mods == null) { return; } for (int i = 0; i < mods.Length; i++) { var component = mods[i].target as Component; if (component == null || component is Transform || ReflectionHelper.HasIgnoredAttribute(component.GetType()) || Serializer.RestrictedTypes.Contains(component.GetType())) { continue; } if (mods[i].objectReference != null) { _metadata.ComponentDiff.SetDiff(component, mods[i].propertyPath, mods[i].objectReference); } else { _metadata.ComponentDiff.SetDiff(component, mods[i].propertyPath, mods[i].value); } } #endif }