OnUserInput() not putting messages in the console

Running into an issue where the Console Messages in UNITY are not showing up.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using UnityEngine;

public class Hacker : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
ShowMainMenu(“Hello Nick”);

    void ShowMainMenu(string greeting)
    {
        Terminal.ClearScreen();
        Terminal.WriteLine(greeting);
        Terminal.WriteLine("");
        Terminal.WriteLine("Pick your level of Felony:");
        Terminal.WriteLine("");
        Terminal.WriteLine("Press 1 for The Public Library");
        Terminal.WriteLine("Press 2 for The City Airport");
        Terminal.WriteLine("Press 3 for The City Police Dept.");
        Terminal.WriteLine("");
        Terminal.WriteLine("Please enter your selection: ");

    }


}
// Update is called once per frame
void Update()
{

    void OnUserInput(string input)
    {
        print(input == "1");
    }

}

}

I have tried recreating the project, I have hit enter, I have tried Debug.Log(input == “1”);
Nothing is writing to the unity console. Any help would be appreciated

Have you tried calculating the result first then pass it into Print?

bool Test = input == “1”;
Print(Test);

Also correct me if I’m wrong, but I think OnUserInput is a message provided by the terminal so it doesn’t have to be nested in the Update method, try removing it from Update.

Hope this helps!

Okay so what’s going on is you’ve defined a method inside a method, so it can only be accessed within Update and since you never called it, nothing happens. I’m pretty sure if you just remove it from the Update the terminal will be able to Invoke it and everything should start working!

Thank you. That helped. What’s odd, is I tried it outside of update before and all I had ever gotten were errors or it didn’t work. But I appreciate it. Thanks again.

No problem!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms