Tanoda
pb_DraggablePanel.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3using System.Collections;
5using GILES;
6
7namespace GILES.Interface
8{
9 public class pb_DraggablePanel : MonoBehaviour, IBeginDragHandler, IDragHandler
10 {
11 Rect screenRect = new Rect(0,0,0,0);
12
14 public RectTransform windowParent;
15
16 public void OnBeginDrag(PointerEventData eventData)
17 {
18 screenRect.width = Screen.width;
19 screenRect.height = Screen.height;
20 }
21
22 public void OnDrag(PointerEventData eventData)
23 {
24 if(windowParent == null)
25 {
26 Debug.LogWarning("Window parent is null, cannot drag a null window.");
27 return;
28 }
29
30 if(screenRect.Contains(eventData.position))
31 windowParent.position += (Vector3) eventData.delta;
32 }
33 }
34}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
RectTransform windowParent
The root gameobject of this window.
void OnBeginDrag(PointerEventData eventData)
void OnDrag(PointerEventData eventData)