资源简介
Android与Unity交互示例
文章地址:http://blog.csdn.net/crazy1235/article/details/46733221
unity源码:https://yunpan.cn/cR369kvVbK2Ef (f9e9)
代码片段和文件信息
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();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 475 2016-06-13 16:00 Interaction\.classpath
I.A.... 861 2016-06-13 15:59 Interaction\.project
I.A.... 2162 2016-06-13 17:14 Interaction\AndroidManifest.xm
I.A.... 29460 2016-06-13 18:26 Interaction\assets\bin\Data\mainData
I.A.... 5120 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\Assembly-CSharp.dll
I.A.... 12288 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\Assembly-Unitysc
I.A.... 126976 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\Boo.Lang.dll
I.A.... 292864 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\Mono.Security.dll
I.A.... 2496512 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\mscorlib.dll
I.A.... 268288 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\System.Core.dll
I.A.... 1069568 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\System.dll
I.A.... 699904 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\UnityEngine.dll
I.A.... 136192 2016-06-13 18:26 Interaction\assets\bin\Data\Managed\UnityEngine.UI.dll
I.A.... 1036040 2016-06-13 18:26 Interaction\assets\bin\Data\Resources\unity_builtin_extra
I.A.... 227 2016-06-13 18:26 Interaction\assets\bin\Data\settings.xm
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split0
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split1
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split10
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split11
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split12
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split13
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split14
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split15
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split16
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split17
I.A.... 317448 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split18
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split2
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split3
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split4
I.A.... 1048576 2016-06-13 18:26 Interaction\assets\bin\Data\sharedassets0.assets.split5
............此处省略41个文件信息
相关资源
-
Android选择拍照剪裁ba
se64.16进制.by - Android Room with a View
- Android项目源码高仿知乎android studio版
- Android开发ArcGIS查找最短的路径
- Android Vitamio的使用解析Part3
- Android实现带边框的表格布局.zip
- 小说阅读器项目Android应用源码极简可
- Android 原生TTS
- Android原生Camera2完成预览和拍照
- JAVAWEB和Android开发的图书馆管理系统
- Android Studio简易购物车
- 最新版谷歌拼音中文输入法V4.1.3.102
- IBeacon Android 源码
- 推箱子Android
- Android 实现短信接收监听--短信动态权
- Android bikeroute自行车导航源码
- android studio 调用相机拍照,选择相册
- android修改头像
- TUTK_Android_SDK
- Android人体检测
- android加密
- Android手机银行
- android_m2repository_r07
- Android SO文件保护加固——混淆篇一源
- Android仿大众点评源码
- android 休眠和唤醒
- android 仿日历翻页特效,数字翻转变换
- Android 高德地图入门demo,最新高德地
- Android解决多个Fragment切换时布局重新
- Android解决多个Fragment切换时布局重新
评论
共有 条评论