Unity Adding Random Namspaces in Scripts

Like Title Says Everytime I build My Unity Game I Get Some Random NameSpace Not Found Error from a Random Script like Error Namespace TimeLine Not Found or
Assets\Scripts\BattleSystem\Challange\ChallangeBattle.cs(3,22): error CS0234: The type or namespace name ‘Remoting’ does not exist in the namespace ‘System.Runtime’ (are you missing an assembly reference?)

But None Of Above Name Spaces I Have Added Actually i never used those before. I Can Only Build my game after removing those namespaces.

Is it normal for all…?

Are you saying Unity is modifying your script file on its own?

well i haven’t used those name spaces since i started programming in Unity. But Whenever i Try To build my Game. Some Random Name Spaces gets added in my scripts and i get build error that library related those name spaces not found. To Build My Games i Need To Remove Those Name Spaces Then Click Build Again. But Removing Names Spaces I haven’t added feels annoying to remove each time.

Maybe your default c# script template has some unnecessary stuff in it?

Also, it’s pretty awkward to read your post when you capitalize the first letter of every word. If English isn’t your first language, you just might want to know that it’s not typical.

sry i was making a game where person type like this after spending time in typing like that it became my habit.

and no its not regarding template. its not adding namespace while creating new script only when i am trying to build my game

Can you show an example of a script before and after the namespace is added? What is it adding exactly? A using statement?

Thanks for your reply . But now its start happening randomly so currently i have no backup of example. Currently code is running and building perfectly it just happen some time randomly. i deleted previous project and recreated it from backup in hope for fixing this problem. I will come with scripts next time i face this problem again.

The first thing you should do is actually check the script for the namespace you think was added out of nowhere. Verify the error is legit basically. If it isn’t there, maybe there is an issue with your library folder. Delete it and let Unity recreate it.

Also a lot of times this error is a result of mistype. Especially if you’re used to type on a certain way like you did in the beginning of this thread it is possible that you introduced something you didn’t mean to.

well if i miss typed why it was not giving error in editor mode only in builds…? I am 100% sure it was not typo

This is happening to me too, since upgrading project to 2019.4.1f1. Definitely not just a mistype as its happening consistently with multiple programmers on the project.

Can confirm this too. I get long namespace names that I have never ever used or seen.

1 Like

Just opened up a simple script that I wrote yesterday and using static UnityEngine.GraphicsBuffer; was at the top lol

It’s not Unity, it is the IDE you’re using. By far the worst offender for this is the Rider IDE.

The feature CAN be turned off but it will likely take you a MASSIVE slog through the internet to find where to set it.

Most of the links that come up for “rider ide disable auto using” or whatever you google for this problem will be expired and out of date.

Also, be prepared for the feature to randomly re-enable itself from time to time.

Source: our entire team used Rider in 2018/2019 and we had to deal with this constantly.

The main guard is to use proper industrial grade source control so you can SEE that the IDE is doing this to you and revert it.

I know it is an older post but this just started happening at random to me in Unity 2021.3.2f1 in a project I am working long time on. So it just started happening one day. One thing to note is that I switched from visual studio 2022 to VS code and I have the same problem in both IDEs. Did anybody found a solution.

I had this today. Visual Studio 2022 and Unity 2022.3.8f1. Lots of imports related to SceneManagement and some other pretty random namespaces. I was able to fix it by removing the imports, closing Visual Studio, relaunching Unity, and going to Build Settings → Build → Clean Build…

This sometimes happens to me if I paste code into a script, even if this code doesn’t use these namespaces.