using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; public class DragWindowUI : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerDownHandler { private RectTransform dragRectTransform; private Canvas canvas; private Image backgroundImage; private Color backgroundColor; public void OnBeginDrag(PointerEventData eventData) { backgroundColor.a = .4f; backgroundImage.color = backgroundColor; } public void OnDrag(PointerEventData eventData) { dragRectTransform.anchoredPosition += eventData.delta / canvas.scaleFactor; } public void OnEndDrag(PointerEventData eventData) { backgroundColor.a = .8f; backgroundImage.color = backgroundColor; } public void OnPointerDown(PointerEventData eventData) { dragRectTransform.SetAsLastSibling(); } public void CloseWindow() { //Destroy(dragRectTransform.gameObject); transform.parent.gameObject.SetActive(false); } void Awake() { dragRectTransform = transform.parent.GetComponent(); backgroundImage = GetComponent(); backgroundColor = backgroundImage.color; } // Start is called before the first frame update void Start() { canvas = SimpleInventorySystem.InventorySystem.instance.inventoryUI; } // Update is called once per frame void Update() { } }