Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Pass an input from InputField upon submit returns null upon second submit

Discussion in 'Immediate Mode GUI (IMGUI)' started by inJUST, Nov 19, 2023.

  1. inJUST

    inJUST

    Joined:
    Jul 23, 2015
    Posts:
    5
    So I'm trying to pass an input from InputField into my CheckString function however it is returning null. For some reason my input = s goes null once I hit enter... any thoughts?

    Here is the setup:
    Code (CSharp):
    1. public void ReadString(string s)
    2. {
    3.     input = s;
    4.  
    5.     // This checks to see if the string written is the same being read
    6.     CheckString(currentWord, input);
    7. }
    8. private void CheckString(string read, string write) { Debug.Log("read: " + read); Debug.Log("write: " + write); if (read == write ) { Debug.Log("Read equals write"); } }
    9.  
     
  2. inJUST

    inJUST

    Joined:
    Jul 23, 2015
    Posts:
    5
    Nevermind the issue was that I was redeclaring the string variable on Start.