Hey, Mono cecil works fine in the editor. I'm changing the: /Library/ScriptAssemblies/Assembly-CSharp.dll on [InitializeOnLoad] and using EditorApplication.LockReloadAssemblies(); EditorApplication.UnlockReloadAssemblies(); while changing it The problem is when building it out, it doesn't seem to work I have tried: [PostProcessBuildAttribute(0)] Question is, which DLL do I process for the build. And at what stage? The building code is also in the Assembly-CSharp.dll if that makes a difference. It's also wrapped in #if UNITY_EDITOR help would be very much appreciated
I haven't done a lot of modifying the same assembly that the code doing the modifying is in... but, I will note you said: Well, that UNITY_EDITOR compiler directive tells it to only run in the editor. So it would make sense if it worked in the editor and not in the build.
Yeah but the code is only supposed to run in the editor, it's not supposed to be compiled out. Since Cecil is modifying the build DLL from the editor. And trying to build the game with any code that uses UnityEditor will cause a compile error.
I'm not following exactly... You're hoping to use cecil to modify the build dll when you build the game? So that the distributed package has these changes done by cecil? But this gets done from within the editor? When/where does this code using cecil get ran? ... The only logical place I can see doing something like this would be in a build script (so editor only specifically). Instead of using the standard build process in the file menu, you instead write one in an editor script and use the 'BuildPipeline': https://docs.unity3d.com/ScriptReference/BuildPipeline.html Then when done, you load up the generated dll and modify it. ... Otherwise, when and where would it be done?