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应用

时间: 2024-08-04 10:36:32

unity3d与eclipse集成开发android应用的相关文章

5.Eclipse集成开发环境

5.Eclipse集成开发环境 Eclipse集成开发环境不仅可以编译裸机工程,还可以调试整个裸机工程,这样当程序异常的时候,可以更加有效的进行修改.接下来就是搭建整个eclipse集成环境:这个调试环境的框架如下图1-1: 图1-1 从上面的框架图看到,要实现eclipse在线调试裸机程序,需要安装的软件是eclipse+CDT.JLink驱动.GDB调试软件,需要连接的硬件是JLink连接pc机和开发板. 注意:为了避免干扰,最好对NandFlash进行格式化:图1-2: 然后选择y: 图1

[国嵌笔记][019][Eclipse集成开发环境]

Eclipse集成开发环境的作用 可以编译程序,也可以对程序进行在线调试 集成开发环境 1.JLink连接开发板的JTAG 2.JLink连接PC的USB 3.eclipse软件 4.gdb server软件 5.JLink软件 安装步骤 1.格式化nand flash 2.连接JLink,并设置从nand flash启动 3.安装gdb server软件 1.tar zxvf linux-gdb-7.5.tar.gz 2.执行./build-all,编译gdb server软件,然后安装软件

Eclipse集成开发环境搭建之Java、Python

这里就以Eclipse为例,说明Java集成开发环境的搭建. 第一步,下载安装JDK,配置环境变量,这里就不多重复了.需要提到的是,JDK.Eclipse要同为Windows 32位或Windows 64位,这里选择的均为64位: 第二步,下载Eclipse.到Eclipse下载页面http://www.eclipse.org/downloads/选择合适的版本,这里选择的是Eclipse IDE for Java EE Developers,Windows 64位版本,按提示下载压缩包ecli

在Eclipse中开发Android程序时截屏的方法

在Eclipse中调试Android程序时,有时需要将程序截图保存到电脑中.步骤如下: Window --- Show View --- Other : 在弹出的窗口中,选择 Devices : 在打开的Device选项卡中,选择要截图的设备或模拟器,然后点击旁边的截图按钮: 在弹出的窗口中,点击 Save 按钮,将程序截图保存到指定的目录中即可.

【PyQt5】QT designer + eclipse 集成开发

[写在前面的话] 考虑将pyqt5的界面开发qt designer 集成在eclipse中,并且,不利用cmd命令行进行转换. [工具] 1.pyqt5 2.qt designer 3.eclipse +pydy [步骤] 1.首先配置Qt designer. 菜单 run-->external Tools-->External tools configurations 2.在Program 中new 一个新项目 3.配置PyUIC,如图2所示: ******但是这里有个问题,最后转换的py文

eclipse中开发android程序。每次运行都自动打开新的avd模拟器。怎么才能下次运行时用已经打开的?

选择 run configuration -> target -> Automatic -> 在 launch a new Android Virtual Device 选择你需要的版本启动,等待启动完成如果启动后,Choose a running Android device里没有出现选择项运行 cmd 运行命令 adb kill-server 然后 eclipse 控制台(Console)出现 Adb connection Error:远程主机强迫关闭了一个现有的连接.等待 Conn

1.5 Eclipse集成开发环境

1. 格式化nandflash PATH路径优先用前面的 Arm-linux-gdb ? # .bashrc ? # User specific aliases and functions ? alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' ? # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi export PATH=$PATH:/opt/arm-

Eclipse集成开发环境搭建

gdbserver安装: 安装gdb-server的环境变量要放在arm-linux-gcc的环境的前面,因为arm-linux-gcc的安装包里面也有gdb,linux系统在找指令时从/root/.bashrc里面从上而下找指令的 Jlink for linux 安装 解压安装包就不再叙述,下面是拷贝几个文件的指令 cp -d libjlinkarm.so* /usr/lib -f cp 45-jlink.rules /etc/udev/rules.d/ 最后输入./JLinkGDBServe

在Eclipse集成开发平台中利用XFire框架发布Webservice

一.正所谓"工欲善其事,必先利其器",下面就先来配置运行环境吧! 下载xfire-distribution-1.2.6.zip压缩包到本地,解压后将xfire-all-1.2.6.jar和lib文件夹里面的jar放到同一个文件夹xfirejars中. 下载安装tomcat并关联的Eclipse工程中,这个就认为大家都懂,不多说了. 打开eclipse,点击File->New->Dynamic Web Project,新建工程FirstWebService 鼠标在FirstW