Hi, something seems to be wrong with the code, can you please help me out here:
Welcome to the community
Your code seems fine? What is the issue? Do you get any errors in Unity? Anything else that should run but is not? If you get any errors in Unity please take a screenshot of them.
Just a tip: Try to provide as much information as possible, it helps us which in turn helps you
Hi Michael! Thank you so much for your reply!
And the error that I get within Unity Console is as follows, am I missing something ?
Could you paste your whole code, inlcuding the import statements?
Sure! Here it is:
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Activation;
using UnityEngine;
public class Hacker : MonoBehaviour
{
int level;
enum Screen { MainMenu, Password, Win};
Screen currentScreen = Screen.MainMenu();
// Start is called before the first frame update
void Start()
{
ShowMainMenu();
}
void ShowMainMenu()
{
Terminal.ClearScreen();
Terminal.WriteLine("Welcome to the gaming terminal!");
Terminal.WriteLine(" ");
Terminal.WriteLine("Choose Level: ");
Terminal.WriteLine("Press 1 for Easy");
Terminal.WriteLine("Press 2 for Medium");
Terminal.WriteLine("Press 3 for Hard");
Terminal.WriteLine("Enter your selection: ");
}
void OnUserInput(string input)
{
if (input == "menu")
{
ShowMainMenu();
}
else if (input == "1")
{
level = 1;
StartGame();
}
else if (input == "2")
{
level = 2;
StartGame();
}
else if (input == "3")
{
level = 3;
StartGame();
}
else
{
Terminal.WriteLine("Please select 1, 2 or 3!");
}
}
void StartGame()
{
currentScreen = Screen.Password();
Terminal.WriteLine("You have chosen level " + level);
Terminal.WriteLine("Please provide a password");
}
}
I think errors like these are well known issues of Unity. Try commenting out this line:
using System.Runtime.Remoting.Activation;
and see if you have any issues. Otherwise, try restarting Unity.
Hi, thank you!. Commenting it out seemed to have solved the first issue. (one with Remoting) The other error it shows now is that MainMenu cannot be used like a method. Can you please see what the issue is ? I am following the same steps as in the tutorial.
Hi again, it worked now!! I just had to eliminate the brackets it seems!! And sorry for the trouble. Thanks again and have a nice day!
You are welcome, glad you solved the problem! Have a nice day too