fixed bug
This commit is contained in:
parent
3f65020061
commit
931da51b7f
Binary file not shown.
Binary file not shown.
@ -9,18 +9,34 @@ public class HomeCanvasController : MonoBehaviour
|
||||
private Button newGameButton;
|
||||
private Button loadGameButton;
|
||||
private Button exitGameButton;
|
||||
private Text txtSaveDate;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
newGameButton = transform.Find("Panel").Find("NewGameButton").GetComponent<Button>();
|
||||
loadGameButton = transform.Find("Panel").Find("LoadGameButton").GetComponent<Button>();
|
||||
exitGameButton = transform.Find("Panel").Find("ExitGameButton").GetComponent<Button>();
|
||||
txtSaveDate = transform.Find("Panel").Find("txtSaveDate").GetComponent<Text>();
|
||||
|
||||
newGameButton.onClick.AddListener(() => { NewGameEvent(); });
|
||||
loadGameButton.onClick.AddListener(() => { LoadGameEvent(); });
|
||||
exitGameButton.onClick.AddListener(ExitGameEvent);
|
||||
}
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// 加载游戏存档
|
||||
if (!ResourceManager.Instance.GetGameArchiveStatus())
|
||||
{
|
||||
txtSaveDate.text = "没有存档";
|
||||
}
|
||||
else
|
||||
{
|
||||
txtSaveDate.text = ResourceManager.Instance.GetSaveDateTime();
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 新游戏
|
||||
/// </summary>
|
||||
@ -41,16 +57,6 @@ public class HomeCanvasController : MonoBehaviour
|
||||
if (ResourceManager.Instance.GetGameArchiveStatus())
|
||||
{
|
||||
SceneManager.LoadScene("Level");
|
||||
// UI 提示
|
||||
GameManager.Instance.UIManager.ShowInfo("已读档!");
|
||||
// 音频播放
|
||||
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "Save");
|
||||
}
|
||||
else
|
||||
{
|
||||
// UI 提示
|
||||
GameManager.Instance.UIManager.ShowInfo("未发现存档!");
|
||||
GameManager.Instance.SoundManager.PlaySound(ESoundType.Effect, "No");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,6 +180,21 @@ public class ResourceManager : Singleton<ResourceManager>
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存档时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetSaveDateTime()
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
return $"PC:{System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
#else
|
||||
FileInfo fileinfo = new FileInfo(SaveDataFilePath);
|
||||
return $"存档时间:{fileinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载游戏存档
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user