广告结束回来,精彩继续!
我们游戏中存在好多种消息机制即二次确认框,这也是游戏中非常重要的一部分,这可以给玩家带来更好的体验,而我们做游戏的目标不就是给玩家创造美好的体验么?
一下是我在开发项目中开发的一个提示框组件即二次确认框:
Enum MessageBoxButtons
{
OK,
Cancel,
Sure
}
using UnityEngine;
using System;
using System.Collections;
// 对话提示框显示组件
public class MessageBox : MonoBehaviour
{
public static MessageBox Instance { get { return instance; } }
private static MessageBox instance = null;
// 是否点击任意处关闭对话提示框
private bool isAnywhereQuit;
private GameObject goOK;
private GameObject goCancel;
private GameObject goSure;
private UILabel labelMessage;
private UILabel labelOK;
private UILabel labelCancel;
private UILabel labelSure;
<span style="white-space:pre"> </span>// 都是点击确认,取消还有空白处的回调函数
private Action firstCallback;
private Action secondCallback;
private Action thirdCallback;
private Action callback;
private Action anyWhereCallback;
void Awake()
{
instance = this;
var refs = GetComponent<GameObjectRef>();
goOK = refs["OK&