Search Unity

OnPostprocessMaterial never called.

Discussion in 'Immediate Mode GUI (IMGUI)' started by Deleted User, Feb 7, 2018.

  1. Deleted User

    Deleted User

    Guest

    I am trying to get a callback when a material is changed (specifically when the _MainTex-reference is changed), but the OnPostprocessMaterial() function is never getting called.

    public class MyAssetPostprocessor : UnityEditor.AssetPostprocessor {
    void OnPostprocessMaterial(Material material) {
    Debug.Log ("Postprocessing material: " + (material ? material.name : "null"));
    }
    }


    Having this problem in 2017.1.0p4 and 2017.3.1f1. What's wrong?
     
  2. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
  3. Deleted User

    Deleted User

    Guest

    Neither making changes to a material nor importing it via drag and drop or even explicitly through Context Menu -> Import New Asset appears to call the function. Implementation of the constructor reveals that it is getting called at least when creating or importing materials though.

    Even if it worked I guess this is only intended for import post processing, not for reacting to changes.
     
  4. Desumika

    Desumika

    Joined:
    Sep 21, 2017
    Posts:
    2
    The last line at document: This method is only called by the ModelImporter.