| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class ScrollViewScript : MonoBehaviour, IDropHandler
- {
- 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>();
- questionCard.PrepareQuestion("QuestionText", "AnswerText");
- questionCard.GetQuestion(true);
- questionCard.SetQuestionSafe();
- questionCard.transform.SetSiblingIndex(0);
- questionCard.transform.SetParent(contentPanel);
- }
- public void OnDrop(PointerEventData eventData) {
- Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
- if (d == null || !d.gameObject.name.Contains("NewQuestion")) {
- return;
- }
- // Popup modal asking are you sure here or at onDragEnd?
- GameObject question = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
- QuestionCard questionCard = question.GetComponent<QuestionCard>();
- questionCard.PrepareQuestion("QuestionText", "AnswerText");
- NewQuestion nq = d.GetComponent<NewQuestion>();
- questionCard.SetAnswerText(nq.answerString);
- questionCard.SetQuestionText(nq.questionString);
- questionCard.questionString = nq.questionString;
- questionCard.answerString = nq.answerString;
- questionCard.categoryString = nq.categoryString;
- questionCard.idString = nq.idString;
- questionCard.transform.SetParent(contentPanel);
- questionCard.transform.SetSiblingIndex(d.placeholder.transform.GetSiblingIndex());
- }
- }
|