Unity客户端架构-DialogManager

发表于2018-09-10
评论0 2.3k浏览
继续Unity客户端架构系列的介绍,上一篇中给大家介绍了BaseDialog的使用,这一篇我们就来看看DialogManager的使用。

直接上代码:
using UnityEngine;
using System.Collections;
using System;
public class DialogManager : MonoBehaviour 
{
    private Hashtable dialogs = new Hashtable();
    public bool DialogExist(DialogType type)
    {
        return this.dialogs.ContainsKey(type);
    }
    public DialogInfo AddDialog(DialogType type)
    {
        DialogInfo dialogInfo = new DialogInfo();
        dialogInfo.type = type;
        this.dialogs.Add(type, dialogInfo);
        return dialogInfo;
    }
    public void ResetDialog()
    {
        IDictionaryEnumerator enumerator = this.dialogs.GetEnumerator();
        while (enumerator.MoveNext())
        {
            DialogInfo dialoginfo = enumerator.Value as DialogInfo;
            dialoginfo.AsynState = AsynState.Completed;
        }
    }
    public DialogInfo GetDialogInfo(DialogType type)
    {
        if (!this.DialogExist(type))
        {
            return this.AddDialog(type);
        }
        return this.dialogs[type] as DialogInfo;
    }
    public void RemoveDialog(DialogType type)
    {
        if (this.DialogExist(type))
        {
            this.dialogs.Remove(type);
        }
    }
    public void ClearDialog()
    {
        this.dialogs.Clear();
    }
    public Transform GetDialog(DialogType type)
    {
        if (type == DialogType.None)
        {
            return null;
        }
        string str = Util.ConvertPanelName(type);
        return io.Gui.transform.Find(str);
    }
}
来自:https://blog.csdn.net/u013108312/article/details/52565174

Unity客户端架构系列教程

如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引