Need help

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



public class AdventureGame : MonoBehaviour
{

    [SerializeField] Text textComponent;
    [SerializeField] State StartingState;

    int[] oddNumbers = { 1, 3, 5, 7, 9 };

    State state;

    // Start is called before the first frame update
    void Start()
    {
        state = StartingState;
        textComponent.text = state.GetStateStory();
        Debug.Log(oddNumbers[3]);
    }

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

    }
}

it shows error
CS0246 The type or namespace name ‘MonoBehaviour’ could not be found
CS0246 The type or namespace name ‘SerializeField’ could not be found
CS0103 The name ‘Debug’ doesn’t exist in the current context.

It could be VS issue, try restarting VS or right click>reimport on script in Unity. It that doesn’t help, try deleting Library folder and reopen project in Unity.

Also your post needs proper title. Every single person on Earth needs help for something.

1 Like

will give, sorry first time here don’t really know how to use it.

Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

If this is just Visual Studio acting up (extremely common), then this might help:

This may help you with intellisense and possibly other Visual Studio integration problems:

Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.

https://discussions.unity.com/t/778503

Also, try update the VSCode package inside of Unity: Window → Package Manager → Search for Visual Studio Code Editor → Press the Update button

Also, this: https://discussions.unity.com/t/805330/7