public void Setup(int index, string question, string leftEnd, string rightEnd, int numbers, LikertPanel lp, int oIndex) { OriginalIndex = oIndex; Stimulus = question; Index = index; Question.text = (index + 1) + ". " + question; LeftEnd.text = leftEnd; RightEnd.text = rightEnd; likertPanel = lp; for (int i = 1; i < numbers + 1; i++) { GameObject g = GameObject.Instantiate(NumberPrefab); g.transform.SetParent(NumberLine.transform); g.GetComponentInChildren <Text>().text = "" + i; g.GetComponent <Button>().onClick.AddListener(() => Notify(g)); } RectTransform r = (RectTransform)this.transform; r.localScale = Vector3.one; }
void OnGUI() { GUILayout.Label("General Parameters", EditorStyles.boldLabel); questionnaireName = EditorGUILayout.TextField("Questionnaire name", questionnaireName); leftHandText = EditorGUILayout.TextField("Left hand teft", leftHandText); rightHandText = EditorGUILayout.TextField("Left hand teft", rightHandText); pointsOnScale = EditorGUILayout.IntSlider("Points on scale", pointsOnScale, 1, 50); numberOfQuestions = EditorGUILayout.IntSlider("Number of questions", numberOfQuestions, 1, 50); while (questions.Count < numberOfQuestions) { Question q = new Question(); questions.Add(q); } while (questions.Count > numberOfQuestions) { questions.RemoveAt(questions.Count - 1); } GUILayout.Label("Questions", EditorStyles.boldLabel); foreach (Question q in questions) { EditorGUILayout.BeginHorizontal(); q.prompt = EditorGUILayout.TextField("Question", q.prompt); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Create questionnaire")) { GameObject questionnaire = (PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath("Assets/TestTube/Quick UI/Panels/Likert Panel.prefab", typeof(GameObject)) as GameObject)) as GameObject; questionnaire.transform.SetParent(GameObject.Find("Blank UI").transform); LikertPanel qPanel = questionnaire.GetComponent <LikertPanel>(); List <string> trialText = new List <string>(); foreach (Question q in questions) { trialText.Add(q.prompt); } qPanel.Questions = trialText.ToArray(); qPanel.name = questionnaireName; qPanel.NumbersOnLine = pointsOnScale; qPanel.LeftHandText = new string[] { leftHandText }; qPanel.RightHandText = new string[] { rightHandText }; qPanel.LikertTitle = questionnaireName; RectTransform r = ((RectTransform)questionnaire.transform); r.localPosition = Vector2.zero; r.localScale = Vector3.one; r.offsetMax = Vector2.zero; r.offsetMin = Vector2.zero; } }