I Cant not bulid my script when I use "UnityEditor" in my script

Hello,everyone .Now ,I am using Unity to make animation.For example, there are a lot of animaitonClips in the project.I has to select different animation fragments to be combined according to different conditions, , and then play the animation. It is not possible to make a fixed state machine because of there are so many conditions. So I dynamically generate the AnimatorController and the animation state machine based on the selected animation fragment. So in this condition, I use the UnityEditor. script in the Unity3D environment, running very well, but my project cannot be released (bulid). I have tried many ways to solve this problem, but it is not ideal. is there anyone has other method to replace my idea or help solve the problem? I will be very grateful

try wrapping your editor code with this:

#if UNITY_EDITOR

// editor code ...

#endif

when you build the game, that code will be excluded & no errors will popup. You shouldn’t need editor code in your game anyways so everything should work fine.

Thanks anyway.