Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Event at Asset Creation

Discussion in 'Editor & General Support' started by DaCookie, Jun 28, 2016.

  1. DaCookie

    DaCookie

    Joined:
    Nov 4, 2014
    Posts:
    44
    Hi everyone.

    My question is simple : does a callback in UnityEditorInternal (I suppose) called when an asset is created exists ?

    Thanks for any answer :)

    EDIT : Another question, is there a paradise where the UnityEditorInternal or UnityEngineInternal assemblies are documented ?
     
    Last edited: Jun 28, 2016
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    What's in the UnityEditor section of the manual is what you get. It takes some digging and google-fu, but you can find what you're looking for there.

    Here's the editor class that handles assets: https://docs.unity3d.com/ScriptReference/AssetPostprocessor.html
    Here's an example function you want to override for importing textures: https://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessTexture.html

    Be careful! if you have errors in import code, your assets will not import correctly! If this happens, fix/remove your import code then reimport the asset.
     
  3. DaCookie

    DaCookie

    Joined:
    Nov 4, 2014
    Posts:
    44
    Thanks a lot.

    For my tool, I use UnityEditor.AssetModificationProcessor, not AssetProcessor. By using OnWillCreateAsset(), I can know when an asset is imported in the project, even if it's a script :)
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    praschl likes this.