How to make a GameObject that prompts user for text input in Unity - unity3d

I'm new to Unity and I'm trying to create an object that upon being placed by the user will prompt the user for text input.
The GameObject is basically a text box. This is also meant for a mobile application.

Fortunately, the answer is very simple and doesn't even require writing code.
You can use the “InputField" UI component.
You can quickly create an InputField from the menu bar entry "GameObject> UI> InputField" or "GameObject> UI> Legacy> InputField>".
This way, if you didn't already have a canvas in the scene, it will be created, and an InputField will be inserted inside.
The parent gameObject manages the inputField, and in fact it is the only one with the component, while the child objects are to show the text, "placeholder" for the text before inserting some text, and "text" to show the text it will write the user.
if you think my answer helped you, you can mark it as accepted and vote positively. I would very much appreciate it :)

Related

How to create simple UI text after deleting TextMeshPro in Unity

I just deleted the TextMeshPro package and I don't know where to create a simple UI text now.
It doesn't show it for me anymore.
I assume that you are talking about TextMeshPro?
Usually if you right click in the hierarchy, you will find stuff as text elements under UI. If you have TextMeshPro installed you still can find regular Button, Text, Input etc. elements under UI > Legacy.

How to change text in textblock from onclick button event in UE5?

I am new to Unreal Engine. Currently I am learning UE5.
I am trying to change text and I had run into problem. And somehow I can't find any information about it.
I simply created user widget, I put a button and a text block. So the question is how can I change text in text block using onclick button event?
I found the solution. It was easier than I thought.
First mark your text as variable. Then literally [Get] it in ur bp.
Get a branch [set 'name'] from your text (I my case Head Txt).
Then from Set set a branch [SetText] and type ur text.
That's it!
Can't believe I spent so many time trying to find the solution in blueprint videos, but accidently found out how to do this from C++ code.
Additional note to this
For beginners, sometimes SetText will not show due to "Context Sensitive" is ticked (by default)
So you need to uncheck the box and make sure to select correct type of SetText with correct target widget type.

Unity Dropdown shows the first time around, duplicated text

I am having this issue where I have a dropdown that should say finances, inventory, and stats. Which when you click on it will cause other panels of UI to appear. Now for some reason, the options it says it has is all Money:(which is the first item name of the first option). Why is that? I've attached images below that show what I mean.
Sorry about the links i dont have high enough rep yet
Duplicated Text of Money
Another instance of ^
My Tabs
Dropdown Setup
Let's take a closer look at your third and fourth pictures and compare them to the default Dropdown UI element.
So in your third image you show a similar tree but what happened to the Template GameObject? It appears you deleted this and replaced it with the Finances GameObject. This is your primary issue. You can't delete this Template GameObject portion of the Dropdown GameObject. The Template is utilized by the Dropdown code in order to further determine the style of the Dropdown you'll see while in game as well as provide you with a template to look at. I don't know all of the internals of how this works, but I know it for sure plays a roll in your issue.
I know this because now take a look at my Dropdown component. Look at the Template field in mine and compare it to yours. Your's is filled with Finances rather than Template, which is the reason that your Dropdown populates with fields from the Finances rather than the values you are trying to pass it.
Here is what I suggest you do. I'm assuming that the FinancesTab, InventoryTab and StatsTab are all UI elements you want to open upon clicking the respective Dropdown item. If that is the case:
Create a new Dropdown GameObject
Don't delete the Template GameObject within it and leave the Template field in the Dropdown GameObject as is
Add a script that utilizes the SetActive function for each UI element (place them in public fields) to the Dropdown GameObject
Set this code up so that when a certain item on the Dropdown is selected, it sets the desired UI Tab to SetActive(true);
Now reference the new script in the OnValueChanged(Int32) field and reference the correct Method from that script in the dropdown menu in the OnValueChanged(Int32) field.
I believe this should solve your problem and help you achieve what you want. Take a look at the Dropdown API and this Youtube tutorial on Dropdowns if my steps are confusing. You can definitely achieve what you want by following those two links (that's how I figured them out!).
Hope this helps!
Your caption is the gameobject 'Label' so its defaulting that in the dropdown because there are no sprites. I'm guessing Label has a text component that says 'Money'?

Gui text does not display

I am using unity 4.6 to develop a small game.
There is no gui text object in the menu. Therefore I created an empty object and added gui text as a component. But it does not display the text I type. Need help on this. Thank you
I think that 4.6 is when they introduced the new UI system so you can use that.It is actually pretty easy...from the drop down menu that you created the game object go to UI. There you can select from a number UI options one of witch is Text or UI Text if my memory serves me well. When you click it it will create a canvas object and UI Text object that is a child of the Canvas.From here just select the Text object and in the inspector you have a textbox which should serve your need :) Also the Canvas is your screen in the sense that if you drag your text to the top left corner of the Canvas(in the scene view) your text will be in the top left corner of the screen when you start your game(at least in the default settings). Hope that helps!
P.S. Also here is a link to the new UI article that the Unity guys have on their site: https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/the-new-ui
That happens sometimes. Delete the current gameobject and the guitext in the scene. Do what you did backwards.
Create a new guitext then create a new empty gameobject. Change the transform of the empty gameobject to 0,0,0 then drag the new gui text into the empty gameobject.
That should solve your problem.
The default text you should see if that went well is "New Text".
If you are editing the new text in the text area and it stopped showing, you will need to increase the width and sometimes the Height of the guiText. Don't use the scale tool as that will work but the graphics you get will be low quality text rendering on the screen.

Updating console/logs in-app. I don't really know how to explain it

I need something, a box, where it updates with new text.
I don't really know how to explain it, if you play the game A Dark Room on iOS, it's the console thing on the left. It updates with new text, and you can scroll up and down with it to find previous text (overflow on it I guess.). I'm terrible at explaining. Sorry.
I was thinking about making a list view controller but I don't know how to use it. I'll look it up, though.
If it's only about logs, like if you want to show text body with few paragraphs, you can use textView. Whenever you have new text you can append it to current text in textview and update textview again. Whenever required, user can scroll up and look at the previous text.