From f95ccf240c48c97c54e8f09e386d56a2cf5fffc9 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期日, 19 十一月 2023 21:35:09 +0800 Subject: [PATCH] 0312 同步最新unity版本的UnityPlayerActivity.java --- SdkProject/library/src/main/java/com/secondworld/sdk/UnityPlayerActivity.java | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/SdkProject/library/src/main/java/com/secondworld/sdk/UnityPlayerActivity.java b/SdkProject/library/src/main/java/com/secondworld/sdk/UnityPlayerActivity.java index bee6ee2..ee5653c 100644 --- a/SdkProject/library/src/main/java/com/secondworld/sdk/UnityPlayerActivity.java +++ b/SdkProject/library/src/main/java/com/secondworld/sdk/UnityPlayerActivity.java @@ -4,12 +4,14 @@ import android.app.Activity; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.PixelFormat; import android.os.Bundle; -import android.os.Process; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.View; import android.view.Window; - +import android.view.WindowManager; +import android.os.Process; import com.unity3d.player.IUnityPlayerLifecycleEvents; import com.unity3d.player.UnityPlayer; @@ -39,8 +41,8 @@ getIntent().putExtra("unity", cmdLine); mUnityPlayer = new UnityPlayer(this, this); -// setContentView(mUnityPlayer); -// mUnityPlayer.requestFocus(); + setContentView(mUnityPlayer); + mUnityPlayer.requestFocus(); } // When Unity player unloaded move task to background @@ -70,6 +72,22 @@ super.onDestroy(); } + // If the activity is in multi window mode or resizing the activity is allowed we will use + // onStart/onStop (the visibility callbacks) to determine when to pause/resume. + // Otherwise it will be done in onPause/onResume as Unity has done historically to preserve + // existing behavior. + @Override protected void onStop() + { + super.onStop(); + mUnityPlayer.pause(); + } + + @Override protected void onStart() + { + super.onStart(); + mUnityPlayer.resume(); + } + // Pause Unity @Override protected void onPause() { -- Gitblit v1.8.0