All I want is to implement a simple IPreprocessBuildWithReport to write a .csv file...
using System.IO;
using System.Text;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.Callbacks;
namespace My.App.Scripts
{
public class MyStuffDoer : IPreprocessBuildWithReport
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
DoMyStuff();
}
[DidReloadScripts]
public static void DoMyStuff()
{
...
}
}
}
Rider is happy to accommodate me, but Unity is refusing to build, insisting that
The type or namespace 'Build' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
The type or namespace 'Callbacks' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
The type or namespace 'IPreprocessBuildWithReport' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace 'BuildReport' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace 'DidReloadScriptsAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace 'DidReloadScripts' could not be found (are you missing a using directive or an assembly reference?)
Stop asking me, Unity, I don't know! AM I?!
Can't seem to find anything remotely useful on the internet in regards to this.
And all the examples I find just toss their IPreprocessBuildWithReport implementation at me, with absolutely no mention of an assembly.
How do you implement an IPreprocessBuildWithReport?
CodePudding user response:
You need to put your editor scripts into folders called "Editor" = )
Your script compiles and runs in the editor environment. Your specific method is found and executed by the editor when building the executable app. But since it's an Editor script, and not a production script, it needs to be recognized by Unity as being part of the extended Editor, not of your app.
Unity is not always intuitive, but it does love you <3
