Пример #1
0
    // Display Shout Text Box
    public void DisplayText(int objectID, ShoutTextZone shoutZone)
    {
        if (shoutZone != null) // Pass the shoutZone as a reference to destroy it once text is finished.
        {
            if (interactiveDialogue.ContainsKey(objectID))
            {
                tbManager = this.GetComponent <TextBoxManager>();

                if (tbManager != null)
                {
                    tbManager.CreateTextBox(interactiveDialogue[objectID], shoutZone, null);
                }
                else
                {
                    print("TextBoxManager is null!");
                }
            }
        }
    }
    // Create a text box and animate the spoken dialogue
    public void CreateTextBox(List <string> dialogue, ShoutTextZone shoutZone, TextZone textZone)
    {
        if (shoutZone != null)
        {
            shoutZoneObject = shoutZone.transform.gameObject;
            textZoneObject  = null;
        }
        else if (textZone != null)
        {
            shoutZoneObject = null;
            textZoneObject  = textZone.transform.gameObject;
        }

        if (dialogue != null)
        {
            GameObject clone = Instantiate(textBoxPrefab) as GameObject;
            textPanel = clone.transform.GetChild(0).gameObject;                // Set panel
            boxText   = textPanel.transform.GetChild(0).GetComponent <Text>(); // Set text

            if (textFont)
            {
                boxText.font  = textFont;
                boxText.color = Color.red;
            }

            clone.transform.SetParent(canvas.transform, false); // Parent text box to canvas
            scrubbedText = dialogue;

            if (endLine == 0)
            {
                endLine = scrubbedText.Count - 1;
            }

            StartCoroutine(TextScroll(scrubbedText[currLine]));
        }
    }