Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

AssetDatabase.ImportPackage Callbacks don't work ?

Discussion in 'Extensions & OnGUI' started by baptisteb_unity, Aug 6, 2018.

  1. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    3
    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:
    92
  3. baptisteb_unity

    baptisteb_unity

    Joined:
    Feb 13, 2018
    Posts:
    3
    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:
    3
    Oh btw, the issue tracker is put as fixed but no version is precise.
     
  5. BaptisteB

    BaptisteB

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

    BaptisteB

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

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,016
    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:
    254
    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,016
    If it's not being called then it sounds like a bug. Can you please send a bug report?