using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class ScrollViewScript : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler { public GameObject prefab; public Transform contentPanel; // Start is called before the first frame update void Start() { SetGiventQuestion(); } public void SetGiventQuestion() { // if new game, create one question card to start with GameObject question = Instantiate(prefab, new Vector2(0,0), Quaternion.identity) as GameObject; QuestionCard questionCard = question.GetComponent(); questionCard.PrepareQuestion(); questionCard.GetQuestion(true); questionCard.SetQuestionSafe(); questionCard.transform.SetParent(contentPanel); } /* public void OnDrop(PointerEventData eventData) { Debug.Log(eventData.pointerDrag + " dropped on " + gameObject.name); Draggable d = eventData.pointerDrag.GetComponent(); if (d != null) { // Kontrollera om man släppt kortet på en korrekt possition, d.parent = contentPanel; } } */ public void OnDrop(PointerEventData eventData) { Draggable d = eventData.pointerDrag.GetComponent(); if (d != null) { d.placeholderParent = this.transform; } } public void OnPointerEnter(PointerEventData eventData) { if (eventData.pointerDrag == null) { return; } Draggable d = eventData.pointerDrag.GetComponent(); if (d != null) { d.placeholderParent = this.transform; } } public void OnPointerExit(PointerEventData eventData) { if (eventData.pointerDrag == null) { return; } Draggable d = eventData.pointerDrag.GetComponent(); if (d != null && d.placeholderParent == this.transform) { d.placeholderParent = d.parent; } } }