SOLVED : How to grab the text from input fields with the new gui!

SOLVED - Rookie mistake -
Solution : Cannot initialize outside, needed to put it inside a function or void :stuck_out_tongue:

Havent worked much with the new GUI, since i’ve always been a fan of NGUI, it just seems more finished!

However, trying to wrap my head around this “new” stock GUI.
so i got a input field on a screen and i prefer to drop my objects into the scripts via Public gameobjects.

So for examples

using UnityEngine;
using UnityEngine.UI;
using System.Text.RegularExpressions;
using System.Collections;

public class guiControl : MonoBehaviour {

    [Header("GUI Input")]
    public GameObject GNavn;  // <---- Drag the entire inputfield to this container, might have to only drag the text component.

    // InputField GNavn = GNavn.GetComponent<InputField>();
    // string Pilotnavn = GNavn.GetComponent(InputField);
    // string Pilotnavn = GNavn.InputField(Text);

   // Text Pilotnavn = GNavn.GetComponent<Text>;  <---  Text field as gameobject

void start() {
Debug.log(Pilotnavn);
}

a few different tests as you can see :wink:

Any suggestions :smile:

Ups… Just ignore me messing around :wink: