0

I am making a 2D platformer where I want the users inputted name to hover over there character. This is what the menu screen looks like

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class set_usernames : MonoBehaviour {

    public InputField name;
    public InputField second_name;

    private string Bader_input_name;
    private string Dwarf_input_name;

    public void updatename(string name){

    }
    public void setget()
    {
        //Debug.Log (name.text);
        Bader_input_name = name.text;
        Dwarf_input_name = second_name.text;

        //Application.loadedLevel("game");
        Debug.Log ("name was " + Bader_input_name);
        Debug.Log ("name was " + Dwarf_input_name);
        SceneManager.LoadScene ("map_select");
    }
}

This is the error message I get

spark
  • 25
  • 1
  • 6

1 Answers1

0

Basically what that means is that you are trying to access an object that's not instantiated. I have no idea how are you trying to access the input but the easiest way is to make two public inputs in your UIController drag and drop them in Unity and access the Text property of input objects like so: myInput.Text.

Ivan Kaloyanov
  • 1,737
  • 6
  • 14
  • 22