1

I am trying to show a Unity Scene as a subactivity in Android (already imported project to Android Studio).

For now, when it loads the scene in the framelayout it just keeps as a black screen. Im not finding any error, and it doesnt seem to be anything null on the Debug or Logcat.

https://i.stack.imgur.com/BEBpi.jpg

Here is the code im using right now:

public class MainActivity extends Activity {


    private UnityPlayer m_UnityPlayer;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create the UnityPlayer
        m_UnityPlayer = new UnityPlayer(this);
        int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);
        boolean trueColor8888 = false;
        m_UnityPlayer.init(glesMode, trueColor8888);

        setContentView(R.layout.activity_main);

        // Add the Unity view
        FrameLayout layout = (FrameLayout) findViewById(R.id.frame);
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
        layout.addView(m_UnityPlayer, 0, lp);
        m_UnityPlayer.requestFocus();
    }

I've been checking some docs and answers, but nothing is working for me

Unity scene a as SubView

Unity and Android: Create an Unity app with a custom layout

Unity scene as a SubView by tnetennba

Any help will be appreciated, thanks!

Jshell91
  • 11
  • 4

0 Answers0