Search Unity

AssetDatabase.ImportPackage Callbacks don't work ?

Discussion in 'Immediate Mode GUI (IMGUI)' started by baptisteb_unity, Aug 6, 2018.

  1. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    4
    Hello !

    I'm making a tool where I have to import a custom package from Github, and I need a call back when it's completed in editor.

    For that I use as recommend by the doc the AssetDatabase.ImportPackage callback, more precisely AssetDatabase.importPackageCompleted.

    Here is the function where I declare the callbacks:

    Code (CSharp):
    1. void Download()
    2. {
    3. AssetDatabase.importPackageCompleted += ImportCompleted;
    4.                             AssetDatabase.importPackageCancelled += ImportCancelled;
    5.                             AssetDatabase.importPackageFailed += ImportCallBackFailed;
    6.                             AssetDatabase.importPackageStarted += ImportStarted;
    7.  
    8. AssetDatabase.ImportPackage(path, true);
    9.  
    10. }
    11.  
    12.  
    And here the functions called by the callbacks:

    Code (CSharp):
    1.  static void ImportCompleted(string packageName)
    2.         {
    3.             Debug.Log ("Completed " + packageName);
    4.             AssetDatabase.importPackageCompleted -= ImportCompleted;
    5.         }
    6.        
    7.         static void ImportCancelled(string packageName)
    8.         {
    9.             Debug.Log ("Cancelled " + packageName);
    10.             AssetDatabase.importPackageCancelled -= ImportCancelled;
    11.         }
    12.        
    13.         static void ImportCallBackFailed(string packageName, string _error)
    14.         {
    15.             Debug.Log ("Failed " + packageName);
    16.             AssetDatabase.importPackageFailed -= ImportCallBackFailed;
    17.         }
    18.        
    19.         static void ImportStarted(string packageName)
    20.         {
    21.             Debug.Log ("Started " + packageName);
    22.             AssetDatabase.importPackageStarted -= ImportStarted;
    23.         }
    The only callback that works is the ImportStarted one.
    Any idea?
     
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    99
  3. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    4
    Hello !
    I try to put an AssetDatabase.Refresh (before and after by the way ^^) but it doesn't work.
     
  4. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    4
    Oh btw, the issue tracker is put as fixed but no version is precise.
     
  5. BaptisteB

    BaptisteB

    Joined:
    Mar 11, 2015
    Posts:
    12
  6. BaptisteB

    BaptisteB

    Joined:
    Mar 11, 2015
    Posts:
    12
    Someone?
     
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,364
    It doesn't say fixed. It says by design which means that's how it's supposed to work.

     
  8. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    275
    The AssetDatabase.importPackageCancelled does not reimport or recompile and it's not being called. Is there a specific way to receive those calls? @karl_jones
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,364
    If it's not being called then it sounds like a bug. Can you please send a bug report?
     
  10. BaptisteB

    BaptisteB

    Joined:
    Mar 11, 2015
    Posts:
    12
    Neither the AssetDatabase.importPackageCompleted and AssetDatabase.importCallBackFailed.
    That was part of the original question. Or maybe there is something I don't understand...

    @karl_jones do we need to post three bug report or just 1 ?
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,364
    One bug report is fine.
     
  12. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    4
    @Martin_Gonzalez Did you send a bug report? If yes, could you share a link to the issue tracker?
     
  13. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    275
  14. BaptisteB

    BaptisteB

    Joined:
    Mar 11, 2015
    Posts:
    12
    Did you manage to make the other callbacks (Completed, Started, Failed) work? @Martin_Gonzalez
     
  15. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    275
    I didn't use other evenst, I just wanted that one because my idea was to delete the file after import is completed.