我创建了一个场景,用户必须从架子上拿起食物。但是当鼠标被带到产品上时,标签在某些方向上具有闪烁效果。当我在这里和那里移动我的第一个人时,闪烁的效果消失,显示变得稳定。请帮我修复这个bug。
以下是视频的link
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Coke_bottles : MonoBehaviour
{
public GUIText textObject;
public bool showGUI;
public GameObject[] objects;
public int i = 0;
void OnMouseOver()
{
transform.localScale = new Vector3(5f, 5f, 5f);
showGUI = true;
}
void OnMouseExit()
{
transform.localScale = new Vector3(2.8593f, 3.2275f, 1f);
showGUI = false;
}
void OnGUI()
{
GUI.color = Color.white;
GUIStyle myStyle = new GUIStyle(GUI.skin.GetStyle("label"));
myStyle.fontSize = 20;
GUI.Label(new Rect(Input.mousePosition.x, Input.mousePosition.y, 100f, 10f), "");
if (showGUI)
{
GUI.Box(new Rect(100, 50, 300f, 100f), "");
GUI.Label(new Rect(100, 50, 999f, 999f), "You are selecting " + gameObject.name, myStyle);
}
if (i == 1)
{
GUI.color = Color.green;
myStyle.fontSize = 15;
GUI.Label(new Rect(610.3f, 160.56f, 300f, 100f), "Soft Drink Selected");
}
}
void OnMouseDown()
{
i = 1;
transform.position = new Vector3(346.457f, 21.78f, 36.715f);
transform.Rotate(new Vector3(0, -90, 0));
}