- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
- using System.Collections;
- using iGUI;
- public class Test : MonoBehaviour
- {
- public Transform targetTransform;
- public iGUIElement element;
- float elementOffset = 0;
- void Update()
- {
- Vector3 targetGUIPoint = Camera.main.WorldToScreenPoint(targetTransform.position + offset);
- targetGUIPoint.y = Screen.height - targetGUIPoint.y;
- targetGUIPoint.x -= element.rect.width * 0.5f;
- targetGUIPoint.y -= element.rect.height * 0.5f;
- element.rect.x = targetGUIPoint.x;
- element.rect.y = targetGUIPoint.y;
- //unity3d教程:www.unitymanual.com
- targetTransform.Translate(Input.GetAxis("Vertical") * Vector3.forward);
- targetTransform.Translate(Input.GetAxis("Horizontal") * Vector3.left);
- }
- }
复制代码 |
|