-
I'm creating an MVP implementation for unity, where Jint is used as scripting for the model. var canMove = Root["Root_BoolContainer/B_CanMove"]
var special = Root["Root_Special"]
var strength = special["I_Str"]
strength.SetValid(function(lastValue, newValue) {..Some code for valid...} ) Situation: I have string IDs (like it: "Root_BoolContainer/B_CanMove") that I would like to keep as variables. I have options for this:
Questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I'm probably not able to give any direct answers, especially as I haven't done any Unity development. You might want to ping the gitter chat room too with this discussion topic. I think performance in this case is something that you need to measure. Make sure you use the v3 beta, it's much faster. Having multiple engines should be quite efficient as memory usage has been quite optimized, also if you have static script, you should compile it only once using Jint will soon support dynamic import (but unfortunately it's a bit cumbersome to use via Promise while there's no await support). You could also create a wrapper type to allow using properties via cleaner API, like |
Beta Was this translation helpful? Give feedback.
-
Do I understand correctly that the two marked lines perform exactly the same actions and theoretically they should be absolutely the same in speed? If yes, then it is better to use several engines. I was afraid that in this option there might be extra castes. Engine e1 = new Engine();
Engine e2 = new Engine();
e2.SetValue("SomeValue", e1.GetValue("SomeValue")) // this var someValue = otherEngine.GetValue("SomeValue") // and this |
Beta Was this translation helpful? Give feedback.
I'm probably not able to give any direct answers, especially as I haven't done any Unity development. You might want to ping the gitter chat room too with this discussion topic.
I think performance in this case is something that you need to measure. Make sure you use the v3 beta, it's much faster. Having multiple engines should be quite efficient as memory usage has been quite optimized, also if you have static script, you should compile it only once using
JavaScriptParser
and then pass the sameScript
instance to engine.Jint will soon support dynamic import (but unfortunately it's a bit cumbersome to use via Promise while there's no await support).
You could also create a wrapper type t…