Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
8
Question by Brian 4 · Jul 30, 2010 at 05:29 PM · buildassetsresources

Can I exclude specific assets in Assets/Resources from the build?

I have some files in the Assets/Resources directory that are needed in the editor for debugging, but I would like to exlude at build time. Is there a way I can script the build process to exclude specific assets?

Comment
Add comment · Show 1
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 hexagonius · Nov 06, 2019 at 09:53 AM 0
Share

@$$anonymous$$ 4 Bunny83's answer is the best and only correct one, if it's not too much trouble, please switch the "Best Answer" flag over to his answer.

6 Replies

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

Answer by qJake · Jul 30, 2010 at 06:00 PM

You may or may not be able to exclude files (I don't think you can), but if you've written your own Debug class, you can stop it from working outside Unity by using a check:

if(Application.isEditor)

Just use that condition everywhere in your class to stop it from running outside of the editor, on client machines.

Comment
Add comment · Show 3 · 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 Brian 4 · Aug 04, 2010 at 04:20 PM 3
Share

I appreciate the info on excluding code from running outside the editor, but in this case, I want to exclude specific art assets from the build.

avatar image fireDude67 · Jan 23, 2011 at 06:34 PM 0
Share

$$anonymous$$aybe if you placed it in Assets/Editor it would not get put in a build?

avatar image MorphVGX · Jul 02, 2018 at 04:35 PM 1
Share

Why is this the best answer? It is not at all.

avatar image
17

Answer by titin_lc · Apr 25, 2013 at 02:43 PM

Yes, you can. You need to build by script, but first move out the resources you want from the "Resources" folder. And after building, restore those files. Try the following:

 // Move assets from Resources
 UnityEngine.Debug.Log(AssetDatabase.MoveAsset("Assets/Resources/blablabla", "Assets/blablabla"));
     
 // Compile on work folder
 BuildPipeline.BuildPlayer(...);
 
 // Restore assets to Resources
 UnityEngine.Debug.Log(AssetDatabase.MoveAsset("Assets/blablabla", "Assets/Resources/blablabla"));
 
 // I don't know if this is necessary
 AssetDatabase.DeleteAsset("Assets/blablabla");
 
 // Refresh database
 AssetDatabase.Refresh();

 
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 Bunny83 · Apr 25, 2013 at 03:03 PM 0
Share

That's a bit of an overkill but of course works if you have Unity pro ;)

I've posted an answer which makes your life a bit easier ;)

avatar image ShawnFlanagan · Dec 04, 2014 at 10:29 PM 0
Share

This solution was exactly what I needed. Thanks!

avatar image furic · Mar 13, 2015 at 04:32 AM 0
Share

looking for this to exclude asset bundles in resources folder, thanks heaps...

avatar image sosh · Nov 06, 2017 at 01:04 PM 0
Share

@Bunny83 @titin_lc What about this requires Unity Pro? Thanks.

avatar image Bunny83 sosh · Nov 06, 2017 at 03:59 PM 1
Share

This is obsolete since Unity 5.x where they basically removed almost all differences between the personal and plus / pro versions. Now Unity has exact the same features regardless of the license. The only things that remain pro / plus only are:

  • The dark pro editor skin

  • Splash Screen removal

For anyone reading this in the future, keep in $$anonymous$$d that things can change over time.

avatar image
7

Answer by Waz · Feb 10, 2011 at 01:05 AM

Resources are always included, so if you're trying to save space in output, you will HAVE to move them out of a Resources directory.

However, any GameObject in the hierarchy that is tagged with "EditorOnly" will not be included (nor will its non-Resource dependencies), and you never NEED to use Resources (you can always just reference the asset as a parameter to the GameObject).

So, for example, have a "DebugConsole" object in your scene, tag it with EditorOnly, and have its assets as variables that you configure. Obviously if this GameObject is needed in every scene, you'll want to make it a Prefab and copy it to every one.

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
6

Answer by Bunny83 · Apr 25, 2013 at 03:01 PM

Just in case you didn't know this one:

EditorGUIUtility.Load

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
3

Answer by rodger_hu · Jan 23, 2014 at 03:50 AM

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

So, Move all you don't want compiled resource to WebPlayerTemplates folder. may be you need create WebPlayerTemplates folder first. sorry by my bade english :)

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
  • 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

8 People are following this question.

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

Related Questions

Load resources the scene depend on but not in "Resources" folder 1 Answer

How To Refresh Resources Folder in Build? 1 Answer

Everything on Resources folder goes to the build? 1 Answer

Distribute terrain in zones 3 Answers

Prefabs are instantiated in editor but not in executable 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