void DecodeData() { for (int i = 0; i < data.SaveList.Count; i++) { string[] loadPath = AssetDatabase.FindAssets(data.SaveList[i].ID); string path = AssetDatabase.GUIDToAssetPath(loadPath[0]); GameObject obj = (GameObject)AssetDatabase.LoadAssetAtPath(path, typeof(GameObject)); GameObject newPrefab = (GameObject)PrefabUtility.InstantiatePrefab(obj); newPrefab.transform.localPosition = SerializedTransformExtention.DeserializePosition(data.SaveList[i].Transform); newPrefab.transform.localRotation = SerializedTransformExtention.DeserializeRotation(data.SaveList[i].Transform); newPrefab.transform.localScale = SerializedTransformExtention.DeserializeScale(data.SaveList[i].Transform); } }
public void SavePlacedAssets() { SaveData saveData = new SaveData(); SaveToFile saveFile = new SaveToFile(); for (int i = 0; i < SaveableAssets.Count; i++) { SerializedPrefab savePrefab = new SerializedPrefab(); savePrefab.Transform = SerializedTransformExtention.SerializeTransform(SaveableAssets.ElementAt(i).Key); savePrefab.ID = SaveableAssets.ElementAt(i).Value; saveData.SaveList.Add(savePrefab); } saveFile.WriteData(saveData); }