public static LevelClassData CreateInstance(int theNumLevel, Vector3 theShipPos, Vector3 theTargetPos, int theNbAtt, int theNbRep, List <ForceField> theFFList, List <FoeClass> theFoesList, List <BonusMalus> theBmList, List <Obstacle> theObstacleList) { LevelClassData levelData = ScriptableObject.CreateInstance <LevelClassData>(); levelData.Init(theNumLevel, theShipPos, theTargetPos, theNbAtt, theNbRep, theFFList, theFoesList, theBmList, theObstacleList); #if UNITY_EDITOR AssetDatabase.CreateAsset(levelData, string.Concat("Assets/LevelData/Level", theNumLevel, ".asset")); #endif // Debug.Log(AssetDatabase.GetAssetPath(levelData)); return(levelData); }
public static void SaveToFile(LevelClassData data, string path) { MemoryStream ms = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, data); string retValue = Convert.ToBase64String(ms.ToArray()); // A vérifier ms.Close(); ms.Dispose(); File.WriteAllText(path, retValue); }
public static LevelClassData ReadFromFile(string path) { byte[] data = Convert.FromBase64String(File.ReadAllText(path)); // A vérifier MemoryStream ms = new MemoryStream(data); BinaryFormatter bf = new BinaryFormatter(); LevelClassData result = (LevelClassData)bf.Deserialize(ms); ms.Close(); ms.Dispose(); return(result); }
public static void NewLevel() { LevelClassData data = ScriptableObject.CreateInstance <LevelClassData>(); }