コード例 #1
0
        // this shows the choices
        private void ShowChoice(Descision descision)
        {
            choice = -1;
            // create the buttons
            for (int i = 0; i < descision.Choices.Count; i++)
            {
                Choice ch = descision.Choices[i];

                // just using Instantiate for now, since this is just a prototype
                // but we should be using some sort of object pool
                GameObject button = Instantiate(choiceButtonPrefab);
                button.transform.SetParent(choicesParent.transform);
                button.transform.localPosition = new Vector3(0, (i - 2) * 85, 0);
                button.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 80);
                button.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 600);
                button.GetComponent <Button>().onClick.AddListener(
                    () =>
                {
                    choice = ch.NextNode;
                    Deactivate();
                }
                    );
                button.GetComponentInChildren <Text>().text = ch.Text;
            }
        }
コード例 #2
0
        private void RenderDescsion(Descision descision)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\n");
            for (int i = 0; i < descision.Choices.Count; i++)
            {
                sb.Append("\t" + i + ": " + descision.Choices[i].Text);
                sb.Append("\n");
            }
            Console.WriteLine(sb.ToString());
        }