Script Initialization

Now that we have the SymGym library in our Unity project, we need to initialize it so we can send information to and from the SymGym controller.

Add SymGym Stub variables

To initialize the library, add the following variables to the GameController.cs in the /Assets/Scripts directory.) (If you are following the tutorials, you may need to modify the Done_GameController.cs script in the Done_Scripts directory.)

  public static AndroidJavaObject sgStub;
  public static AndroidJavaObject sgState;

Initialize the Library

Add the following to the Initialize() method (create Initialize() if necessary)

  public static void Initialize() {
    if (sgStub == null) {
      AndroidJavaClass unityPlayer =
                       new AndroidJavaClass("com.unity3d.player.UnityPlayer");
      AndroidJavaObject activity =
      AndroidJavaObject context =
      sgStub = new AndroidJavaObject("",
             context, "api_key_string_here");