• 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
1
Question by Plattadrug · Sep 23, 2020 at 12:21 PM · slowassetdatabase

Asset database refresh has become very slow

Hey, so my project used to take about 10 seconds to recompile every time I entered the editor from VS and about another 5-10 seconds to enter play mode. Now whenever I save in VS and go back to the editor I get AssetDatabase.Refresh popup shows and takes anywhere from 2-4 minutes and another 1-2 to enter play mode. I have added a few assets from the store to my project but they were all pretty small. Any help with this? Pretty unfeasible to wait up to 5 minutes in-between code changes.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Gera1997 · Oct 10, 2020 at 05:45 PM

EDIT: Permanent solution (apparently) found.

Hey @Plattadrug , I'm having the same problem, I'm afraid I have not found a permanent solution. However I do have a couple solutions that will fix the problem temporarilty, they might be helpfull.

  1. Restart Unity, this fixes the problem most of the time.

  2. If restarting unity doesn't work, go to Assets -> Reimport All. This will also fix the problem but reimporting could take a long time depending on the size of your project.

Sadly, this seem to be temporary fixes, for me its only a matter of time before unity goes back to being slow in AssetDatabase.Refresh.

EDIT: @Plattadrug , I think I found the permanent solution, in my case it seems I had was a problem with Visual Studio, not Unity.

Go to: Preferences -> External Tools -> External Script Editor. And see if you have 2 options to pick Visual Studio, like in this screenshot. One that includes the current installed version between the "[ ]" (I do not know what those are called) make sure you have THAT one selected and not the other.

alt text

My guess is that opening VS as an external tool refreshes a lot of files it shouldn't be recompiling i.e. those that belong to the Unity Engine. I'm not 100% sure this was the causing the problem, but I've not experienced the slow refresh in over a week since I did this.


sin-titulo.png (28.8 kB)
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
0

Answer by atur94 · Nov 27, 2020 at 10:39 AM

Actually i found good hack for the following issue. I've been looking for the answer for the same question until I noticed that AssetDatabase is documented. I disabled it and from time to time I refresh everything manually which takes significientaly less time. For people who try to solve the same problem here is the class which you need to create in order to get rid of this issue. I haven't noticed any cons of this solution YET. Maybe sometimes project files are not refreshed but ctrl+r(Assets -> Refresh) does the job

 #if UNITY_EDITOR 
 // this is important or you want be able to build project because of
 // UnityEditor library
 
 using UnityEditor;
 
 [InitializeOnLoad]
 public class OnUnityLoad
 {
     static OnUnityLoad()
     {
         AssetDatabase.DisallowAutoRefresh();
     }
 }
 #endif
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
1

Answer by reshen817 · Nov 28, 2020 at 02:20 AM

Another workaround is to only refresh assets when you switch to play mode. This will let you quickly switch back and forth between external editors and unity without incurring the refresh penalty, but still get fresh assets when you usually need them (at runtime). You can also use CTRL+r manually to refresh the asset list at need.

  • Disable auto-refresh (Edit > Preferences > Auto Refresh should be unchecked)

  • Follow the advice provided by DireLogomachist in this unity form post and add the following script to your project:

     using UnityEditor;
     [InitializeOnLoadAttribute]
     public static class PlayRefreshEditor {
         static PlayRefreshEditor() {
             EditorApplication.playModeStateChanged += PlayRefresh;
         }
      
         private static void PlayRefresh(PlayModeStateChange state) {
             if(state == PlayModeStateChange.ExitingEditMode) {
                 AssetDatabase.Refresh();
             }
         }
     }
    
    
    
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 atur94 · Dec 14, 2020 at 07:24 AM 0
Share

I didn't know that this option is available through Unity Editor. Thats a nice solution for the following issue

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

136 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

When looping through assetbundle assetdatabase how do you reference a material object 0 Answers

Proper way to refresh asset 0 Answers

How to make a new path register in the AssetDatabase? 2 Answers

Custom assets give Missing (Mono Script) 0 Answers

editor scripting for setting mechanim statemachine layer avatarmask 0 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