[Unity][UGUI]跟随角色头顶的名字血条

 

 

[Unity][UGUI]跟随角色头顶的名字血条_第1张图片

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIFollowObject : MonoBehaviour
{
    public Text nameLabel;
	// Update is called once per frame
	void Update ()
    {
        Vector3 namePos = Camera.main.WorldToScreenPoint(this.transform.position);
        namePos.z = 0;//namePos.z如果不为0,则有可能覆盖 其他的UI
        nameLabel.transform.position = namePos;
    }
}

 

 

 

相关文章:

1.

[Unity][特效][UGUI]HUD围绕角色头顶的血条特效逐渐减血逐渐加血

2. 

[Unity]动态人物头像

3.[Unity][UGUI]用UGUI自带的Canvas角色头顶的名字

4.[Unity][Animator][UGUI]伤害飘字跟随角色不停的移动

5.[Unity][Animation&Animator][特效]伤害飘字

6.

你可能感兴趣的:(Unity,UGUI)