unity3d:ui跟着gameobject移动

一时失言乱红尘 2022-05-11 10:20 351阅读 0赞
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class UiFollowObj : MonoBehaviour {
  5. Transform m_trans;
  6. public Transform m_followTrans;
  7. public GameObject m_child;
  8. // Use this for initialization
  9. void Start () {
  10. m_trans = this.transform;
  11. }
  12. private void LateUpdate()
  13. {
  14. if (m_followTrans != null)
  15. {
  16. Vector2 player2DPosition = Camera.main.WorldToScreenPoint(m_followTrans.position);
  17. m_trans.position = player2DPosition;
  18. }
  19. }
  20. }

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,351人围观)

还没有评论,来说两句吧...

相关阅读

    相关 UE4 3DUI的弧度

    想要实现的效果是,展现在页面上的3DUI(即Actor)具备弧度。 修改的位置: ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_1