package com.chen.interaction;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;
public class UnityPlayerNativeActivity extends UnityPlayerActivity {
private LinearLayout u3dLayout;
private Button zoomInBtn, zoomOutBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_main);
u3dLayout = (LinearLayout) findViewById(R.id.u3d_layout);
u3dLayout.addView(mUnityPlayer);
mUnityPlayer.requestFocus();
zoomInBtn = (Button) findViewById(R.id.zoom_in_btn);
zoomOutBtn = (Button) findViewById(R.id.zoom_out_btn);
zoomInBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("info","in");
UnityPlayer.UnitySendMessage("Manager", "ZoomIn", "");
}
});
zoomOutBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("info","out");
UnityPlayer.UnitySendMessage("Manager", "ZoomOut", "");
}
});
}
public String getName(final String str) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(UnityPlayerNativeActivity.this, str, 1000).show();
}
});
return "for the lich king";
}
/**
* 3D调用此方法,用于退出3D
*/
public void makePauseUnity() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mUnityPlayer != null) {
try {
mUnityPlayer.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
UnityPlayerNativeActivity.this.finish();
}
});
}
/**
* 按键点击事件
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
onDestroy();
}
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
// UnityPlayer.UnitySendMessage("Manager", "Unload", "");
mUnityPlayer.quit();
}
// Pause Unity
@Override
protected void onPause() {
super.onPause();
mUnityPlayer.pause();
}
// Resume Unity
@Override
protected void onResume() {
super.onResume();
mUnityPlayer.resume();
}
@Override
public void onBackPressed() {
super.onBackPressed();
// mUnityPlayer.quit();
// this.finish();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Interaction.rar (48个子文件)
Interaction
res
drawable-ldpi
drawable-hdpi
drawable-xhdpi
drawable
app_icon.png 8KB
values
strings.xml 113B
drawable-mdpi
layout
layout_main.xml 1KB
assets
bin
Data
sharedassets0.assets.split6 1024KB
sharedassets0.assets.split3 1024KB
sharedassets0.assets.split18 310KB
sharedassets0.assets.split17 1024KB
sharedassets0.assets.split8 1024KB
sharedassets0.assets.split15 1024KB
splash.png 575KB
sharedassets0.assets.split13 1024KB
sharedassets0.assets.split11 1024KB
sharedassets0.assets.split2 1024KB
sharedassets0.assets.split5 1024KB
settings.xml 227B
Resources
unity_builtin_extra 1012KB
sharedassets0.assets.split12 1024KB
unity default resources 611KB
sharedassets0.assets.split4 1024KB
Managed
mscorlib.dll 2.38MB
Assembly-CSharp.dll 5KB
System.Core.dll 262KB
Assembly-UnityScript.dll 12KB
System.dll 1.02MB
UnityEngine.dll 684KB
UnityEngine.UI.dll 133KB
Boo.Lang.dll 124KB
Mono.Security.dll 286KB
sharedassets0.assets.split16 1024KB
sharedassets0.assets.split9 1024KB
sharedassets0.assets.split7 1024KB
sharedassets0.assets.split0 1024KB
sharedassets0.assets.split10 1024KB
mainData 29KB
sharedassets0.assets.split1 1024KB
sharedassets0.assets.split14 1024KB
src
com
chen
interaction
UnityPlayerNativeActivity.java 2KB
.project 861B
.classpath 475B
project.properties 18B
AndroidManifest.xml 2KB
libs
armeabi-v7a
gdbserver 259KB
UnityEditor.UI.dll 69KB
libunity.so 13.82MB
libmono.so 3.75MB
UnityEngine.UI.dll 135KB
libmain.so 34KB
unity-classes.jar 70KB
共 48 条
- 1
资源评论
- HongChengDarren2019-03-22可以,再次下载
- 斯陀含2019-02-28不错,可是使用
- sxwwc2017-10-18来看看是否有帮助
- 狂三酱2016-06-22能用的资源
iywgqt
- 粉丝: 2
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Lgtaxian - 副本.mac
- ubuntu-22.04.5-desktop-amd64.iso.torrent
- 软考软件设计师考试笔记改进版
- 华硕主板BIOS关闭secure boot安全启动设置方法
- Kylin-Server-V10-SP3-General-Release-2303-ARM64.iso
- I219-V网卡驱动windows server适用
- php期末作业php+mysql+html期末作业聊天网站聊天室系统
- H3C驱动FocalTech-FocalFP-A02-v2.0.3.83-0-30005-0
- windows字体Fonts
- win11字体包,误删除字体的可以直接拷贝安装
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功