76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.LogicObj;
|
|||
|
|
|||
|
public class DialogTipUIRoot : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
public GameObject m_CloneDialogUI;
|
|||
|
|
|||
|
List<DialogTipUI> m_DiaLogTips = new List<DialogTipUI>();
|
|||
|
|
|||
|
public void ShowDialog(int ServerID, float showTime, string dialog)
|
|||
|
{
|
|||
|
for(int i=0;i<m_DiaLogTips.Count;i++)
|
|||
|
{
|
|||
|
if(m_DiaLogTips[i].ServerId == ServerID)
|
|||
|
{
|
|||
|
m_DiaLogTips[i].ShowDialog(ServerID, showTime, dialog);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
for(int i=0;i<m_DiaLogTips.Count;i++)
|
|||
|
{
|
|||
|
if(m_DiaLogTips[i].gameObject.activeSelf==false)
|
|||
|
{
|
|||
|
m_DiaLogTips[i].ShowDialog(ServerID, showTime, dialog);
|
|||
|
m_DiaLogTips[i].gameObject.SetActive(true);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
GameObject newDialog = GameObject.Instantiate(m_CloneDialogUI) as GameObject;
|
|||
|
if(newDialog!=null)
|
|||
|
{
|
|||
|
DialogTipUI newDialogUI = newDialog.GetComponent<DialogTipUI>();
|
|||
|
if(newDialogUI!=null)
|
|||
|
{
|
|||
|
newDialog.transform.SetParent(transform);
|
|||
|
newDialog.transform.localEulerAngles = Vector3.zero;
|
|||
|
newDialog.transform.localScale = Vector3.one;
|
|||
|
newDialog.SetActive(true);
|
|||
|
newDialogUI.ShowDialog(ServerID, showTime, dialog);
|
|||
|
m_DiaLogTips.Add(newDialogUI);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveDiaLog(DialogTipUI dialog)
|
|||
|
{
|
|||
|
for(int i=0;i<m_DiaLogTips.Count;i++)
|
|||
|
{
|
|||
|
if(m_DiaLogTips[i] == dialog)
|
|||
|
{
|
|||
|
if(m_DiaLogTips.Count<=5)
|
|||
|
{
|
|||
|
m_DiaLogTips[i].ServerId = -1;
|
|||
|
m_DiaLogTips[i].gameObject.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_DiaLogTips[i].transform.SetParent(null);
|
|||
|
m_DiaLogTips[i].gameObject.SetActive(false);
|
|||
|
GameObject.Destroy(m_DiaLogTips[i]);
|
|||
|
m_DiaLogTips.RemoveAt(i);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|