So, I'm checking if one of my function names is found in the interpreter after the script has compiled, and it can't seem to find it. What's weird about this is, it only happens 50% of the time when starting in the Unity editor from scratch. Afterward, the function can be found (not sure if it's a caching thing). Also, windows standalone builds do not exhibit this bug. It works 100% of the time.
Here is my function to check for the function name:
private bool HasHandler(string handlerName)
{
try
{
Value val = mSys.interpreter.GetGlobalValue(handlerName);
if (val == null)
return false;
}
catch (UndefinedIdentifierException e)
{
return false;
}
return true;
}
And here is my interpreter initialization:
interpreter.Reset(finalScript);
interpreter.Compile();
if (runScriptAfterLoad)
{
// SEMI-HACK: This forces the script to run once
// so that the function map is validated
// for lookups.
interpreter.RunUntilDone(0.01f, false);
}
mIsReady = true;
At what point can I guarantee HasHandler() returns true for 100% of the time? It seems like I'm not waiting for MiniScript to register all the vars in the map.