Auto 9 slice sprite generator on Unity.
Create Auto9SliceTester. Assets > Create > Auto 9Slice > Tester
Click `Run` to automatically slice the images in the same directory.
Add it to your EditorScript so that it will be executed at your desired timing.
var slicedTexture = Auto9Slicer.Slicer.Slice(texture, SliceOptions.Default);
textureImporter.spriteBorder = slicedTexture.Border.ToVector4();
File.WriteAllBytes(filePath, slicedTexture.Texture.EncodeToPNG());