Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Resolved Update ProjectFolderWindow in Editor from code after adding Files via script

Discussion in 'Testing & Automation' started by Mechandrius, Jun 27, 2019.

  1. Mechandrius

    Mechandrius

    Joined:
    Aug 15, 2015
    Posts:
    4
    Hello Fellow Devs

    Through a script I am creating some folders and images inside the SteamingAssets folder of my project. But the new folders/files are not showing when I click on the ProjectWindow in the Editor. It takes some time and reloading to import/show them.

    Is there a way to trigger this import/reimport manually at the end of the script, so the new files are visible right away (after a short import progress bar)?

    Thanks in advance, Mech
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,283
    liortal likes this.
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,257
    As @Baste said, that should do the trick.

    A small optimization trick is to wrap the code that creates new assets in AssetDatabase.StartAssetEditing() and AssetDatabase.StopAssetEditing() calls.

    This makes sure that the new assets are being imported once as a batch, instead of one by one whenever each of them is created. For our uses it makes things much faster.
     
    Stormy102 likes this.