unity-象棋
前言
本文主要是关于自己的一个游戏项目的UI管理界面构建的总结
一、UI面板
UI面板的构造我分为:主游戏界面、单机模式界面、联网游戏界面、
二、管理者的设定
初步建立起游戏内的三个管理者:UI管理者、声音管理者、游戏主要管理者
1.UIManager
代码如下(示例):
public class UIManager : MonoBehaviour
{
public static UIManager Instance { get; private set; }
public GameObject[] panels;
//0.主菜单 1.单机 2.模式选择 3.难度选择 4.单机游戏面板 5.联网游戏面板
// Start is called before the first frame update
public Text tipUIText;// 当前需要改变具体文本的显示UI
public Text[] tipUITexts;//两个对应显示UI的引用
private GameManager gameManager;
void Start()
{
Instance = this;
gameManager = GameManager.Instance;
}
// Update is called once per frame
void Update()
{
}
/// <summary>
/// 单机模式
/// </summary>
///
public void StandaloneMode()
{
panels[0].SetActive(false);
panels[1].SetActive(true);
//单机选择面板的显示
}
/// <summary>
/// 联网模式
/// </summary>
///
public void NetWorkingMode()
{
}
/// <summary>
/// t退出游戏
/// </summary>
///
public void ExitGame()
{
Application.Quit();
}
}
2.AudioManager
代码如下(示例):
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance { get; private set; }
// Start is called before the first frame update
void Start()
{
Instance = this;
}
// Update is called once per frame
void Update()
{
}
}
3.GameManager
代码如下(示例):
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }//单例
void Awake()
{
Instance =this;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
总结
例如:以上就是今天做的内容,之后也会不定时更新关于象棋游戏这个项目的内容。有兴趣的可以给个小小的关注。你的关注就是我的动力