public DragPreview Create(Transform parent, InventoryObject obj)//, Vector3 position)
        {
            DragPreview dp = Instantiate(gameObject, parent).GetComponent <DragPreview>();

            dp._image.sprite = obj.Icon;
            //dp._image.SetNativeSize();
            return(dp);
        }
Example #2
0
        public virtual void OnEndDrag(PointerEventData eventData)
        {
            if (_dragPreview != null)
            {
                Destroy(_dragPreview.gameObject);
                _dragPreview = null;
            }

            OnObjectEndDragHandler?.Invoke(this);
        }
Example #3
0
        public virtual void OnBeginDrag(PointerEventData eventData)
        {
            if (canvas == null)
            {
                return;
            }

            if (_object != null)
            {
                _dragPreview = _dragPreviewTemplate.Create(transform, _object);// transform.position);
                _dragPreview.transform.SetAsLastSibling();

                OnObjectBeginDragHandler?.Invoke(this, _object);

                OnDrag(eventData);
            }
        }