mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
idk
This commit is contained in:
29
Assets/Scripts/SaveData.cs
Normal file
29
Assets/Scripts/SaveData.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SaveData : MonoBehaviour
|
||||
{
|
||||
[SerializeField] PlayerData _PlayerData = new PlayerData();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(SavePlayerToJson);
|
||||
}
|
||||
|
||||
public void SavePlayerToJson()
|
||||
{
|
||||
string playerData = JsonUtility.ToJson(_PlayerData);
|
||||
|
||||
System.IO.File.WriteAllText(Application.persistentDataPath + "/PlayerData.json", playerData);
|
||||
Debug.Log(Application.persistentDataPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerData
|
||||
{
|
||||
public string username;
|
||||
}
|
||||
Reference in New Issue
Block a user