Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

need help in text box

Discussion in 'Scripting' started by ahmed513, May 15, 2015.

  1. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
    iam creating a fps multiplayer game and need help how to make a text box that appear on the first time player login after creating the account and show enter your nick name after the player enter the name and click ok it store it on the database and never appear again that textbox
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    What sort of database are you talking about, do you have one in mind?
    A quick solution would be to store the players name using PlayerPrefs.
    Code (csharp):
    1.  
    2. if( !PlayerPrefs.HasKey( "player-name" ) )
    3. {
    4.     // Show the enter your name GUI  
    5. }
    6. ..........
    7. // To assign the name
    8. PlayerPrefs.SetString( "player-name", "player1" );
    9.  
    Take a look at the UI tutorials for creating your text box, you will want to use an Input field.
    http://unity3d.com/learn/tutorials/modules/beginner/ui
     
  3. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
    but how to make it save inside a sqlite database
     
  4. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
    but how to make it save inside a sqlite database
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
  6. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Well you would need to check your db to see if a value has been saved for your player, if it has then don't show the text box. You could use the PlayerPrefs to store a flag to indicate this so you don't have to check the db each time.
     
  8. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
    but player prefs no portable so i can,t use it in another client
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    You will need to make a query to your db then at the start.
     
  10. ahmed513

    ahmed513

    Joined:
    Jul 22, 2014
    Posts:
    32
    I thought that this will be better to make a query to check if it empty or no