add
This commit is contained in:
parent
f401818c64
commit
80277e13ec
@ -7,8 +7,10 @@ public class Promptmgr : MonoBehaviour
|
|||||||
public static Promptmgr Instance;
|
public static Promptmgr Instance;
|
||||||
private GameObject PromptPrefab;
|
private GameObject PromptPrefab;
|
||||||
private GameObject PromptWhiltePrefab;
|
private GameObject PromptWhiltePrefab;
|
||||||
private float movedistance = 800f;//Òƶ¯µÄ¾àÀë
|
private float movedistance = 400f;//移动的距离
|
||||||
private float moveDuration = 1f;//Òƶ¯ËùÐèµÄʱ¼ä
|
private float moveDuration = 1f;//Òƶ¯ËùÐèµÄʱ¼ä
|
||||||
|
public GameObject canvs;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -17,22 +19,43 @@ public class Promptmgr : MonoBehaviour
|
|||||||
DontDestroyOnLoad(this);
|
DontDestroyOnLoad(this);
|
||||||
PromptPrefab = (GameObject)Resources.Load("Prefabs/Prompt");
|
PromptPrefab = (GameObject)Resources.Load("Prefabs/Prompt");
|
||||||
PromptWhiltePrefab = (GameObject)Resources.Load("Prefabs/PromptWhite");
|
PromptWhiltePrefab = (GameObject)Resources.Load("Prefabs/PromptWhite");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void PromptBubble(string message)
|
public void PromptBubble(string message)
|
||||||
{
|
{
|
||||||
GameObject proobj = Instantiate(PromptPrefab);
|
PromptBubble(message, Color.white, Color.black);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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)
|
public void PromptWhilteBubble(string message)
|
||||||
{
|
{
|
||||||
GameObject proobj = Instantiate(PromptWhiltePrefab);
|
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);
|
proobj.transform.position = new Vector3(Screen.width / 2, Screen.height / 2 + 33, 0);
|
||||||
StartCoroutine(MoveUpandDestory(proobj));
|
StartCoroutine(MoveUpandDestory(proobj));
|
||||||
Text protext = proobj.transform.Find("Prompttext").GetComponent<Text>(); ;
|
Text protext = proobj.transform.Find("Prompttext").GetComponent<Text>(); ;
|
||||||
@ -65,7 +88,4 @@ public class Promptmgr : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user