Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
//		foreach(uConversation c in LoadResources.Instance.Conversations) {
//			if(c.getName().Equals(name)) {
//				conv = c;
//				break;
//			}
//		}

//		for(int i = 0; i < conv.getNodeList().Count; i++) {
//			uConversationNode node = conv.getNodeList()[i];
//			Debug.Log(i + ". " + node.getText());
//		}

        curNode      = uConversationNode.getNodeByStringID(startConvID);
        nameUI1.text = name;
        nameUI2.text = name;
        if (curNode == null)
        {
            Debug.Log(this.name + " cannot find their conversation!");
        }
        curText.text = curNode.getText();
        int numResponses = 0;

        foreach (string s in curNode.getAlternativeStrings())
        {
//			Debug.Log("Alternatives: " + s);
            if (numResponses > 0)
            {
                GameObject newButton = (GameObject)Instantiate(buttonPrefab);
                newButton.GetComponent <RectTransform>().SetParent(buttonHolder.transform, false);
                newButton.GetComponent <RectTransform>().anchoredPosition = Vector2.zero - new Vector2(0, 18 + (numResponses - 1) * 55);
                newButton.GetComponent <RectTransform>().localScale       = Vector3.one;
                newButton.GetComponent <RectTransform>().localEulerAngles = Vector3.zero;
                newButton.GetComponent <RectTransform>().GetChild(0).GetComponent <Text>().text = s;
            }
            else
            {
                buttonPrefab.transform.GetChild(0).GetComponent <Text>().text = s;
            }
            numResponses++;
        }
    }
Esempio n. 2
0
    private void UpdateUI()
    {
        curText.text = curNode.getText();
        int numResponses = 0;

        //INEFFICIENT
        for (int i = 1; i < buttonHolder.transform.childCount; i++)
        {
            Destroy(buttonHolder.transform.GetChild(i).gameObject);
        }

        if (curNode.getAlternativeStrings().Count != 0)
        {
            foreach (string s in curNode.getAlternativeStrings())
            {
                if (numResponses > 0)
                {
                    GameObject newButton = (GameObject)Instantiate(buttonPrefab);
                    newButton.GetComponent <RectTransform>().SetParent(buttonHolder.transform, false);
                    newButton.GetComponent <RectTransform>().anchoredPosition = Vector2.zero - new Vector2(0, 18 + (numResponses - 1) * 55);
                    newButton.GetComponent <RectTransform>().localScale       = Vector3.one;
                    newButton.GetComponent <RectTransform>().localEulerAngles = Vector3.zero;
                    newButton.GetComponent <RectTransform>().GetChild(0).GetComponent <Text>().text = s;
                }
                else
                {
                    buttonPrefab.transform.GetChild(0).GetComponent <Text>().text = s;
                }
                numResponses++;
            }
        }
        else
        {
            buttonPrefab.transform.GetChild(0).GetComponent <Text>().text = "Goodbye";
        }
    }