// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
package com.unity3d.player;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.ImageFormat;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.RectF;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.media.Image;
import android.media.ImageReader;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Size;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.os.Process;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class UnityPlayerActivity extends Activity implements IUnityPlayerLifecycleEvents {
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// Override this in your custom UnityPlayerActivity to tweak the command line arguments passed to the Unity Android Player
// The command line arguments are passed as a string, separated by spaces
// UnityPlayerActivity calls this from 'onCreate'
// Supported: -force-gles20, -force-gles30, -force-gles31, -force-gles31aep, -force-gles32, -force-gles, -force-vulkan
// See https://docs.unity3d.com/Manual/CommandLineArguments.html
// @param cmdLine the current command line arguments, may be null
// @return the modified command line string or null
protected String updateUnityCommandLineArguments(String cmdLine) {
return cmdLine;
}
// Setup activity layout
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity"));
getIntent().putExtra("unity", cmdLine);
mUnityPlayer = new UnityPlayer(this, this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
applyForPermission(); // add by eh
}
// When Unity player unloaded move task to background
@Override
public void onUnityPlayerUnloaded() {
moveTaskToBack(true);
}
// Callback before Unity player process is killed
@Override
public void onUnityPlayerQuitted() {
}
@Override
protected void onNewIntent(Intent intent) {
// To support deep linking, we need to make sure that the client can get access to
// the last sent intent. The clients access this through a JNI api that allows them
// to get the intent set on launch. To update that after launch we have to manually
// replace the intent with the one caught here.
setIntent(intent);
mUnityPlayer.newIntent(intent);
}
// Quit Unity
@Override
protected void onDestroy() {
mUnityPlayer.destroy();
super.onDestroy();
}
// Pause Unity
@Override
protected void onPause() {
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
@Override
protected void onResume() {
super.onResume();
mUnityPlayer.resume();
}
// Low Memory Unity
@Override
public void onLowMemory() {
super.onLowMemory();
mUnityPlayer.lowMemory();
}
// Trim Memory Unity
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (level == TRIM_MEMORY_RUNNING_CRITICAL) {
mUnityPlayer.lowMemory();
}
}
// This ensures the layout will be correct.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mUnityPlayer.configurationChanged(newConfig);
}
// Notify Unity of the focus change.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
mUnityPlayer.windowFocusChanged(hasFocus);
}
// For some reason the multiple keyevent type is not supported by the ndk.
// Force event injection by overriding dispatchKeyEvent().
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
return mUnityPlayer.injectEvent(event);
return super.dispatchKeyEvent(event);
}
// Pass any events not handled by (unfocused) views straight to UnityPlayer
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
return mUnityPlayer.injectEvent(event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return mUnityPlayer.injectEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return mUnityPlayer.injectEvent(event);
}
/*API12*/
public boolean onGenericMotionEvent(MotionEvent event) {
return mUnityPlayer.injectEvent(event);
}
//////////////////////////增加的代码开始处////////////////////////////////////////////////////
final private static String TAG = UnityPlayerActivity.class.getName();
//供unity 调用 接口
public void OnClickBtn1() {
Log.d(TAG, "android OnClickBtn1");
if (isOpenFloatingWindow()) {
addFloatingWindowView(); //增加悬浮窗后
} else {
openCamera();
}
}
//供unity 调用 接口
public void OnClickBtn2() {
Log.d(TAG, "android OnClickBtn2");
if (isOpenFloatingWindow()) {
releaseFloatingWindow();
} else {
releaseCamera();
}
}
//供unity 调用 接口 暂时无用
public void OnClickBtn3() {
Log.d(TAG, "android OnClickBtn3");
// myActivity.addFloatingWindowView();
exchangeCamera(); //切换相机
}
/////////////////////////////////////////////////////////////////
//增加camera2 摄像头
private CameraManager mCameraManager;
private CameraDevice.StateCallback mStateCallback;
private CameraDevice mCameraDevice;
private TextureView mTextureView;
private CameraCaptureSession mCaptureSession;
private CaptureRequest mPreviewRequest;
private int mCameraSensorOrientation = 0; //摄像头方向
// private int mCameraFacing = CameraCharacteristics.LENS_FACING_FRONT ; //默认使用前置摄像头
private int mDisplayRotation = 0; //getDisplay().defaultDisplay.rotation //手机方向
private String cameraIdFront = "1"; //相机ID 可以自行设定 // 0 后置 1 前置 //默认使用前置摄像头
private Size[] cameraSizeFront; //相机支持的尺寸
private CameraCharacteristics cameraCharacteristicsFront; //
private static final int RECV_MAX_IMAGES = 2; //同时最多接收2张图片
private ImageReader mImageReader;
private TextureView.SurfaceText
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于camera2 untiy悬浮窗摄像头预览分析(优化二) (2321个子文件)
baselib.a 1.22MB
DefaultWsdlHelpGenerator.aspx 59KB
DefaultWsdlHelpGenerator.aspx 59KB
DefaultWsdlHelpGenerator.aspx 59KB
gradlew.bat 3KB
classAnalysis.bin 1024KB
executionHistory.bin 538KB
jarAnalysis.bin 138KB
executionHistory.bin 135KB
fileHashes.bin 121KB
outputFiles.bin 59KB
fileHashes.bin 26KB
taskHistory.bin 24KB
resourceHashesCache.bin 23KB
sha1-checksums.bin 20KB
md5-checksums.bin 18KB
resourceHashesCache.bin 18KB
feature_tests.bin 14KB
feature_tests.bin 14KB
CMakeDetermineCompilerABI_CXX.bin 10KB
CMakeDetermineCompilerABI_CXX.bin 10KB
CMakeDetermineCompilerABI_C.bin 10KB
CMakeDetermineCompilerABI_C.bin 10KB
last-build.bin 1B
last-build.bin 1B
Compat.browser 2KB
Compat.browser 2KB
Compat.browser 2KB
mscorlib_CodeGen.c 2.27MB
Il2CppTypeDefinitions.c 1.75MB
Il2CppMetadataUsage.c 1.08MB
UnityEngine.UI_CodeGen.c 458KB
UnityEngine.CoreModule_CodeGen.c 406KB
marshal.c 356KB
debugger-agent.c 337KB
class.c 334KB
Il2CppGenericInstDefinitions.c 332KB
icall.c 256KB
object.c 249KB
verify.c 206KB
metadata.c 201KB
dlmalloc.c 177KB
os_dep.c 171KB
metadata-verify.c 149KB
threads.c 146KB
sre.c 142KB
Il2CppGenericClassTable.c 131KB
Il2CppGenericMethodTable.c 131KB
sgen-gc.c 127KB
w32file-unix.c 127KB
w32process-unix.c 123KB
assembly.c 121KB
Il2CppGenericMethodDefinitions.c 110KB
cominterop.c 108KB
sre-save.c 107KB
win32_threads.c 102KB
UnityEngine.AndroidJNIModule_CodeGen.c 101KB
reflection.c 96KB
sgen-marksweep.c 93KB
sgen-mono.c 91KB
System_CodeGen.c 91KB
image.c 82KB
loader.c 82KB
appdomain.c 81KB
misc.c 81KB
decimal-ms.c 79KB
deflate.c 77KB
pthread_support.c 77KB
mark.c 76KB
custom-attrs.c 73KB
w32socket.c 73KB
test.c 70KB
remoting.c 63KB
boehm-gc.c 57KB
domain.c 55KB
dyn_load.c 54KB
inflate.c 54KB
alloc.c 52KB
UnityEngine.IMGUIModule_CodeGen.c 52KB
mono-perfcounters.c 52KB
finalize.c 49KB
mono-threads.c 46KB
pthread_stop_world.c 44KB
w32socket-unix.c 44KB
trees.c 43KB
monitor.c 41KB
dbg_mlc.c 39KB
profiler.c 38KB
threadpool-worker-default.c 38KB
security-core-clr.c 37KB
sgen-debug.c 36KB
sre-encode.c 35KB
gc.c 35KB
allchblk.c 34KB
sgen-tarjan-bridge.c 33KB
xxhash.c 33KB
mark_rts.c 33KB
exception.c 33KB
coree.c 32KB
debug-helpers.c 31KB
共 2321 条
- 1
- 2
- 3
- 4
- 5
- 6
- 24
资源评论
yunteng521
- 粉丝: 106
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功