add
This commit is contained in:
parent
f401818c64
commit
80277e13ec
@ -7,8 +7,10 @@ public class Promptmgr : MonoBehaviour
|
||||
public static Promptmgr Instance;
|
||||
private GameObject PromptPrefab;
|
||||
private GameObject PromptWhiltePrefab;
|
||||
private float movedistance = 800f;//Òƶ¯µÄ¾àÀë
|
||||
private float movedistance = 400f;//移动的距离
|
||||
private float moveDuration = 1f;//Òƶ¯ËùÐèµÄʱ¼ä
|
||||
public GameObject canvs;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -17,22 +19,43 @@ public class Promptmgr : MonoBehaviour
|
||||
DontDestroyOnLoad(this);
|
||||
PromptPrefab = (GameObject)Resources.Load("Prefabs/Prompt");
|
||||
PromptWhiltePrefab = (GameObject)Resources.Load("Prefabs/PromptWhite");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PromptBubble(string message)
|
||||
{
|
||||
GameObject proobj = Instantiate(PromptPrefab);
|
||||
proobj.transform.SetParent(GameObject.Find("Canvas").transform);
|
||||
proobj.transform.position =new Vector3(Screen.width/2,Screen.height/2+33,0);
|
||||
StartCoroutine(MoveUpandDestory(proobj));
|
||||
Text protext = proobj.transform.Find("Prompttext").GetComponent<Text>();
|
||||
protext.text = message;
|
||||
PromptBubble(message, Color.white, Color.black);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示弹窗
|
||||
/// </summary>
|
||||
/// <param name="message">显示的内容</param>
|
||||
/// <param name="textColor">文字颜色,默认白色</param>
|
||||
/// <param name="backgroundColor">背景颜色,默认黑色</param>
|
||||
public void PromptBubble(string message, Color textColor, Color backgroundColor)
|
||||
{
|
||||
GameObject proobj = Instantiate(PromptPrefab);
|
||||
proobj.transform.SetParent(canvs.transform);
|
||||
proobj.transform.position = new Vector3(Screen.width / 2, Screen.height / 2 + 33, 0);
|
||||
StartCoroutine(MoveUpandDestory(proobj));
|
||||
|
||||
Text protext = proobj.transform.Find("Prompttext").GetComponent<Text>();
|
||||
protext.text = message;
|
||||
protext.color = textColor; // 设置文本颜色
|
||||
|
||||
// 设置背景颜色
|
||||
Image backgroundImage = proobj.GetComponent<Image>();
|
||||
if (backgroundImage != null)
|
||||
{
|
||||
backgroundImage.color = backgroundColor; // 设置背景颜色
|
||||
}
|
||||
}
|
||||
public void PromptWhilteBubble(string message)
|
||||
{
|
||||
GameObject proobj = Instantiate(PromptWhiltePrefab);
|
||||
proobj.transform.SetParent(GameObject.Find("Canvas").transform);
|
||||
proobj.transform.SetParent(canvs.transform);
|
||||
proobj.transform.position = new Vector3(Screen.width / 2, Screen.height / 2 + 33, 0);
|
||||
StartCoroutine(MoveUpandDestory(proobj));
|
||||
Text protext = proobj.transform.Find("Prompttext").GetComponent<Text>(); ;
|
||||
@ -65,7 +88,4 @@ public class Promptmgr : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user