Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
12
Question by robinking · Jul 01, 2011 at 02:18 PM · assetscompiling

Can I put scripts somewhere so they don't compile?

At some points I need to set a script aside and not include it in the compile, as it contains too many compile errors and I know I will come back to it, but in the meantime I'll work on others. Regardless of whether or not that in itself is a good idea, is there a place inside 'Assets' I can move the script to, where it will not compile? Or a folder I can stipulate as 'do not compile'? At the moment I'm commenting out the entire script so I can compile without it, or I suppose I could move it in the Finder, but I'd rather move it within the Unity IDE...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

7 Replies

· Add your reply
  • Sort: 
avatar image
15
Best Answer

Answer by jashan · Dec 14, 2012 at 08:33 PM

I've just ran into a situation where I needed that, and while dragging files out of the Assets folder certainly is an option if you're not using version control (Asset Server, Subversion or anything like that), when you do use version control, that's not an option.

The reason I needed this was for keeping HTML-JavaScript files in the project, and there's a really good solution that you also find in the documentation:

Overview: Script compilation (Advanced)

So here's the trick (it's a bit down the page):

Additionally, any scripts in a folder called WebPlayerTemplates will not be compiled at all.

So, simply create a folder WebPlayerTemplates (below your Assets folder), and you have an area which still is under version control but is not touched by the compiler. Awesome :-)

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robinking · Dec 15, 2012 at 12:33 AM 0
Share

Brilliant! Thanks Jashan.

avatar image jashan · Dec 15, 2012 at 10:41 AM 0
Share

You're very welcome! And thank you for accepting this as answer, Robin!!!

avatar image Bunny83 · Dec 15, 2012 at 04:34 PM 0
Share

I remember we had that question already several times. Too bad we can't group similar questions...

avatar image madcalf · Feb 26, 2013 at 02:29 AM 0
Share

Just a note for anyone having trouble using the WebPlayerTemplates folder for this: It apparently has to be in the root of your Assets folder. It can't be in any sub folders, or else the scripts inside still get compiled. At least that's what was happening for me. (Unity 3.5).

avatar image ratneshpatel · Jul 12, 2019 at 03:56 PM 0
Share

This works even in 2018.3

avatar image
12

Answer by testure · Jul 01, 2011 at 03:15 PM

Personally, I just use a conditional directive..

 #if false
 
 class foo : MonoBehaviour
 {
     // rest of your code.
 }
 
 #endif
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robinking · Jul 01, 2011 at 03:23 PM 0
Share

Ah, pretty good... thanks.

avatar image
1

Answer by flaviusxvii · Jul 01, 2011 at 03:05 PM

I've always just dragged them out of the Assets folder. What's wrong with that?

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robinking · Jul 01, 2011 at 03:23 PM 0
Share

Fair enough! Sounds easy, I was just being too lazy to switch to the Finder :)

avatar image testure · Jul 01, 2011 at 03:30 PM 0
Share

although, once you drag it out of your assets folder you're not able to access it from within Unity. If you wrap a conditional directive around your code, it will stay in the assets folder so you can access it from within Unity, but it still won't compile.

I guess it all depends on what you need to do

avatar image robinking · Jul 01, 2011 at 03:39 PM 0
Share

Just shove it out of the way while I work on something else... So I just drag it back in when I want to come back to it. So your way is probably the simpler way for me for now.

avatar image jashan · Dec 14, 2012 at 08:35 PM 0
Share

There's two problems with this approach:

a) you can't do it within Unity b) if you're using version control, you lose the history

See new answer (below) for a better approach: There actually is such a folder, and it's called WebPlayerTemplates

avatar image
-1

Answer by yoyo · Jul 29, 2014 at 05:29 PM

Some good answers here already, here is another option to consider.

For my projects I use external version control, not Unity's built-in version control. I always set up my project structure so that the unity folder is a nested folder, not the top-level folder. This lets me have other folders in the project that are not visible to Unity. This layout would let you move non-compiled source files out of the Unity Assets folder without moving them out of your project.

Note that if your code is compiled in Visual Studio into a DLL then the source code itself is not under the Assets folder. In your Visual Studio solution you can either remove a source file from the project (but not delete it from the hard drive) or right-click on the file, view properties, and change the build action from Compile to Content -- this keeps it in the project but does not compile it.

Here's my typical top-level structure:

 /MyProject
     /unity
         /Assets
         /Library (excluded from version control)
         /ProjectSettings
     /source (source code gets compiled into DLL's)
     /<more> (whatever other folders you want)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
-2

Answer by Booniac · Jan 25, 2013 at 10:56 AM

There is now an editor extension for this, available here.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ziplock9000 · Dec 21, 2020 at 12:01 PM 1
Share

Don't use links, they go dead. Copy the text or at least a synopsis. Standard Q&A stuff

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I tell what's happening during Compile? It's taking way too long, and doing too many things. 0 Answers

Wait until scripts compile 1 Answer

Does "Pixels to Units" on importing assets affect performance? 0 Answers

How can I allow the device Camera to insert face on actor? 0 Answers

How do I not use a script? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges