public SurveyProjectButton(SurveyProject sProject, RectTransform buttonTemplate,float fromTop) { surveyProject = sProject; rectTransform = (RectTransform)Instantiate(buttonTemplate); name = sProject.projectName; rectTransform.gameObject.SetActive(true); rectTransform.name = name; ((Text)rectTransform.GetChild(0).GetComponent<Text>()).text = name; rectTransform.parent = buttonTemplate.parent; rectTransform.SetDefaultScale(); rectTransform.SetSize(buttonTemplate.GetSize()); rectTransform.SetPivotAndAnchors(Vector2.zero); rectTransform.SetLeftTopPosition(new Vector2(-(rectTransform.GetWidth()*0.5f), fromTop)); Button button = rectTransform.GetComponent<Button>(); button.onClick.AddListener(OnUse); }