using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class save_names : MonoBehaviour {
public static string userName;
public GameObject inputField;
public void UserName()
{
userName = inputField.GetComponent<InputField>().text;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class display_inputs : MonoBehaviour {
private Text nautName;
void Start ()
{
nautName = gameObject.GetComponent<Text>();
save_names.userName = nautName.text;
}
I put the save_names script on a empty game object and dragged the input field into the variable. The other script I put on the Text field, which is where the name should appear that was typed in.
Not entirely sure if I have set it up because it doesn’t seem to change the name when I go into the game scene.
Here is the script accessing the static variable in the game scene (based off what you have said above):
public class display_inputs : MonoBehaviour {
public Text nautName;
public void Awake ()
{
string nautName = save_names.save_Names.userName;
}
}