代码示例:
设置界面
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SettingPanel : BasePanel<SettingPanel>
{
public UIButton btnClose;
public UISlider sliderMusic;
public UISlider sliderSound;
public UIToggle togMusic;
public UIToggle togSound;
protected override void Init()
{
btnClose.onClick.Add(new EventDelegate(() =>
{
//隐藏自己
HideMe();
}));
sliderMusic.onChange.Add(new EventDelegate(() =>
{
//改变音量大小,并且改变数据
}));
sliderSound.onChange.Add(new EventDelegate(() =>
{
//改变音效大小,并且改变数据
}));
togMusic.onChange.Add(new EventDelegate(() =>
{
//背景音乐开关
}));
togSound.onChange.Add(new EventDelegate(() =>
{
//背景音效开关
}));
HideMe();
}
public override void ShowMe()
{
base.ShowMe();
//显示自己时候,更新面板的内容数据
}
public override void HideMe()
{
base.HideMe();
//隐藏自己的时候,需要保存这次的数据
}
}
开始界面
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BeginPanel : BasePanel<BeginPanel>
{
public UIButton btnBegin;
public UIButton btnRank;
public UIButton btnSetting;
public UIButton btnQuit;
protected override void Init()
{
btnBegin.onClick.Add(new EventDelegate ( () =>
{
//显示武器面板
print("选角");
//隐藏自己
HideMe();
}));
btnRank.onClick.Add(new EventDelegate(() =>
{
//显示排行榜
print("排行榜");
}));
btnSetting.onClick.Add(new EventDelegate(() =>
{
//显示设置面板
SettingPanel.Instance.ShowMe();
print("设置");
}));
btnQuit.onClick.Add(new EventDelegate(() =>
{
//退出游戏
print("退出");
Application.Quit();
}));
}
}