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

AssetDatabase.Refresh

Discussion in 'Asset Database' started by Crossway, Sep 22, 2019.

  1. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Hi. I need to refresh Unity Editor to see the changes I make to asset folders immediately so I wrote below code and it works but Unity editor become too slow and it uses a lot of CPU resources.

    Code (CSharp):
    1.  using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. [InitializeOnLoad]
    7. public class UpdateEditor : Editor
    8. {
    9.      private float waitTime = 3f;
    10.      static UpdateEditor()
    11.      {
    12.          EditorApplication.update += Start;
    13.      
    14.      }
    15.      static void Start()
    16.      {
    17.          AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    18.      }
    19. }