Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Error CS0246: Are you missing a using directive or an assembly reference?

Discussion in 'Editor & General Support' started by NickVas, Jul 11, 2023.

  1. NickVas

    NickVas

    Joined:
    Jul 28, 2017
    Posts:
    9
    Backstory:
    I was trying to implement Unity Push Notifications SDK, messing with analytics and firebase... something went wrong, and I've got this error first:

    Code (CSharp):
    1. Package com.unity.render-pipelines.lightweight@2.0.3-preview has invalid dependencies:
    2. com.unity.render-pipelines.core: Version [2.0.3-preview] is incompatible with the selected version [2.0.0-preview]
    3. One or more packages could not be added to the local file system:
    4. com.unity.render-pipelines.core: Package [com.unity.render-pipelines.core@2.0.0-preview] cannot be found
    Next: I've found on web that to resolve that I can go Help > Reset Packages to defaults
    (I'm working with Plastic SCM - so I relied on it, thinking I can restore everything back anyway) so I pressed on it... and got 200+ errors, like this:

    Code (CSharp):
    1. Assets/_DEV/Scripts/LevelsScripts/LevelController.cs(37,12): error CS0246: The type or namespace name 'TextMeshProUGUI' could not be found (are you missing a using directive or an assembly reference?)
    I've tried to revert my game using version control...but the errors not gone (how can it be?)

    Tried to remove manifest.json and packages-lock.json files, so Unity can rebuild them - didn't help.

    Opened another unity project - there is everything ok.

    I'm still noob with Unity... tried to resolve this by my self, searching web - without a result...
     
  2. NickVas

    NickVas

    Joined:
    Jul 28, 2017
    Posts:
    9
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,951
    At a minimum you need to doublecheck you have TextMeshPro in game.

    Here's more things to check:

    Extra unwanted packages in new projects (collab, testing, rider and other junk):

    https://forum.unity.com/threads/temp-unityengine-testrunner-dll-error.1133938/#post-7287748

    About the fastest way I have found to make a project and avoid all this noise is to create the project, then as soon as you see the files appear, FORCE-STOP (hard-kill) Unity (with the Activity Manager or Task Manager), then go hand-edit the Packages/manifest.json file as outlined in the above post, then reopen Unity.

    Sometimes the package system gets borked from all this unnecessary churn and requires the package cache to be cleared:

    https://stackoverflow.com/questions/53145919/unity3d-package-cache-errors/69779122
     
    NickVas likes this.
  4. NickVas

    NickVas

    Joined:
    Jul 28, 2017
    Posts:
    9
    I've re-imported packages...and problem solved!