unity3d与eclipse集成开发android应用
原地址:http://blog.csdn.net/armoonwei/article/details/7032537
Unity as a Library
Once you have eclipse installed and up to date you have to follow a few steps to get your unity project set up as a library in eclipse.
- 创建一个空的unity3d工程,然后使用android平台进行编译。
- 切换到新工程的目录中,找到Temp目录,这个目录下有:staging area.
- 拷贝目录staging area到其他某个目录下,注意此目录不要放置于eclipse工作空间中。
- 打开eclipse并创建一个android的项目。
- 在创建项目的引导中,选择Android Project并点击Next按钮
- 这一步是工程的library信息, This will be the library part of your project so name the project accordingly to avoid any confusion.
- You will also want to select the option to create project from an existing source. This source being the files you copied to the folder you are using as a holding area. If you select the Staging Area folder then click OK you will see that eclipse has filled in the relevant fields for you.
- click finish on the project creation wizard.
- Finally right click the root folder in the Package explorer tab in Eclipse and select the Properties option then the android tab. Check the "Is Library" check box, click Apply and then OK.
This completes the steps that you need to carry out to have your unity project addressed as a library in eclipse.
Java Project
The next step is to create the eclipse project that will form the executable part of the project.
- Create another new android project.
- Name the project and select the Build Target and Min SDK Version to be the same as the Library project that you created.
- Make sure that the package name is the same as the bundle identifier in your unity project otherwise you can get problems with conflicting files in the generated java files in your project.
- Now the library you created needs to be added to the project, you do this by right clicking the JavaProject and selecting properties.
- You then need to Select Android and click add. A window should then popup select the library project that was created and click ok. Once you are back in the main window click apply.
- Now select Java Build Path from the list on the left and click add external jar. A window will now popup you need to navigate to your unity install directory and in Unity\Editor\Data\PlaybackEngines\androidplayer\bin there will be a file called classes.jar. Double click that and then click on ok.
This sets up a basic Java Project that is now linked to your unity project and the relevant libraries that we will later need.
Moving the Projects Assets
This is the important part to get your unity content into the Java Project so that it will display when you later build and run your Java Project. You now need to move all the files in the assets folder in the library project into the new project. This is because Android does not allow assets to be used in libraries. The best way to do this is from within the Eclipse IDE. If you expand the assets files within both parts of the package explorer and simply drag the bin and libs folders from the library part of your project to the other. This last step needs to repeated everytime your unity project is rebuilt or maybe you could write a script to handle moving the files everytime you build the project automatically. This could also be achieved using symlinks or junctions. At this point when you run the from the eclipse ide you will be asked which type of project that you want to run. Select android and click ok. After eclipse builds the project it will deploy it to your connected android device and you should see a hello world style application running.
Getting Your Unity Content Running
To get your unity project you need to make a few changes to the java source code. In your eclipse project there will be one source file (.java) open this file. The contents of this file will resemble something like this.
package com.Unity3D.EclipseIntegration; import android.app.Activity;
import android.os.Bundle; public class EclipseIntegration extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
We need to change this. The first thing is to change the base class of the object. It should now instead extend UnityPlayerActivity. You will notice that when you do this that it is red underlined proclaiming errors. This is simply missing import directives in the file. The eclipse shortcut to auto resolve this is ctrl+shift+o. The fiel should now have the import statement.
import com.unity3d.player.UnityPlayerActivity;
If you run in this state you will see that you now have a full screen hello world application. This is not what you want we need one more change to get your unity content running.
In the onCreate function there is one line that is overriding the unity view in the android application. If you delete the line.
setContentView(R.layout.main);
The complete file should now look like this.
package com.Unity3D.EclipseIntegration; import android.os.Bundle; import com.unity3d.player.UnityPlayerActivity; public class EclipseIntegration extends UnityPlayerActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
If you run it now you will see your unity content running on your android device.
unity3d与eclipse集成开发android应用的更多相关文章
- [国嵌笔记][019][Eclipse集成开发环境]
Eclipse集成开发环境的作用 可以编译程序,也可以对程序进行在线调试 集成开发环境 1.JLink连接开发板的JTAG 2.JLink连接PC的USB 3.eclipse软件 4.gdb serv ...
- PhoneGap 在eclipse上开发Android程序
本文将记录在Eclipes上开发Android App,在使用的方法是Hybrid App(混合模式移动应用), 由于本人的工作需要,将要开发在车间使用的数据录入程序,但是其中有非常多的逻辑验证和判断 ...
- 【转】eclipse集成开发工具的插件安装
转发一:打开Eclipse下载地址(http://www.eclipse.org/downloads/),可以看到有好多版本的Eclipse可供下载,初学者往往是一头雾水,不知道下载哪一个版本. 各个 ...
- eclipse adt开发android ndk没有NDK选项问题的解决方案
原创 2015年01月28日 09:38:40 标签: android ndk / eclipse / adt 15989 今天是2015年1月28号,整理一下昨天使用eclipse adt搭建的an ...
- 1.5 Eclipse集成开发环境
1. 格式化nandflash PATH路径优先用前面的 Arm-linux-gdb # .bashrc # User specific aliases and functions ali ...
- 配置eclipse集成开发环境_编译_调试
1. 因为eclipse是基于Java运行,所以在运行Eclipse之前,需要安装Java SE,对于Java SE,需要Java SE6 JRE系列的版本,可以在这个位置下载: Java SE 6只 ...
- 1.3……Eclipse下开发Android相关知识
Android应用目录结构 src -------------------------------------------java原代码存放目录 gen ----------------------- ...
- Eclipse集成开发环境搭建
gdbserver安装: 安装gdb-server的环境变量要放在arm-linux-gcc的环境的前面,因为arm-linux-gcc的安装包里面也有gdb,linux系统在找指令时从/root/. ...
- 5.3.2 Eclipse集成开发环境的使用技巧
Eclipse具有强大的编辑.调试.编译和打包功能,本节仅讲解Eclipse中最常用的功能. 1.将程序代码和注释字体变大 (1)启动Eclipse,选择“Windows”->“Preferen ...
随机推荐
- T-SQL 使用链接库向mysql导数据遇到的奇葩事件一
mysql表结构有 主键 非自增 text longtext类型字段多个 步骤 1.在T-SQL 临时表中处理好所有需要的字段 2.执行openquery语句 字段顺序完全按照mysql字段顺序插入 ...
- 重叠I/O之可等待的重叠I/O【系列一】
一 什么是异步I/O 同步I/O和异步I/O的关键不同就是在发出I/O请求后,线程是否会阻塞.当线程发出一个设备I/O请求的时候,线程会被挂起来,直到设备完成I/O请求为止,这称之为同步I/O.而对于 ...
- Office升级到2013版后无法登录微软账号问题
自打office从2010版升级到2013版,就再也无法登录微软账号了.每次点击登录,弹出来的框就显示:this feature has been disabled by your administr ...
- Visual Studio下SQLite数据库开发环境设置
由于我们介绍的内容都是基于微软的Visual Studio下开发的Win32平台,所以下边我们介绍Visual Studio下SQLite数据库开发环境设置.具体而言我们有两种方式可以在Visual ...
- Cocos2d-x如何控制动作速度
基本动作和组合动作实现了针对精灵的各种运动和动画效果的改变.但这样的改变速度匀速的.线性的.通过ActionEase及其的派生类和Speed 类我们可以使精灵以非匀速或非线性速度运动,这样看起了效果更 ...
- Java WebService简单实例
一.准备工作(以下为本实例使用工具) 1.MyEclipse10.7.1 2.JDK 1.6.0_22 二.创建服务端 1.创建[Web Service Project],命名为[TheService ...
- 用sublime编译C++的方法
sublime代码高亮这么好看,怎么能不用sublime敲代码呢: ) 本人用的版本是sublime Text3中文版 在网上查了查,自己的sublime现在也能编译C++了,设置步骤如下: 1.找到 ...
- 利用多核来加速Linux命令行
本文转载自 多核CPU来加速 awk, sed, bzip2, grep, wc等,如需查看原文,请点此链接进入. -------------------------------我是分割线 开始 -- ...
- C++ 的template
vector的标准模板是:template<template<typename X, class allocator<X> > class T>而普通模板则是tem ...
- 输入与enter
#include<iostream> using namespace std; int main() { char a,b,c; while(scanf("%c%c%c" ...