Search code examples
unity-game-engineunity-editor

ExpressionEvaluator.Evaluate when unity build apk


im using a script in my project and in this script for solve a simple math equation same "1+2-2+1" from string input i use ExpressionEvaluator.Evaluate but this is in unityeditor class and when i build my project i reach an error that is say
"The name "ExpressionEvaluator" does not exist in the current context." i handle this error with using Platform Dependent Compilation https://docs.unity3d.com/Manual/PlatformDependentCompilation.html but when i try to install apk i reach an error on android device and device say the application is not install.

now my question is that,is there any alternative for ExpressionEvaluator.Evaluate or any suggestion that you can helm me with.

thank you so much.


Solution

  • I doubt the installation failure has anything to do with conditional compilation. I can't say much about that, but regarding ExpressionEvaluator, there is a lot of code in UnityEngine. If you were to bundle all that code with your game, you'd get a multi-hundred megabyte apk on your hands; not to mention that most of the code is probably native and they don't/can't build it for all target platforms, only editor platforms (Windows, MacOS).

    You really shouldn't use UnityEditor code in your game logic, not even in the editor. If you use UnityEditor it should only be in editor code. If something's in UnityEditor and you need to support it at runtime, you should find a library that does the same, or write it yourself. You can search for one online or on SO. Here's the first result from a Google search:

    I need a fast runtime expression parser