Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity: IPreprocessBuildWithReport is not running on Build

I am a new with Unity and I have been trying to build a Unity project where when it is built, it can also copy some files with the game.exe in the Build folder. For that, I need to understand how IPreprocessBuildWithReport works.

I have created a C# script called MyCustomBuildProcessor.cs and put it inside: Assets\Scripts\Editor The script is as follows:

//Implement this function to receive a callback before the build is started.
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;

class MyCustomBuildProcessor : IPreprocessBuildWithReport
{
    public int callbackOrder { get { return 0; } }
    public void OnPreprocessBuild(BuildReport report)
    {
        Debug.Log("MyCustomBuildProcessor.OnPreprocessBuild for target " + report.summary.platform + " at path " + report.summary.outputPath);
    }
}

To my understanding, this script should run when I build the project, but the Log is not shown in the console. Can someone explain to me what I am doing wrong?

My build setting is as follows: Unity Build Settings Image , Unity Project Files

My Unity version is: 2022.1.20f1

I have tried building in different version like 2021.3.10f1 and tried placing the file in outside the Editor folder but nothing has worked. Maybe there is something basic that I am missing. I am new to the Unity scene so I have no idea what I am doing wrong.

like image 767
ghufran ullah Avatar asked Nov 19 '25 17:11

ghufran ullah


1 Answers

You need to just uncheck the "Clear on Recompile" toggle:

Clear on Recompile

like image 105
Eduard Malkhasyan Avatar answered Nov 21 '25 06:11

Eduard Malkhasyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!