create a script so the player can name their character?

hey, i wanted to know how the popular game http://slither.io/ allows custom names and show names on players. is it possible to do within unity? dont know if that makes me sound silly asking is it possible but i just wanna know, thanks!
heres the game(i want name inside the player & visible to others)

You just need to provide an inputfield where they can put in a name and then capture that value and display it where you need it to be, like a text ui object.

Just to add to this I made this little snippet just for you, OP.

using UnityEngine.UI;
using UnityEngine;
using System.Collections;

public class UsernameManager
{
    public InputField nameField;

    // Player name variable and property to access
    // it from other scripts.
    string playerName;
    public string PlayerName
    {
        get{ return playerName; }
        set{ Debug.Log("You are not allowed to set the player name like that"); }
    }

    //Use this on a "Submit" button to set the playerName variable.
    public void SubmitName()
    {
        if(string.IsNullOrEmpty(nameField.text) == false)
        {
            playerName = nameField.text;
        }
    }
}

As an example. As you can see, it doesnt have to complicated.

NOTE:
This code may not work as-is, it is hand typed.

you’re some legend man :smile: thanks a lot

1 Like