Ok, so far so good. I learnt how to launch any app from Unity and then how to launch Retroarch. Now I’m trying to load Genesis Plus GX core and a file I have located in a known and confirmed path, but can’t load the rom, and not sure if at least the core is loaded. I’m saving the CONFIGFILE and IME options for later, once I’ve got a rom working, but I don’t know if they should be set in order for the rom to load.
Here’s my code (grabbed from some unfinished examples from the Unity forums). I’d appreciate if someone could take a look and let me know if there’s something wrong:
public void LaunchApp() {
if (Application.platform == RuntimePlatform.Android) {
bool fail = false;
string bundleId = "com.retroarch";
string fileName = Application.persistentDataPath + "/Aladdin.smd";
Debug.Log ("ROM PATH: " + fileName); // I print this to confirm the path is correct
// the next four lines don't need to be changed
AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ca = up.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject packageManager = ca.Call<AndroidJavaObject>("getPackageManager");
AndroidJavaObject launchIntent = null;
try {
launchIntent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", bundleId);
launchIntent.Call<AndroidJavaObject>("putExtra", "ROM", fileName);
launchIntent.Call<AndroidJavaObject>("putExtra", "LIBRETRO", "/data/data/com.retroarch/cores/genesis_plus_gx_libretro_android.so");
//launchIntent.Call<AndroidJavaObject>("putExtra", "CONFIGFILE", getRetroarchProperties);
//launchIntent.Call<AndroidJavaObject>("putExtra", "IME", ime);
}
catch (System.Exception e) {
fail = true;
}
if (fail) {
Debug.Log("App not found");
} else {
ca.Call("startActivity", launchIntent);
}
up.Dispose();
ca.Dispose();
packageManager.Dispose();
launchIntent.Dispose();
}
}
}