How to execute script in scene on build before static batch?

Ok, title is pretty long but I really need to do this thing…

I want this. Every time I build player for any platform, I want scripts to get executed before static batch in scene (I want to modify/optimize static meshes).

That is! Does anyone has any idea, how to do this?

If you have Unity Pro: you can fully script and automate the build pipeline, at which point you can do whatever you want.

Otherwise: you can’t script the build process, but you can create a MenuItem that you click before building.

Try: Edit/Project Settings/ Scritp Execution Order.
See: Unity - Manual: Script Execution Order settings