Unity New UI : How To Build Draggable UI
- 詳細內容
- 分類:Unity
- 發佈:2015-01-17, 週六 02:05
- 點擊數:1428
Unity New UI : How To Build Draggable UI
A way to implement Draggable UI :
using UnityEngine; using System.Collections; public class vUIDrag : MonoBehaviour { float OffsetX; float OffsetY; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void BeginDrag(){ OffsetX=transform.position.x-Input.mousePosition.x;; OffsetY=transform.position.y-Input.mousePosition.y;; } public void OnDrag(){ transform.position= new Vector3( Input.mousePosition.x +OffsetX, Input.mousePosition.y +OffsetY); } }
按個讚!~支持本站!~
FB推薦載入中