Hello,
I wanted to know if it was possible to convert the “GUILayout. TextField” With that of “InputField” of UI?
I have a code that uses the GUILayout. TextField “or it makes calls to scripts” [System. Serializable] “and the line of the GUILayou do calls to” string “” int “… is it possible to convert the line with the variable” InputField "of the function UI?
Thanks in advance !
SCRIPT : Menu
public class Menu : MonoBehaviour {
public enum MenuEnum {
MainMenu,
}
public MenuEnum currentMenu;
void OnGUI () {
GUILayout.BeginArea(new Rect(0,0,Screen.width, Screen.height));
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
if (currentMenu == MenuEnum .MainMenu) {
GUILayout.Label("Pseudo");
Game.current.Pseudo.Name= GUILayout.TextField(Game.current.Pseudo.Name, 20);
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
SCRIPT : Game
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Game {
public static Game current;
public NamePlayer Pseudo;
public Game () {
Pseudo = new NamePlayer ();
}
}
SCRIPT : NamePlayer
using UnityEngine;
using System.Collections;
[System.Serializable]
public class NamePlayer{
public string Name;
public NamePlayer() {
this.Name= "";
}
}
I made an example scene, to give you a head start. Copy the folder in [111978-exampleuilayout.zip|111978] into the assets folder of a new Unity project, and open the Scene.
Hello!
Thank you for your help!
You have reconstituted the scripts that I send it’s really nice of you to have taken the time to help me convert !!!
I am in to take my head on the recording of the evolution of the player via the “menu”! I’ll look at what you’ve done to me beautiful and see if the code is fit in what I want to try to do!
Thank you so much again I keep you in the juice, if I have to share an example in the form of drafts with all the scripts on the “serialization” of the recording of the “Menu” via the evolution of the player!
My head is going to explode… I can’t find a solution…
So I try the example you give me but unfortunately it does not work… In fact I wanted to convert the script GUI into UI and power save a progress by user with diferent users
But currently I’m still looking and digging in my head to find out how I can do… I would infact if two players want to play on the same game… How do I make sure that each player has his own backup through their nickname back up from the beginning of the game? Is there a way to save multiple users and when loading,display the saved users and choose what to load?
Example:
User names > “John”> is 500 points, 100% life, level 5
User names > “michael”> is 2500 point, 100% life, Level 18
Thanks in advance if there is anyone who can help me!
public int numUsers;
public string[] usersNumber;
public void CreateNewsUserNames()
{
usersNumber = new String[numUsers+=1];
}
I use script to create several “Text” for creating multiple backups of each different player. Except that the variable is empty there is no “Prefab” and I do not know how I can write this. And in addition I can not find a solution for Creates different nicks and that each player with their name matches their record of their game… Thanks in advance