Example #1
0
    public void InitScratch()
    {
        ScratchCamera.gameObject.SetActive(true);
        int chooseQuest = DataManagerCourse.Instance.dataQuestScratch.groupScratch.Count;

        g = DataManagerCourse.Instance.dataQuestScratch.groupScratch[Random.Range(0, chooseQuest)];

        Utils.RemoveAllChildren(parrentAnswer);
        txtQuestion.text = g.title;
        imgQuest.sprite  = Resources.Load <Sprite>("IMGScratch/" + g.linkImageName);

        int LableAnswer = 0;

        foreach (Answer ans in g.answer)
        {
            GameObject obj = Instantiate(Answer, parrentAnswer);
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localRotation = Quaternion.identity;
            AnswerInit ani = obj.GetComponent <AnswerInit>();
            ani.Init(Utils.GetLableAnswer(LableAnswer), ans.title);
            int answerChoose = LableAnswer;
            ani.GetComponentInChildren <Button>().onClick.AddListener(delegate { OnClickAnswer(answerChoose, ans.title); });
            LableAnswer++;
        }
    }
Example #2
0
    public void InitDragAndDropData()
    {
        int chooseQuest = DataManagerCourse.Instance.dataQuestScratch.groupScratch.Count;

        g = DataManagerCourse.Instance.dataQuestScratch.groupScratch[Random.Range(0, chooseQuest)];

        Utils.RemoveAllChildren(parrentAnswer);
        Utils.RemoveAllChildren(parrentAnswer1);
        Utils.RemoveAllChildren(parrentAnswer2);
        foreach (Answer ans in g.answer)
        {
            GameObject obj = Instantiate(prefabAnswer, parrentAnswer);
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.GetChild(0).GetComponent <Text>().text = ans.title;
            Canvas.ForceUpdateCanvases();
            DragAnswerElement dr = obj.GetComponent <DragAnswerElement>();
            dr.InitAnswer();
        }
    }