Commit de626af5 authored by Michael But's avatar Michael But
Browse files

Save und Load u. neue Scene aus der Main

parent 1c12a815
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5782222d4c9b9424ea96676650e643a8 guid: 29c3b47bb1f689d40953870d9f90e2c4
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
This diff is collapsed.
fileFormatVersion: 2
guid: ab1e512d906a26744bbbd85d3ea1d157
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -122,7 +122,7 @@ PrefabInstance: ...@@ -122,7 +122,7 @@ PrefabInstance:
- target: {fileID: 395035932932740994, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740994, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
value: SavePoint (2) value: SavePoint2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
...@@ -137,7 +137,7 @@ PrefabInstance: ...@@ -137,7 +137,7 @@ PrefabInstance:
- target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: -22.677734 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
...@@ -332,7 +332,7 @@ PrefabInstance: ...@@ -332,7 +332,7 @@ PrefabInstance:
- target: {fileID: 395035932932740994, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740994, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
value: SavePoint (1) value: SavePoint1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df, - target: {fileID: 395035932932740992, guid: 3ff4cf871f5edaa40b0530c80a9ff9df,
type: 3} type: 3}
......
...@@ -13,4 +13,11 @@ public class SavePointData ...@@ -13,4 +13,11 @@ public class SavePointData
position[0] = save.transform.position.x; position[0] = save.transform.position.x;
position[1] = save.transform.position.y; position[1] = save.transform.position.y;
} }
public SavePointData(Vector2 save)
{
position = new float[2];
position[0] = save.x;
position[1] = save.y;
}
} }
using System;
using System.IO; using System.IO;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement;
public class SaveSystem public class SaveSystem
...@@ -14,7 +16,6 @@ public class SaveSystem ...@@ -14,7 +16,6 @@ public class SaveSystem
SavePointData data = new SavePointData(save); SavePointData data = new SavePointData(save);
formatter.Serialize(stream,data); formatter.Serialize(stream,data);
stream.Close(); stream.Close();
} }
...@@ -25,6 +26,7 @@ public class SaveSystem ...@@ -25,6 +26,7 @@ public class SaveSystem
{ {
BinaryFormatter formatter = new BinaryFormatter(); BinaryFormatter formatter = new BinaryFormatter();
FileStream stream = new FileStream(path, FileMode.Open); FileStream stream = new FileStream(path, FileMode.Open);
SavePointData data = formatter.Deserialize(stream) as SavePointData; SavePointData data = formatter.Deserialize(stream) as SavePointData;
stream.Close(); stream.Close();
...@@ -38,13 +40,14 @@ public class SaveSystem ...@@ -38,13 +40,14 @@ public class SaveSystem
} }
} }
public static void LoadScene() public static void NewGame(Vector2 vec)
{
}
public static void NewGame()
{ {
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/SP.txt";
FileStream stream = new FileStream(path, FileMode.Create);
SavePointData data = new SavePointData(vec);
formatter.Serialize(stream, data);
stream.Close();
} }
} }
...@@ -4,5 +4,11 @@ ...@@ -4,5 +4,11 @@
EditorBuildSettings: EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: [] m_Scenes:
- enabled: 1
path: Assets/_Game/Scenes/DemoScenePlayerControls.unity
guid: f74dd84d63bfc43d5be164a706dd669d
- enabled: 1
path: Assets/_Game/Scenes/Michi_Test_Scene.unity
guid: c748fb3183302944b8f320153a72a1f5
m_configObjects: {} m_configObjects: {}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment