Anyone know integrate Android with Unity Studio? (i will explain)
I created a simple scene in Unity (4.3.x on OSX Maverics) for testing. Has a 3D object and nothing els
For open a Android Studio project from Unity3D
inside Android studio
as march 2016 you need to File -> New -> Import
and let the thing do his work.
Or if you have the quick start window:
Setting up an Android project is really simple. The document you linked is outdated and you don't need to move any files at all.
Unity
File -> Build Settings -> Android
and click Switch Platform
Google Android Project
Export
and choose where you want the Android project to beAndroid Studio
If you want to display the Unity engine inside a subactivity, I suggest you take a look at this answer.
If you're completely unfamiliar with Android development, you should start with a simple "Hello World" app without complicating things by adding Unity to the mix. Just follow some of the official Android guides.
I integrated a Unity project to an Android application.
I had a simple activity with a button created using Android Studio.
On clicking this button the Unity scenes will start.
The android project exported from unity should like this:
It needed to be converted to Gradle project first.
For that:
Now your unity project folder looks like this:
Now open your project and do the following to import the unity project in to your project:
Verify in Settings.gradle file to see if the new module name is added in the include command:
include ':app', ':yournewmodulename’
Open build.gradle file of the new unity module from navigation window and rename the below line:
apply plugin: 'com.android.application'
to
apply plugin: 'com.android.library'
Remove the line from the defaultConfig section of the new unity module:
applicationId "com.xxx.xxx"
Open Manifest of this new unity module and comment the application tag (Do not remove the uses-sdk tag).Integrate the new unity module's Manifest with your project’s Manifest by moving necessary tags to our project’s Manifest (e.g. :Activity, uses-feature etc.).
Open build.gradle of your project and add below line in the dependencies section:
dependencies {
…
compile project(path: ':yournewmodulename')
}
Now on button click you can call the Activity in the unity module from your activity as below:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.xxx.xxx.UnityPlayerActivity;
public class MainActivity extends AppCompatActivity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button= (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, UnityPlayerActivity.class);
startActivity(i);
}
});
}
}