Search Unity

Bug Unity Adding Random Namspaces in Scripts

Discussion in 'Editor & General Support' started by Jenifer_Jane, May 30, 2020.

  1. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    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..?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Are you saying Unity is modifying your script file on its own?
     
  3. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    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.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
  5. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    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
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Can you show an example of a script before and after the namespace is added? What is it adding exactly? A using statement?
     
  7. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    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.
     
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.
     
  9. 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.
     
  10. Jenifer_Jane

    Jenifer_Jane

    Joined:
    Jan 24, 2017
    Posts:
    69
    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
     
  11. JWgames

    JWgames

    Joined:
    Jun 29, 2015
    Posts:
    7
    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.
     
  12. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
    Can confirm this too. I get long namespace names that I have never ever used or seen.
     
    SomaRealityGmbH likes this.
  13. Feral_Pug

    Feral_Pug

    Joined:
    Sep 29, 2019
    Posts:
    49
    Just opened up a simple script that I wrote yesterday and
    Code (CSharp):
    1. using static UnityEngine.GraphicsBuffer;
    was at the top lol
     
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    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.