Exemplo n.º 1
0
    public override void AddItem(string date, string title, string comments)
    {
        Survey survey = new Survey()
        {
            date = date, title = title, comments = comments, manager = new Manager(), store = new Store()
        };

        GameObject go = (GameObject)Instantiate(prefab);

        go.transform.SetParent(contentRect.transform);
        go.name = "Survey " + contentRect.childCount.ToString();
        go.transform.localScale = new Vector3(1f, 1f, 1f);
        go.SetActive(true);

        if (survey.title.IsNullOrEmpty())
        {
            survey.title = go.name;
        }

        SurveyItem item = go.GetComponent <SurveyItem> ();

        item.Setup(survey);

        if (AppController.instance.allSurveys != null)
        {
            AppController.instance.allSurveys.Add(survey);
        }

        updateContentRect();

        form.gameObject.SetActive(false);
        addButton.gameObject.SetActive(true);
        removeButton.gameObject.SetActive(false);
    }