using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class showSwitch : MonoBehaviour {
bool isShowName,isSwitchSence;
void Start () {
isShowName = false;
isSwitchSence = false;
}
void OnMouseEnter()
{
isShowName = true;
}
void OnMouseExit()
{
isShowName = false;
}
private void OnGUI()
{
if(isShowName)
{
GUIStyle style1 = new GUIStyle();
style1.fontSize = 30;
style1.normal.textColor = Color.red;
GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 400, 50), this.name, style1);
}
}
void OnCollisionEnter(Collision other)
{
if (string.Equals("StartCity", other.gameObject.name))
{
isSwitchSence = true;
}
}
void OnCollisionExit(Collision other)
{
isSwitchSence = false;
}
void OnMouseDown()
{
if (isSwitchSence)
{
SceneManager.LoadScene("StartCity");
DontDestroyOnLoad(this);
DontDestroyOnLoad(GameObject.Find("Camera"));
transform.position = new Vector3(800,32,700);
}
}
void Update () { }
}
场景切换+鼠标放在物体上显示名字
最新推荐文章于 2022-05-11 10:05:39 发布