首页 > 代码库 > 因为项目需要使用Unity提供的接口,所以需要将接口classes.jar引入
因为项目需要使用Unity提供的接口,所以需要将接口classes.jar引入
Unity for Android 比较特殊,Unity for IOS 打包是将XCODE工程直接交给开发者,开发者可以在工程
的基础上继续添加新的视图,最后由开发者自行打包生成IPA包,发布程序。而Unity for Android打包
直接生成APK包,等于说源代码开发者是看不到的,但是Unity的自身确实有些局限,针对Android平台我
们需要学习如何在Unity中调用Android的JAVA代码。本章我们的目标是使用Unity的脚本打开Activity。
首先我们创建一个普通的Android工程,目录结构如下图所示。
因为项目需要使用Unity提供的接口,所以需要将接口classes.jar引入至当前工程但中。接口
包的所在地,打开Finder->应用程序->Unity->点击Unity图标,鼠标右键选择“显示包内容
”->Contents->PlaybackEngines->AndroidPlayer->bin->classes.jar 。接口包引入工程后,开
始编写JAVA代码。
UnityTestActivity.java
http://www.qdmm.com/BookReader/1163793,22685467.aspx
http://www.qdmm.com/BookReader/1163793,22685479.aspx
http://www.qdmm.com/BookReader/1163793,22699652.aspx
http://www.qdmm.com/BookReader/1163793,22719361.aspx
http://www.qdmm.com/BookReader/1163793,65455160.aspx
http://www.qdmm.com/BookReader/1163793,65455311.aspx
http://www.qdmm.com/BookReader/1163793,65455315.aspx
http://www.qdmm.com/BookReader/1163793,65455341.aspx
http://www.qdmm.com/BookReader/1163793,65455366.aspx
http://www.qdmm.com/BookReader/1163793,65455374.aspx
http://www.qdmm.com/BookReader/1163793,65455420.aspx
http://www.qdmm.com/BookReader/1163793,65455438.aspx
http://www.qdmm.com/BookReader/1163793,65455443.aspx
http://www.qdmm.com/BookReader/1163793,65455459.aspx
http://www.qdmm.com/BookReader/1163793,65455463.aspx
http://www.qdmm.com/BookReader/1163793,65455464.aspx
http://www.qdmm.com/BookReader/1163793,65455468.aspx
http://www.qdmm.com/BookReader/1163793,65455471.aspx
http://www.qdmm.com/BookReader/1163793,65455475.aspx
http://www.qdmm.com/BookReader/1163793,65455483.aspx
http://www.qdmm.com/BookReader/1163793,65455486.aspx
http://www.qdmm.com/BookReader/1163793,65455491.aspx
http://www.qdmm.com/BookReader/1163793,65455494.aspx
http://www.qdmm.com/BookReader/1163793,65455498.aspx
http://www.qdmm.com/BookReader/1163793,65455503.aspx
package com.xys; import android.content.Context; import android.content.Intent;
import android.os.Bundle; import com.unity3d.player.UnityPlayerActivity; public
class UnityTestActivity extends UnityPlayerActivity { /** Called when the activity is
first created. */ Context mContext = null; @Override public void
onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
?
因为项目需要使用Unity提供的接口,所以需要将接口classes.jar引入