Ejemplo n.º 1
0
  /**
   * Constructor.
   *
   * @param gvrContext The GVR Context.
   * @param language The language of the script file. Please use the constants {@code LANG_*}
   *     defined in {@link GVRScriptManager}, such as {@code LANG_LUA}, {@code LANG_JAVASCRIPT}, and
   *     so on.
   */
  public GVRScriptFile(GVRContext gvrContext, String language) {
    mGvrContext = gvrContext;
    mLanguage = language;

    // Get an engine because some impl. requires a new engine to
    // enforce context
    ScriptEngine engine = mGvrContext.getScriptManager().getEngine(mLanguage);
    mLocalEngine = engine.getFactory().getScriptEngine();

    // Add globals
    mGvrContext.getScriptManager().addGlobalBindings(mLocalEngine);
  }
Ejemplo n.º 2
0
  private String enterLanguage(String language) {
    ScriptEngine engine = mGVRContext.getScriptManager().getEngine(language);

    if (engine == null) {
      return "Cannot find the language engine for " + language;
    }

    mScriptHandler = new ScriptHandler(mGVRContext, language, engine);
    mShell.setLineProcessor(mScriptHandler);

    return null;
  }