Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Getting a namespace definition error whenever i load a script into VS Code?

Discussion in 'Scripting' started by RyanPwn, Dec 8, 2018 at 5:04 PM.

  1. RyanPwn


    Sep 11, 2018
    Hi there, every time I load up a new script it gives me this error

    Code (CSharp):
    1. The namespace '<global namespace>' already contains a definition for 'PlannetGravity' [Assembly-CSharp]
    it seems to not matter what i name it, because a file that was previously working now throws this error. ^

    Here is the code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class PlannetGravity : MonoBehaviour {
    7.     // Use this for initialization
    8.     void Start () {
    10.     }
    12.     // Update is called once per frame
    13.     void Update () {
    15.     }
    16. }
    How should i fix this? Is it a unity error or a VS Code error?

    Thanks <3

    (EDIT: After restarting VS Code, it has a chance to start working. Could it be a problem with omnisharp?
  2. chubbspet


    Feb 18, 2010
    you might have duplicated or renamed the script without the compiler picking it up.