セーブのC#をつくたんですが、どこにいれればいいかわかりません。教えてください。ちなみにこれがスクリプトです
Save Manager.cs
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
[DefaultExecutionOrder(-10)]
public class SaveManager : SingletonMonoBehaviour<SaveManager>
{
string filePath;
SaveData save;
MoveSceneManager moveSceneManager;
public float Volume
{
set
{
save.volume = value;
}
get
{
return save.volume;
}
}
public float BgmVolume
{
set
{
save.bgmVolume = value;
}
get
{
return save.bgmVolume;
}
}
public float SeVolume
{
set
{
save.seVolume = value;
}
get
{
return save.seVolume;
}
}
protected override void Awake()
{
base.Awake();
string saveFileName = "saveData";
if (Debug.isDebugBuild)
{
saveFileName += "_test";
}
filePath = Application.persistentDataPath + "/" + saveFileName + ".json";
save = new SaveData();
moveSceneManager = GetComponent<MoveSceneManager>();
if (Debug.isDebugBuild)
{
CreateDebugData();
}
else
{
if (File.Exists(filePath))
{
Load();
}
else
{
Save();
}
}
}
public void Save()
{
string json = JsonUtility.ToJson(save);
using (StreamWriter streamWriter = new StreamWriter(filePath))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
}
public void Load()
{
if (File.Exists(filePath))
{
using (StreamReader streamReader = new StreamReader(filePath))
{
string data = streamReader.ReadToEnd();
streamReader.Close();
save = JsonUtility.FromJson<SaveData>(data);
}
}
}
public void InitSaveData()
{
save = new SaveData();
}
void CreateDebugData()
{
}
}
Result.cs(こちらにさっきのスクリプトをいれたいんですけどどうすればよいのでしょうか?)
vusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Result : MonoBehaviour
{
private int highScore;
public Text resultTime;
public Text bestTime;
public GameObject resultUI;
void Start()
{
if (PlayerPrefs.HasKey("HighScore"))
{
highScore = PlayerPrefs.GetInt("HighScore");
}
else
{
highScore = 999;
}
}
void Update()
{
if (Goal.goal)
{
resultUI.SetActive(true);
int result = Mathf.FloorToInt(Timer.time);
resultTime.text = "ResultTime:" + result;
bestTime.text = "BestTime:" + highScore;
if (highScore > result)
{
PlayerPrefs.SetInt("HighScore", result);
}
}
}
public void OnRetry()
{
SceneManager.LoadScene(
SceneManager.GetActiveScene().name);
}
public void LoadingNewScene()
{
SceneManager.LoadScene("Title");
}
}
回答待っています