Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Telling Unity to not compile a script

Discussion in 'Scripting' started by HarvesteR, Apr 25, 2011.

  1. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Hello again,

    New question: Is it possible to tell unity to NOT compile a script?

    I have a number of deprecated scripts in my project, which I am too much of an obsessive hoarder to delete... Now, Unity is halting at compiler errors on those scripts (since they don't really work under the current setup), and won't keep on compiling the new good ones...

    Since I'm a compusilve hoarder, I don't feel like deleting those scripts... It would be a lot better to just mark them as 'Do Not Compile' for unity...

    I'm merely curious about this... I could just move them to another folder... But it would be nice to know if Unity provides a more convenient way...

    Cheers
     
  2. Simes

    Simes

    Joined:
    Apr 25, 2011
    Posts:
    3
    I haven't seen an option for that (just checked and there isn't one in preferences), best bet is to move them to another folder that isn't in your current project folder. Then Unity won't auto compile the depreceated scripts and refuse to run until you remove or fix the errors.
     
  3. jgodfrey

    jgodfrey

    Joined:
    Nov 14, 2009
    Posts:
    564
    While I don't know for sure as I'm somewhat new to Unity myself, I'd guess that it'll only attempt to compile scripts with an appropriate extension (.cs, .js, etc). How about just renaming them with a (slightly) modified extension?

    Jeff
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    the only option to not compile a script is not putting it into the assets folder riht from the start or giving it a .txt (or similar) extension so its no longer code.
     
  5. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,249
    or just do a multiline comment to comment out the whole script when you aren't using it.
     
    Abre-ham-kar likes this.
  6. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Hmm, good ideas those :)

    I just ended up moving them to another folder... Unity didn't like that at first, and complained with some null asset errors, but after a restart all is well.

    Today there was a MASSIVE rewrite of a great part of my game code... some changes were so drastic I was afraid to overwrite the original files... thankfully, everything worked, and we're good to keep on building without having to go through a truckload of bugs due to needless complexity.

    Thanks for the tips! :)

    Cheers
     
  7. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,249
    I always save a backups of my projects which i keep to avoid losing something i wanted.
     
  8. ElectricMonk

    ElectricMonk

    Joined:
    Sep 3, 2014
    Posts:
    5
    You can rename the file to .txt, you have to do it outside of unity itself but it keeps it from compiling. Sometimes comment blocks are a pain or you don't want a broken script laying around.
     
  9. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Scripts placed in the WebplayerTemplates folder are ignored.
     
  10. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Use a subversion or git server. I tag my project anytime I do something major. I can delete everything I want freely and instantly be able to go back and find code from before my refactor.
     
  11. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,522
    Oh man, what Garth Smith said a hundred times over! I cannot work without source control, and since there is tons of really good source control out there for free, there is NO reason not to use it.

    Use source control (my favorite is Mercurial but git is great too, and so is SVN), and whenever you get ANYTHING even slightly working, check it in with a note: "Got the spaceship moving." and move on.

    That way you can freely and fearlessly try new things, revert if they don't work out, or delete code and assets you don't need when they no longer matter, and ALL of it is tracked and stored forever in the repository.

    Seriously, just go do it. You are crippling yourself by not using source control.

    Go now. Go. Bitbucket has free repositories, so does Github. There are free clients for all platforms. Go. Do it! :)

    Kurt
     
    AlejoLab and GarthSmith like this.