I’m making an rpg and I want the player to be able to enter a name which will be stored as a string variable but I want to know if there’s a way to call that string from the inspector in a text box.
For example if I make a new text and fill it in the inspector to say “good morning hero”, can I do something like “good morning hero.Charactername” or something like that? Do I need to write a custom inspector(no idea how I would do that btw) or is there a better/simpler way to do that?
Ps: the question form doesn’t let me add any other topic so that’s why I had to pic the only one working.
On button click or whatever you do to save player’s nickname you have to get textbox content from assigned Text class by accesing it’s .text and then save it to player prefs(the easier way) or serialize it and save in .save file (the harder way), so your user won’t have to type his name each time he runs the game. Then you can retrieve player’s name from prefs once and store it in string variable.
Now when you display the story text you have to concatenate the strings by getting the .text of the storybox
and adding player name variable
myTextBox.text += playerNameVariable;
or set the whole text at once, if there is is something after player’s name
(these are not the optimal way, but should get you started)