Spieler Tojson Einheit
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GlobalControl : MonoBehaviour
{
public GameObject Player;
public void Save()
{
var player = Player.GetComponent<PlayerScript>();
PlayerData playerdata = new PlayerData();
playerdata.pos = player.transform.position;
playerdata.curreceny = player.currency;
playerdata.playerDebug = player.IsUsingDebug;
string json = JsonUtility.ToJson(playerdata);
Debug.Log("Player data has been saved");
File.WriteAllText(Application.dataPath + "playerData.json", json);
PlayerData loadedPlayerData = JsonUtility.FromJson<PlayerData>(json);
}
public class PlayerData
{
public bool playerDebug;
public Vector3 pos;
public int curreceny;
}
}
Silly Seahorse