How can I fix a normalmap procedurally generated?

Hi, I have procedurally generated a normalmap taking a texture as a base, but this is what happens when I asign it to the material:

The light is all wrong, specially in the low right part of the surface.
I found that if I export the normalmap file and then import it through the editor
Unity tells me that “This texture is not marked as a normal map”, and if I click the “Fix Now” button the problem goes away but since I want the normalmap
to be generated via script I can’t use this option of course.

How can I tell Unity that this is a normalmap with C#?

I would love to know the solution to this problem too

I know this is an old thread, but stumbled upon it during search for my own issue. The solution is to change the TextureImporter textureType to normalMap.