public static void removeTexture(CompositeTexture p_ct) { Texture2D texA = p_ct.getTextureA(); CompositeTextureData.removeTexture(p_ct); string assetPath = AssetDatabase.GetAssetPath(texA); updateAssetUserData(assetPath); AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); }
void OnPostprocessTexture(Texture2D texture) { bool isCompositeTexture = false; try { //id = CompositeTexture.assetToGUID(texture); int instanceID = AssetDatabase.LoadMainAssetAtPath(assetPath).GetInstanceID(); EDebug.Log("OnPostProcessTexture " + instanceID); if (CompositeTextureData.ExistsByInstanceID(instanceID) && CompositeTextureData.getTexture(instanceID).enabled) { EDebug.Log("is an enabled composite texture"); isCompositeTexture = true; ct = CompositeTextureData.getTexture(instanceID); } } catch (System.Exception) { EDebug.Log("exception in texture processor"); } if (!isCompositeTexture) { return; } EDebug.Log("do work"); NormalToRoughness nr = new NormalToRoughness(); ProcessTexture(ct, texture); ct.getTextureA().setReadable(false); // Instead of setting pixels for each mip map levels, you can also // modify only the pixels in the highest mip level. And then simply use // texture.Apply(true); to generate lower mip levels. }