56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.SceneManagement;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class HomeCanvasController : MonoBehaviour
|
|||
|
{
|
|||
|
private Button newGameButton;
|
|||
|
private Button loadGameButton;
|
|||
|
private Button exitGameButton;
|
|||
|
|
|||
|
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>();
|
|||
|
|
|||
|
newGameButton.onClick.AddListener(() => { NewGameEvent(); });
|
|||
|
loadGameButton.onClick.AddListener(() => { LoadGameEvent(); });
|
|||
|
exitGameButton.onClick.AddListener(ExitGameEvent);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD>Ϸ
|
|||
|
/// </summary>
|
|||
|
public void NewGameEvent()
|
|||
|
{
|
|||
|
// <20><><EFBFBD>ñ<EFBFBD>ʶ<EFBFBD><CAB6>
|
|||
|
PlayerPrefs.SetInt("NewGame", 1);
|
|||
|
// <20><><EFBFBD>س<EFBFBD><D8B3><EFBFBD>
|
|||
|
SceneManager.LoadScene("Level");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|||
|
/// </summary>
|
|||
|
public void LoadGameEvent()
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>浵
|
|||
|
if (ResourceManager.Instance.GetGameArchiveStatus()) SceneManager.LoadScene("Level");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20>˳<EFBFBD><CBB3><EFBFBD>Ϸ
|
|||
|
/// </summary>
|
|||
|
public void ExitGameEvent()
|
|||
|
{
|
|||
|
#if UNITY_EDITOR
|
|||
|
UnityEditor.EditorApplication.isPlaying = false;
|
|||
|
#else
|
|||
|
Application.Quit();
|
|||
|
#endif
|
|||
|
}
|
|||
|
}
|