团结和Eclipse的集成 [英] Integration of Unity and Eclipse

查看:185
本文介绍了团结和Eclipse的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助与整合统一到Eclipse中一点点

Hey guys I need a little bit of help with integration of Unity into Eclipse

我的参考页是=> 这里

我有Unity3D专业版和Android插件专业版

I have Unity3D Pro version and Android Plugin Pro Version

  • 设置您的统一Android项目,你通常会击中 构建。
  • 输入您的项目文件夹,进入温度/ StagingArea。
  • 在所有项目文件复制到一个新的文件夹。
  • 在导入此文件夹Eclipse的一个新的Andr​​oid项目。
  • 标记此项目为在属性窗口中的库 项目。 (右键点击项目名称,进入属性 - > Android的 和标记库。)
  • 创建Eclipse的一个新的Andr​​oid项目。这将构成 项目的Java的一部分。
  • 添加统一的Andr​​oid项目作为库到新的项目。 (右键点击项目名称,进入属性 - > Android的选择 添加...,添加项目。)
  • 添加classes.jar库到库引用为新 项目。 (在性能,去Java_Build_path->库,选择 添加外部JAR ...,定位到 UNITY_INSTALLATION \编辑\ DATA \ PlaybackEngines \和roidplayer \ bin和 添加classes.jar)
  • Set up your Unity Android project as you would normally and hit Build.
  • Enter your project folder, go to Temp/StagingArea.
  • Copy all project files to a new folder.
  • Import this folder as a new Android project in Eclipse.
  • Mark this project as a library in the properties window for the project. (Right click on the project name, go to Properties->Android and mark "Is Library".)
  • Create a new Android project in Eclipse. This will constitute the Java part of your project.
  • Add the Unity Android project as a library to your new project. (Right click on the project name, go to Properties->Android, select "Add...", add the project.)
  • Add the classes.jar library to the Library references for your new project. (In properties, go to Java_Build_path->Libraries, select "Add External Jar...", navigate to UNITY_INSTALLATION\Editor\Data\PlaybackEngines\and roidplayer\bin and add classes.jar)

现在,如果我运行这个小项目到我的设备我得到这样的事情

By now, If I am running this little project into my device I get something like this

您可以看到该链接的图片。

You can see the picture from this link.

https://copy.com/vVaCyQTEUECV

接下来的步骤是这样的:

The next Step is this:

  • 从库项目到新项目将资产文件夹。 (机器人不允许在库被利用的资产,而这 最后一步要重复每当统一项目重建。)
  • Move the assets folder from the library project to the new project. (Android does not allow assets to be utilized in libraries, and this last step has to be repeated whenever the Unity project is rebuilt.)

我从库项目到新项目移动资产的文件夹和资源的文件夹。

I am moving the asset folder and the res folder from the library project to the new project.

在这之后,我从图书馆移动AndroidMnifest.xml和更换项目

After that I am moving the AndroidMnifest.xml from the library and replacing in the project

这是从MainActivity.java我的code

This is my Code from MainActivity.java

package com.Developer.PackMan;

import com.unity3d.player.UnityPlayerNativeActivity;


import android.os.Bundle;

public class MainActivity extends UnityPlayerNativeActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

}
}

这是的Manifest.xml

And this is Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Developer.PackMan" android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
  </application>
  <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-feature android:name="android.hardware.sensor.accelerometer" />
</manifest>

在我建立它,我得到一个错误以下列文本

After I am building it i got an error with the following text

应用程序)过程com.Developer.Packman)意外停止,请重试。

The application )process com.Developer.Packman) has stopped unexpectedly please try again.

现在的问题是,我没有得到任何形式的LogCat中或者控制台错误的,一切都清楚了。

The problem is that I am not getting any kind of Errors in LogCat or Console, everything is clear.

我真的需要你的帮助。谢谢你。

I really need your help. Thank you.

推荐答案

对于一个应用程序,它具有同时显示Unity3d和普通的Andr​​oid UI,我写了一个导游为我备将来使用。 AFAIR它是基于Unity3d版本4.3。我希望这是不够详细:)

For an app which has to show both Unity3d and regular Android UI, I wrote a guide for my future use. AFAIR it's based on Unity3d version 4.3. I hope it's detailed enough :)

根据链接: <一href="http://forum.unity3d.com/threads/98315-Using-Unity-Android-In-a-Sub-View/page4?p=1477830&viewfull=1#post1477830">http://forum.unity3d.com/threads/98315-Using-Unity-Android-In-a-Sub-View/page4?p=1477830&viewfull=1#post1477830

<一个href="https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse">https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse

pre-设置:

为了能开始整合Unity3d和Android,你需要找到'...团结\编辑\ DATA \ PlaybackEngines \ androidplayer \ BIN'的classes.jar文件。你可以把它放在你的工作空间目录。

In order to start integrating Unity3d and Android you need the classes.jar file found in '...Unity\Editor\Data\PlaybackEngines\androidplayer\bin'. You can place it in your workspace directory.

设置:

  1. 在开始与Android项目将包含所有的Andr​​oid 位。
  2. prepare的Unity3d Android项目。导入统一项目 到工作区就像一个普通的Andr​​oid项目。
  3. 在人民币上的统一的项目,然后单击属性,然后进入机器人,并勾选是 图书馆?复选框。
  4. 人民币对Android项目,然后单击属性,然后进入机器人,然后单击添加来添加库 - 统一计划 - 到Android之一。
  5. 仍然在属性对话框,进入Java构建路径,然后选择库选项卡。 在那里,点击添加外部JAR并导航到classes.jar 文件。
  6. 确保这两个项目的目标相同的SDK。
  7. 从统一项目进入Android项目将资产文件夹中。这一步 已在您的统一项目重建每次重复。
  1. Start with an Android project which will contain all the Android bits.
  2. Prepare the Unity3d Android project. Import the Unity project into your workspace like a regular Android project.
  3. RMB on the Unity project, click "Properties", then go to "Android" and tick the "Is Library?" check box.
  4. RMB on the Android project, click "Properties", then go to "Android" and click "Add" to add a library - the Unity project - to the Android one.
  5. Still in the "Properties" dialog, go to "Java Build Path" and select the "Libraries" tab. There, click "Add external JAR" and navigate to the classes.jar file.
  6. Ensure both projects target the same SDK.
  7. Move the "assets" folder from the Unity project into the Android project. This step has to be repeated each time your Unity project is rebuilt.

编码:

本指南假设你的目标是拥有一个Android活动,这将同时显示一个统一的模型和规则的Andr​​oid UI。

This guide assumes your goal is to have an Android activity which will display both a Unity model and regular Android UI.

  1. 添加以下行项目的清单文件的基础:'
  2. 添加清单中的以下行来这是为了遏制统一模型的活动:。这使得触摸事件被传递到既统一模型和常规机器人的UI。
  3. 请在活动延长UnityPlayerActivity,而不是活动。
  4. 请不要加直的onCreate()了的setContentView - 这会导致不必要的行为 - 在我的情况的统一模式是非常小的,无法与互动;相反,在onResume()找到UnityPlayer对象的父视图和它膨胀的布局,并添加所有其他UI元素。请注意,它可能是发现了上述观点可能需要在一个单独的线程中完成的。

故障排除:

  • 在类延伸UnityPlayerActivity NoClassDefFoundException(或类似):去你的Andr​​oid项目的Properties(属性),那么Java构建路径 - >订单与出口和刻度classes.jar(在我的情况下,它是在列表中,如果是顶部有什么差别)。 preSS确定,清理项目,尝试再次运行并祈祷...
  • 在多个DE​​X文件定义LCOM / unity3d /播放/ nativeloader - 确保在Unity项目不包含团结 - classes.jar文件中的库目录
  • (不知道,但值得一试)src文件夹中的问题 - 删除src文件夹中的内容

下面是一些示例code来说明活动持有的Unity3d对象:

Here's some sample code to illustrate the Activity which holds the Unity3d object:

private Button buttonChangeColour;
private UnityPlayer unityPlayer = null;

@Override
public void onResume() {

    super.onResume();

    if (unityPlayer == null) {

        View rootView = findViewById(android.R.id.content);
        unityPlayer = findUnityPlayerView(rootView);

        if (unityPlayer != null) {

            ViewGroup unityPlayerParentView = (ViewGroup)(unityPlayer.getParent());
            View mainHomeView = getLayoutInflater().inflate(R.layout.activity_home, null);
            LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            unityPlayerParentView.addView(mainHomeView, layoutParams);

            buttonChangeColour = (Button) findViewById(R.id.buttonChangeColour);
            buttonChangeColour.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    // [...]
                }
            });
        }
    }
}

private UnityPlayer findUnityPlayerView(View view) {

    if (view instanceof UnityPlayer) {

        return (UnityPlayer) view;
    }
    if (view instanceof ViewGroup) {

        ViewGroup childrenViews = (ViewGroup) view;

        for (int i = 0; i < childrenViews.getChildCount(); i++) {

            UnityPlayer foundView = findUnityPlayerView(childrenViews.getChildAt(i));

            if (foundView != null) {

                return foundView;
            }
        }
    }

    return null;
}

这篇关于团结和Eclipse的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆