/************************************************************
Copyright (C), 2007-2017,BJ Rainier Tech. Co., Ltd.
FileName: RayCastHitControl.cs
Author: Version :1.0 Date: 2018/8/15
Description: 鼠标进入物体显示标签名(UI位置随3D物体的位置)
************************************************************/
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class ShowBendWoodName : MonoBehaviour
{
private Vector3 namePosInScreen;
public Vector3 namePosOffset;//标签偏移量
public GameObject prefabNameSprite;//预制体
public Transform nameLableFather;//标签父类
private GameObject nameLable;
// Use this for initialization
void Start()
{
nameLable = Instantiate(prefabNameSprite, new Vector3(namePosInScreen.x, namePosInScreen.y, 0f), Quaternion.identity) as GameObject;
nameLable.transform.SetParent(nameLableFather);
nameLable.name = gameObject.name;
UI位置跟随3D物体
最新推荐文章于 2023-06-20 10:48:27 发布
这篇博客探讨了如何使UI元素如PrefabNameSprite跟随3D物体移动,实现UI在3D场景中的动态定位,确保信息始终与游戏对象保持同步。
摘要由CSDN通过智能技术生成