Search Unity

  1. Unity 2018.3 is now released.
    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. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    93
  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:
    10
  6. BaptisteB

    BaptisteB

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

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,099
    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:
    259
    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,099
    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:
    10
    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,099
    One bug report is fine.