android 移植游戏,Unity游戏移植到Android平台

很多时候不仅需要单纯的运行单个的unity游戏,而是需要将游戏嵌入Android代码中和android其他功能相辅生成一个APP,比如通过android界面的一个按钮来启动一个unity游戏。本文介绍一下主要的过程。

1.  将可运行的unity游戏打包为Android project。

在Unity界面,File->Building settings,Export Android project。

04776cf0b3f8

另外需要配置一下Player Settings,我的是这样的。注意package Name的名字要与将要移植到android中的package name保持一致。其余的api设置也与android平台保持一致。

04776cf0b3f8

2.  打包完成后在Android studio中新建一个项目或者打开自己的项目,将打包好的项目中libs中的unity-classes.jar复制到Android Studio中的libs中,并且点击右键Add to library。

04776cf0b3f8

04776cf0b3f8

3.  在Android studio中app->src->main下新建jniLibs 这样一个directory,将unity工程中的src->main->jniLibs的armeabi-v7a和x86复制到jniLibs中。

04776cf0b3f8

04776cf0b3f8

4.  将unity项目 中的src->main->assets整个文件复制到android studio中的app->src->main->assets中。

04776cf0b3f8

04776cf0b3f8

5.  至此,基本资源文件复制完成,下面进行Android 代码的编辑。我的app制作思路是在android放置一个按钮然后启动游戏,点击mouse启动打地鼠游戏。

04776cf0b3f8

在MainActivity中设置按钮的监听事件。新建一个MouseActivity活动。然后打开unity生成的projectw文件中的UnityPlayerActivity.java,将其中的内容全部复制到MouseActivity中(除了首行的package),并修改UnityPlayerActivity类名为MouseActivity。

04776cf0b3f8

04776cf0b3f8

04776cf0b3f8

6.  修改AndroidManifest.xml中的内容。打开unity项目src->main中的AndroidManifest.xml,复制这些内容到android studio中

04776cf0b3f8

(这是android studio中的内容)

04776cf0b3f8

(这是unity中的,这些也需复制到android studio中)

到现在全部步骤完成,进行run就可以在真机运行了。(最后运行的图片老是上传失败,没办法了)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441844.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

code vs 代码格式化排版_23行代码,教你用python实现百度翻译!(建议收藏)

前言:努力折腾的人生虽然不是符合完美生活,但它一定是个很精彩的人生!生命在于折腾,正如敲代码一样,你们说是吗?文章主要介绍了用23行python代码实现百度翻译,颇有参考性,喜欢的记得…

【HDU - 1013 】Digital Roots (大数模拟)

题干: The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summe…

mete30是鸿蒙系统么,华为mete30pro什么时候能用上鸿蒙系统?

[其他]华为mete30pro什么时候能用上鸿蒙系统?8957电梯直达huafans01303113614新学乍练发表于 2021-4-21 21:43:19来自:HUAWEI Mate 30 Pro 5G最新回复 2021-4-22 12:10:10华为mete30pro什么时候能用上鸿蒙系统?能有确切的时间吗伊凡爱尔顿已臻…

【HDU - 1520】Anniversary party (树形dp)

题干: There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tree rooted at the rector V. E. Tretyako…

android assets 文件夹 复制,Android 中 Assets目录下 文件或文件夹的复制

1、文件或文件夹的复制/** 下面两个方法不是AsyncTask的接口** copyFileOrDir 目录复制* copyFile 文件复制*/private void copyFileOrDir(String path) {AssetManager assetManager mContext.getAssets();String assets[] null;try {assets assetManager.list(path);//复制…

python运算符中用来计算整商的是什么_零基础学python,看完这篇文章,你的python基础就差不多了...

Python基础语法1. 认识Python1.1 Python 简介Python 的创始人为吉多范罗苏姆(Guido van Rossum)。Python 的设计目标:一门简单直观的语言并与主要竞争者一样强大开源,以便任何人都可以为它做贡献代码像纯英语那样容易理解适用于短…

*【HDU - 1242 】 Rescue (反向dfs,或bfs)

题干&#xff1a; Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M < 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angels friends want to save Angel. Their task is: approach Ang…

华为鸿蒙os系统转正,华为鸿蒙OS系统正式官宣,转正工作提上日程,明年多款终端将使用...

华为鸿蒙OS系统相信很多小伙伴都不陌生&#xff0c;作为国内现如今顶尖的科技企业。华为这些年的发展也是十分迅速的&#xff0c;而再快速的发展过程中。更多的用户对于华为的新款系统也充满了好奇&#xff0c;要知道一款属于国人自己的国产系统。在之前的国内手机上是几乎不存…

【FZU - 2140 】Forever 0.5 (计算几何,构造)

题干&#xff1a; Given an integer N, your task is to judge whether there exist N points in the plane such that satisfy the following conditions: 1. The distance between any two points is no greater than 1.0. 2. The distance between any point and the ori…

map型字段 mongodb_MongoDB极简教程

来源&#xff1a;我没有三颗心脏1.MongDB 简介MongoDB(来自于英文单词“Humongous”&#xff0c;中文含义为“庞大”)是可以应用于各种规模的企业、各个行业以及各类应用程序的开源数据库。作为一个适用于敏捷开发的数据库&#xff0c;MongoDB 的数据模式可以随着应用程序的发展…

html 如何改变图片形状,图形变换的三种方式是什么?

图形变换的三种方式1、平移平移&#xff0c;是指在同一平面内&#xff0c;将一个图形上的所有点都按照某个直线方向做相同距离的移动&#xff0c;这样的图形运动叫做图形的平移运动&#xff0c;简称平移。平移不改变图形的形状和大小。图形经过平移&#xff0c;对应线段相等&am…

springboot html压缩,springboot 请求响应压缩

官方文档原文&#xff1a;[https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/reference/htmlsingle/\#how-to-enable-http-response-compression][https_docs.spring.io_spring-boot_docs_2.1.5.RELEASE_reference_htmlsingle_how-to-enable-http-response-compression]…

Trie树(字典树)详细知识点及其应用

Trie&#xff0c;又经常叫前缀树&#xff0c;字典树等等。它有很多变种&#xff0c;如后缀树&#xff0c;Radix Tree/Trie&#xff0c;PATRICIA tree&#xff0c;以及bitwise版本的crit-bit tree。当然很多名字的意义其实有交叉。 定义 在计算机科学中&#xff0c;trie&#x…

aip格式转化为pdf_python提取pdf文档中的表格数据、svg格式转换为pdf

提取pdf文件中的表格数据原文链接https://www.analyticsvidhya.com/blog/2020/08/how-to-extract-tabular-data-from-pdf-document-using-camelot-in-python/另外还参考了这篇文章https://camelot-py.readthedocs.io/en/master/实现提取pdf文档中的表格数据需要使用camelot模块…

html验证邮箱自动,html5+JavaScript进行邮箱地址验证

html5 网页特效 邮箱地址验证body, input, textarea {font-family: "helvetica", arial, helvetica;}label {display: block;float: left;clear: left;text-align: right;width: 100px;margin-right: 10px;}p { padding: 10px; }fieldset { border: 1px solid #ccc; …

6 rethad 自定义硬盘_图文详解zabbix配置自定义监控项过程

概述今天主要介绍一下zabbix如何去配置自定义监控模板&#xff0c;下面一起来看看吧&#xff01;一、模板1、概念模板(template)&#xff1a;可以应用到主机上的实体(包括监控项、触发器、数据图、图表、监控分类、低级的自动发现规则)的集合。当一个模板被应用到一个主机后&am…

【HDU - 1085 】Holding Bin-Laden Captive! (母函数)

题干&#xff1a; We all know that Bin-Laden is a notorious terrorist, and he has disappeared for a long time. But recently, it is reported that he hides in Hang Zhou of China! “Oh, God! How terrible! ” Don’t be so afraid, guys. Although he hides in a…

html text align属性,HTML canvas

实例在位置 150 创建一条红线。位置 150 是下面实例中定义的所有文本的锚点。请研究每种 textAlign 属性值的效果&#xff1a;YourbrowserdoesnotsupporttheHTML5canvastag.JavaScript&#xff1a;var cdocument.getElementById("myCanvas");var ctxc.getContext(&qu…

html超链接点不了_HTML、CSS、JS都有哪些区别?不看必悔

划重点HTML、CSS、及JS的区别有哪些&#xff1f;在日常学习中&#xff0c;html&#xff0c;css和js我们都学过&#xff0c;起初分不清这三者的区别和联系&#xff0c;随着知识的增长&#xff0c;有了一些体会。看一下这三项技术都是什么&#xff0c;能干什么&#xff1f;web前端…

【Codeforces - 378C】Maze(dfs,思维)

题干&#xff1a; Pavel loves grid mazes. A grid maze is an n  m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side. Pavel drew a grid maze with all empty…