How to Display Text from InputField and Save User name in Unity
Вставка
- Опубліковано 6 кві 2021
- In This video you will learn How to Display Text from InputField and Save User name in Unity 3d.
This tutorial will teach you step by step how to Display Text from InputField and Save User name from script c#.
🔔 Subscribe for More Tutorials: If you like what I'm doing, don't forget to like, share, and subscribe! let me know what do you think about this video in comments.
🤝 Connect with Me:
Website: grafikgames.com
Instagram: / grafikgames
Patreon: / grafikgames
Other videos that will teach you Untiy:
➡️ How to create Toggle button in Unity 3d
• Unity Toggle : How To ...
➡️ How to Update UI color from script in Unity 3D
• Unity Change Color : H...
➡️ How to make Score in Unity 3D
• Unity Score System : H...
Thank you very much. It worked perfectly
How do i do for the input to receive also paragraphs?
How can we save list of names in playerprefs?
Thank you!!!!!!!!!!
You are welcome
thanks
*Thanks!*
Welcome
MTGK abi
thank you
With pleasure thanks for your feedback
'PlayerPrefs' does not contain a definition for 'Getstring'
Is there a method where you can enter your name, and the name showing on the screen in a other sceene
//Add a text in the other scene and assign a tag to it
// Create a new script.
//Add new Empty Gameobject to the new scene and assign this script to it
// play and text will be displayed when you open scene.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Update_text : MonoBehaviour
{
private Text obj_text;
// Start is called before the first frame update
void Start()
{
obj_text = GameObject.FindGameObjectWithTag("text").GetComponent();
obj_text.text = PlayerPrefs.GetString("user_name");
}
}
@@Grafikgames 2 months late but you coulkd have a public refrence to the name in a scripts
what is the "PlayerPrefs"?? Is it a built-in function??
The Player Prefs class in Unity is used to save small amounts of data from your game to disk, which allows you to store and recall single string, integer and float values between gameplay sessions. This can be extremely useful for saving and loading basic sets of data, such as option settings or simplified game saves.
so how do I transfer the value I got from the first scene to the second scene
Use PlayerPrefs, SetString, and GetString call it in the start methode.
@@Grafikgames I assigned the text in the 2nd training as an asset, then I joined the first training, it worked, is it a problem?
any scr i dont made it
@@Grafikgames do you have a dc server fls l need your help :(
Hi, do you know how i can add another text but the old text should be saved?
PlayerPrefs only save one value, if u add another text , you will remove the previous one and it will be updated with the new text
@@Grafikgames and how can i make it that that the old text wouldnt be remmoved?
You can create an Input field next to text inputfield.
You can put text that you want , and in the new input field create string '' YourNewText ''
So when you click ok , the new text will be save in the new inputfield variable and you can call it everytime u want , maybe u can create a load methode which will load any text you want
@@Grafikgames and how can i make it endless, because i am making a game on one device and how can i make it endless so that as many players as the user wants can join
worked when beggining of the code looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Linq;
using TMPro;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class DisplayText : MonoBehaviour
{
[SerializeField] TextMeshProUGUI obj_text;
[SerializeField] TextMeshProUGUI display;
and its not enought, you cant grap InputFile object, you need to grab object named Text that is inside InputFile object tree.
it's because you are using TMP
@@Grafikgames there is only tmp in current unity i think
There is also UI text
Savior
Hi, I've done it all, but I can't drag and drop it to the objtest and displaytext in displaytext, I wonder why
Did you make public text your script ?
@@Grafikgames yeah dude
Did you fix it ?
@@Grafikgames no l did'nt
Explain exactly.. how couldn't you drag the text?
Make a package
does dis work on mobile webgl
Yes , in Unity then build the game for mobile.
@@Grafikgames just for clarification, its webgl for website typing via mobile, not android apk right? so i can type a text in mobile web
Many errors
Did you use same steps ? Same script ?
feel free to provide us your script.
@@Grafikgames plz give me script
@@shershaahofficial2954 i will paste the script soon in the video description..
@@Grafikgames ok video link