0
\$\begingroup\$

I have made a box where you can type in your name in unity. After typing your name you can click on the button. Clicking on the button it will copy the string that you typed in within a sentence. so like: "The name" + stringToEdit + "is the name that your parents gave you!" . Now I used debug.log so that the text will show up in the debug. Is there a way to make the button add a text in a specific position in the scene that copies the string plus the sentences after being clicked???

I Used JS script by the way.

\$\endgroup\$
1
  • \$\begingroup\$ Do you need the text positioned on screen (2D) or "inside" the game world? \$\endgroup\$ Commented Nov 15, 2015 at 15:28

1 Answer 1

1
\$\begingroup\$

using a c# script you would have to call something like this:

OnGUI()
{
    //check that the text has been added
    if(text != null)
    {
        //width and height of the text box pop-up
        int width = 60,
            height = 20;
        Vector2 boxPosition = new Vector2((Screen.width / 2) - (width / 2), (Screen.width / 2) - (width / 2)),
            boxSize = new Vector2(width, height);

        //draw the text on scrren
        GUI.Label(new Rect(boxPosition, boxSize), text);
    }
}

I've simplified it so that it is easy to read but you could make it way more compact once you have it working

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.