Advertisement
Guest User

Unity: Drag-able Windows (Unity 4.6)

a guest
Sep 19th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.EventSystems;
  4. using System.Collections;
  5.  
  6. public class UIWindowBase : MonoBehaviour, IDragHandler
  7. {
  8.     RectTransform m_transform = null;
  9.    
  10.     // Use this for initialization
  11.     void Start () {
  12.         m_transform = GetComponent<RectTransform>();
  13.     }
  14.    
  15.     public void OnDrag(PointerEventData eventData)
  16.     {
  17.         m_transform.position += new Vector3(eventData.delta.x/100, eventData.delta.y/100);
  18.        
  19.         // magic : add zone clamping if's here.
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement