Git Product home page Git Product logo

uaal-example's Introduction

Unity as a Library integration example to iOS and Android

In some scenario developers using native platform technologies (like Android/Java & iOS/Objective C) want to include in their apps/games features powered by Unity for 3D/2D Real Time Rendering, AR experience, interaction with 3D models, 2D mini games and more.

Starting with Unity 2019.3.0a2, Unity introduced a new feature to use Unity as a library in native apps by integrating the Unity runtime components and content in a native platform project. The Unity Runtime Library exposes controls to manage when and how to load/activate/unload within the native application.

Warning

Using Unity as a Library requires you have experience with developing for native platform technologies such as Java/Android, Objective C/iOS, or Windows Win32/UWP. You need to be familiar with the structure of the project, language features and specific platform configuration options (like user permissions for example).

Requirements

  • Android: Unity 6000.0.0b16 or higher
  • iOS: Unity 2021.3.28f1 or higher

Limitations

While we tested many scenarios for Unity as a library hosted by a native app, Unity does not control anymore the lifecycle of the runtime, so we cannot guarantee it'll work in all possible use cases. For example:

  • Unity as a Library supports rendering only full screen, rendering on a part of the screen isn’t supported.
  • Loading more than one instance of the Unity runtime isn’t supported.
  • You may need to adapt 3rd party Plug-ins (native or managed) to work properly
  • Overhead of having Unity in unloaded state is: 90Mb for Android and 110Mb for iOS

How it works

The build process overall is still the same, Unity creates the iOS Xcode and Android Gradle projects and generated iOS Xcode and Android Gradle projects have the following structure: A library part (iOS framework and Android Archive (AAR) file) that includes all source & plugins A thin launcher part that includes app representation data and runs library

Step by step explanations on how to include the iOS / Android library part into your native application when needed.

uaal-example's People

Contributors

emandravickas avatar jcunity avatar juliusmik avatar lusnys avatar manugildev avatar mindaugasv-unity avatar pavel-unity avatar todi1856 avatar vaidasma avatar veryhappyyoung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uaal-example's Issues

这个库能兼容iOS9么?

现有项目想把AR作为一个小功能集成进去,但项目最低得兼容iOS9,想通过判断系统版本来开放AR功能,但是集成UnityFramework这个库后在iOS11前的版本无法运行,以动态库的方式集成,状态也设置为Optional
dyld: Library not loaded: /System/Library/Frameworks/ARKit.framework/ARKit
Referenced from: /private/var/containers/Bundle/Application/725C2190-DC6B-4406-9F74-C84947D0BD50/GACClient.app/Frameworks/UnityFramework.framework/UnityFramework
Reason: image not found

Warning after gradle updated: Using `flatDir`

Hi,
I saw an issue in Android, after I updated AGP to 7.0.0. After compile, I see a warning that warns me not to use flatDir.
Using flatDir should be avoided because it doesn't support any meta-data formats.

image

Is there any alternative to this problematic block to prevent this warning?

MainUnityActivity doesn't show logs or trigger breakpoints

When trying to add functionality to the Android<->Unity interface and debug it, I cannot get a breakpoint to trigger or logs to show in the MainUnityActivity class. Even something as simple as onCreate. Can someone please explain to me how this class is used? It seems that it's being built during compile time..

Is there a way to have a constantly updating String shared between MainActivity and MainUnityActivity?

Bitcode issue on uploading tvOS app with Unity project merged into it.

Hi,

We've merged the tvOS and Unity project and are using unity as a library into the native tvOS application.

When we try to upload the build to TestFlight, it rejects stating that bitcode mismatch in tvOS and UnityFramework (image attached).

As TVOS does not expose bitcode settings, we tried setting bitcode on and off in UnityFramework, but still no luck.

Unity Version: Unity 2020.1.16f1 Xcode Version: 12.2

Any help would be much appreciated.

Screenshot 2020-12-23 at 10 47 40 PM

Unload, Activities stack and Back button

Hello everyone,

We have a use case where we need to execute Unity in the same process as the main app. So instead of killing the activity (and thus killing the process) we are unloading the UnityPlayer. However, by unloading the MainUnityActivity remains in the activities stack and the back button behaviour is broken as follows:

Let's say that our stack is as follows: A > B > C > MainUnityActivity. By unloading and going back to C our stack becomes A > B > MainUnityActivity > C. So when we click the back button MainUnityActivity is brought to the front of the stack again.

The UaaL solves this by overriding onBackPressed and explicity going to the previous activity each time. When it ends up in the "root" activity it calls finishAffinity which closes all remaining activities, including MainUnityActivity.
Our module will be integrated into apps with different structure that we can't control so we can't use the above workaround.

Is there a way to unload or kill the Unity Player and not alter the back button functionality?
We created an example project based on the UaaL example which shows the issue we are facing (see below). There are // NOTE: in a few places that provide information about the back button flow. The activity stack in the example is as follows: RootActivity > MainActivity > MainUnityActivity.

What we would like to achieve is to go back to RootActivity by only using the back button and without specifying any activities - like in the UaaL example.

Example project here.

Thank you,
Christos

Videos on Android are black using UaaL, works fine in pure Unity build.

Hi, I'm using UaaL with Unity 2020.3.14f1 and AR Foundation 4.1.7 and the video I'm trying to play is just a VideoClip using the Unity VideoPlayer component and it shows a black screen where the video should be. the video plays fine in an Android build built directly from Unity. In the logcat, it's spewing this message:

W/Unity: AndroidVideoMedia::OpenExtractor could not translate sharedassets0.resource to local file. Make sure file exists, is on disk (not in memory) and not compressed.
AndroidVideoMedia: Error opening extractor: -10004

I found it's similar to this issue playing video in compressed asset bundles, they have to be uncompressed.
https://issuetracker.unity3d.com/issues/android-loading-videos-from-assetbundles-fails-unless-its-uncompressed-and-loaded-from-file

So I'm wondering if it needs to be extracted and/or uncompressed first from sharedassets0? I did confirm there a workaround of putting the video in StreamingAssets and playing it from a URL. Not ideal but it works.
Thanks,
Alan

Getting bunch of errors while integrating unity as library into ios native project, in which both unity and native project contains Firebase libraries.

I have an iOS native project and a Unity project.

What i am trying to achieve? - On a button click from the native ios app, i want to show unity in which both the native and ios project contains firebase dependencies.
What i am actually getting? - When i try to run the app in xcode, i am getting following errors (almost 4000 similar error but for different Targets):
"Multiple commands produce '/Users/M_742794/Library/Developer/Xcode/DerivedData/MarkersLab-gpaeablwazuyowbfwysavwxcotrv/Build/Products/Debug-iphoneos/BoringSSL-GRPC/openssl_grpc.framework/Headers/cipher.h':

  1. Target 'BoringSSL-GRPC' (project 'Pods') has copy command from '/Users/M_742794/Developer/iOS/Development/iOS AR Build/Pods/BoringSSL-GRPC/src/include/openssl/cipher.h' to '/Users/M_742794/Library/Developer/Xcode/DerivedData/MarkersLab-gpaeablwazuyowbfwysavwxcotrv/Build/Products/Debug-iphoneos/BoringSSL-GRPC/openssl_grpc.framework/Headers/cipher.h'
  2. Target 'BoringSSL-GRPC' (project 'Pods') has copy command from '/Users/M_742794/Developer/iOS/Development/unity-AR-Build/Pods/BoringSSL-GRPC/src/include/openssl/cipher.h' to '/Users/M_742794/Library/Developer/Xcode/DerivedData/MarkersLab-gpaeablwazuyowbfwysavwxcotrv/Build/Products/Debug-iphoneos/BoringSSL-GRPC/openssl_grpc.framework/Headers/cipher.h'"

Steps i followed for unity integration to my native project -

  1. imported Firebase libraries like Auth, storage, firestore, core in unity and created an iOS build.
  2. Podfile has been generated after the build and i installed the firebase pods.
  3. I have added the Unity-iPhone.xcodeproj along with its Pods.xcodeproj to my native project workspace with the project structure as below(masked is my native xcodeproj):

Screenshot 2021-11-22 at 2 10 07 PM

4. followed the steps mentioned in this uaal link https://github.com/Unity-Technologies/uaal-example/blob/master/docs/ios.md properly like: 1. Added UnityFramework.framework to the native app general settings framework, libraries and embedded content and removed the same from Build phases Link binary with libraries section. 2. Added Unity-iPhone.xcodeproj's Data folder target membership to UnityFramework. 3. Added Unity-iPhone.xcodeproj's NativeCallProxy file target membership to UnityFramework with public access. 4. made code changes in native project to show unity on button click.
  1. I have firebase dependencies in my native xcode project as well as unity xcode project and the podfiles are as below:

    • Unity Xcode project Podfile: Screenshot 2021-11-22 at 2 22 36 PM

    • Native Xcode project Podfile: Screenshot 2021-11-22 at 2 23 02 PM

  2. I have installed the pods for both the projects and started building in xcode.

  3. The build is failing with number of "Multiple commands produce" errors: Error

  4. The errors might be causing due to firebase dependency in both native and unity projects but could not find proper solution for this issue.
    I am expecting solutions from this group for my problem, Thanks!

[Android] APK turning in two apps after install

I don't know if this is supposed to happen, but after doing eveything in the tutorials i end up getting two apps, the Native + Unity and the other contains only the Unity app with none of the native features/screens.
Is there a way to not have this second Unity only app installed together?

UnityPlayer Unload and Activities Stack

Hello everyone,

We have a use case where we need to execute Unity in the same process as the main app. So instead of killing the activity (and thus killing the process) we are unloading the UnityPlayer. However, by unloading the MainUnityActivity remains in the activities stack and the back button behaviour is broken as follows:

Let's say that our stack is as follows: A > B > C > MainUnityActivity. By unloading and going back to C our stack becomes A > B > MainUnityActivity > C. So when we click the back button MainUnityActivity is brought to the front of the stack again.

The UaaL solves this by overriding onBackPressed and explicity going to the previous activity each time. When it ends up in the "root" activity it calls finishAffinity which closes all remaining activities, including MainUnityActivity.
Our module will be integrated into apps with different structure that we can't control so we can't use the above workaround.

Is there a way to unload or kill the Unity Player and not alter the back button functionality?
We created an example project based on the UaaL example which shows the issue we are facing (see below). There are // NOTE: in a few places that provide information about the back button flow. The activity stack in the example is as follows: RootActivity > MainActivity > MainUnityActivity.

What we would like to achieve is to go back to RootActivity by only using the back button and without specifying any activities - like in the UaaL example.

Example project here.

Thank you,
Christos

'UnityFramework/UnityFramework.h' file not found

I followed the iOS example, and when I try to run the app, i get the above error in
NativeiOSApp > NativeiOSApp > MainViewController.mm > line 4
#include <UnityFramework/UnityFramework.h>

This is for xcode 11.2
Any help would be appreciated!

[Android-Bug] Clicked the Show Unity Button is crash

I tried to change the gradle version to 3.x.x and it is working.
But the new project of Android Studio 4.x does not work properly.

And tried the following solutions but it still does not work:
f111fei/react-native-unity-view#142 (comment)

Info

build.gradle(PROJECT:APP):

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 28
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.cell.ardemo2"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation project(':unityLibrary')
    implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

build.gradle(PROJECT):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Log:

2020-10-31 20:09:20.061 4569-4569/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.cell.ardemo2:Unity, PID: 4569
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libmain.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
        at java.lang.System.loadLibrary(System.java:1664)
        at com.unity3d.player.UnityPlayer.<clinit>(Unknown Source:13)
        at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
        at com.company.product.OverrideUnityActivity.onCreate(OverrideUnityActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

iOS Unity not quitting properly

I am currently using UaaL for our Xamarin app. I got everything working instead of a standard quit Unity action.

If I use UnityFramework.QuitApplication. It doesn't just quit Unity. It closes the entire app. When I use UnityFramework.UnloadApplication it just unloads Unity and stops working. But also won't go back to the main page of the iOS app I set up.

I have a button on my app home page that launches Unity. And I have a button that should close Unity again when pressed. And then it should go back to my app home page. But it doesn't, as I explained above.

Is there a way to do this properly?

Remove the second icon

The read.me says
After installation there will be two icons added on the device. To leave only the icon of the main activity, remove ... from the AndroidManifest.xml in unityLibrary

What do the "..." mean exactly?

Unity as a library iOS export build issue

I'm having issues just building the exported iOS project to use as a framework, I'm getting the following error:

Undefined symbols for architecture arm64:
  "__ex_callSwiftMethod", referenced from:
      _AppDelegate__ex_callSwiftMethod_m9ACE99169389609201934BB0583C0D7FB94120F9 in Assembly-CSharp.o
      _AppDelegate_CallSwiftMethod_mA359D3C6DD1D01A6B3FFF3305156B1A426AC9C4B in Assembly-CSharp.o
     (maybe you meant: _AppDelegate__ex_callSwiftMethod_m9ACE99169389609201934BB0583C0D7FB94120F9)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried with 2019.3.0f6 and 2019.3.2f1 but to no avail, I had previously had a working project using 2019.3.0f2 but can't see any changes in the newer versions changelogs

Could it be related to derived data?

    cd /Users/me/apps/new-game/client/ios/iosUnityBuild
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-ios11.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -L/Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Products/ReleaseForRunning-iphoneos -L/Users/me/apps/new-game/client/ios/iosUnityBuild/Libraries -F/Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Products/ReleaseForRunning-iphoneos -filelist /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework.LinkFileList -install_name @rpath/UnityFramework.framework/UnityFramework -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -map -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/UnityFramework-LinkMap-normal-arm64.txt -dead_strip -Xlinker -object_path_lto -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework_lto.o -fembed-bitcode-marker -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -weak_framework CoreMotion -weak-lSystem -liPhone-lib -framework Security -framework MediaToolbox -framework CoreText -framework AudioToolbox -weak_framework AVFoundation -framework AVKit -framework CFNetwork -framework CoreGraphics -framework CoreMedia -weak_framework CoreMotion -framework CoreVideo -framework Foundation -framework OpenAL -framework OpenGLES -framework QuartzCore -framework SystemConfiguration -framework UIKit -liconv.2 -lil2cpp -weak_framework Metal -Xlinker -dependency_info -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework_dependency_info.dat -o /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-crexctbdpabsmpbeobadidyfheya/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/UnityFramework```

crash

Process Name: 'com.timedomain.ace'
Thread Name: 'single-pool-1-t'
pid: 5918, tid: 8993 >>> com.timedomain.ace <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000000000000
x0 0000000000000000 x1 00000000142d613c x2 000000007f080426 x3 0000000000000000
x4 00000000ffffffff x5 0000000000000001 x6 0000000000000000 x7 0000000000000000
x8 0d30ee5b7e30aec2 x9 0d30ee5b7e30aec2 x10 0000000000000001 x11 0000007546768018
x12 0000000000001118 x13 7765695672656c63 x14 0000000000000000 x15 0000000000000000
x16 0000000000000000 x17 0000000000000bc7 x18 0000000000000001 x19 0000007529e26c00
x20 0000000000000000 x21 00000000145ae030 x22 0000000070d6c898 x23 0000000070d767e0
x24 0000000070d8a678 x25 0000000000000000 x26 0000000014090ee0 x27 0000000013f9a910
x28 0000000000000000 x29 0000000000000000 x30 000000009c38de64
sp 000000749bba97e0 pc 000000009c38de68 pstate 0000000080000000
v0 00000000000000000000000000000001 v1 00000000000000000000000000000000
v2 00000000000000000000000000000001 v3 00000000000000000000000000000004
v4 000000000000000000000000000003e0 v5 00000000000000000000000000000004
v6 000000000000000000000000000003e1 v7 000000000000000000000000000043e1
v8 00000000000000000000000000000001 v9 00000000000000000000000000000000
v10 00000000000000000000000000000000 v11 00000000000000000000000000000000
v12 00000000000000000000000000000000 v13 00000000000000000000000000000000
v14 00000000000000000000000000000000 v15 00000000000000000000000000000000
v16 00000000000000000000000000000000 v17 000000000000000000000000000043e0
v18 00000000000000000000000000000000 v19 0000000000000000000000003fa47ae2
v20 00000000000000000000000000000000 v21 00000000000000000000000041800000
v22 0000000000000000ab6529087994da10 v23 000000000000000000000000c16d9168
v24 000000000000000000000000ebad8088 v25 000000000000000000000000ebad8089
v26 000000000000000000000000ebad808a v27 000000000000000000000000ebad808b
v28 000000000000000000000000ebad808c v29 000000000000000000000000ebad808d
v30 000000000000000000000000ebad808e v31 000000000000000000000000764a70ec
fpsr 0800001b fpcr 00000000
#00 pc 000000000006ae68 /dev/ashmem/dalvik-jit-code-cache (deleted)
#1 pc 000000000006ae60 /dev/ashmem/dalvik-jit-code-cache (deleted)

[Android] App crashed when click on "Show Unity"

Hello everyone,

When I run the app on my device (Android) with Android Studio and with the full example folder everything works fine.

But when I start a very new project or when i'm using those folders (https://github.com/Unity-Technologies/uaal-example) and follow all the steps, when I run the app and click on "Show Unity" the app crashed every time and without any errors....

When I look to the UnityProject folder there is a lots of differences between "mine" and the full example folder. And I don't understand why, I'm using the same Unity version....

Is there some steps missing in the construction/strucutre of the UnityProject folder ?? Why are there so different ?

I have read that some people got the same issue than me in the unity forum, but I haven't seen any answers.

Any help will be very welcome !
Thanks !

Split binary functionality?

My unityLibrary folder is now 175 MB.
Is there a possibility to split it into an OBB and still get the UnityLibrary?

Application.quit is quitting whole native app

Hi Team,

i have integrated unity as a library in native swift project and it is working fine but there is a problem on close button as i have used Application.quit on close button and it closes the whole native app. But i want only unity app should close and when again click on showUnity then unity app should initialise properly but it closes whole native app.

Please help me to resolve this issue.

Seek some articles explaining how it work

Hi, bros!
I want to Seek some articles explaining how android calls Unity's interface in the repository and how the Cube is displayed.
I opened the Unity project, but I could not see the Cube inside.
I am new to Unity, and I could not find an article explaining how it works on the Internet.
Can you recommend some to me?

Unity lib with multiple scenes?

Is it possible to have multiple scenes in an unity lib? I don't want to merge those scenes. On click of button one of my native iOS app I want to open Scene1 of unity. On click of button two of my native iOS app I want to open Scene2 of unity and so on.

Does someone knows how to do it in Swift, Java or Kotlin? I don't understand objective c.

App Crash

1 、When unity platform send "Application.Unload" command, iOS Platform received callback message "- (void)unityDidUnload:(NSNotification*)notification " and App will Crash.
2、 When unity Platform send a "__Internal method" and told iOS to dismiss unity page,iOS will call "unloadApplication:true" method and app will crash .

3 There is crash report info on below ,please help:
UnityFramework was compiled with optimization - stepping may behave oddly; variables may not be available.

Xamarin support for Android and iOS

Hi, I tried the example and it works very well with Android Studio and XCode. I've tried to create an Xamarin.Android project to use Unity in Xamarin. I created the unityLibrary-release.aar from the example and used it in Xamarin Bindings. It seems to work. Unfortunatelly if I try to start the MainUnityActivity it doesn't start Unity, it crahes.
I think it would be a great think for the Xamarin community, if we could, like in the example, to start and manipulate a Unity Game from Xamarin.

UnityAndroidApp2.zip

is it possible to switch the screen from Unity to Android(activity )or ios(viewcontroller)?

Hi Unity forks

Due to changes in uaal function, Native->Unity->Native case understands through samples

Thanks very much It’s very love it :)

But is it possible if we move from Starting with the Unity screen to Android or each custom screen of ios?

Android
Unityplayeractivity -> nativeactivty
Back to unity

IOS
Unity viewcontroller-> native viewcontroller back to unity

Maybe it should be called as a plugin, right? , Or is it impossible?

Thanks
Best regards
Derrick

Android : keep unity player always alive

How can we avoid unity player restarting itself , every time the MainUnityActivity is started?

My activity flow is somewhat complex. There are two possiblites of opening unity:

  1. List View -> Unity
  2. List View -> List View -> Unity

Every time unity starts, I want it to resume the earlier state.
On iOS, there is a way to just hide unity with method "hideUnityWindow"? Is there such a possibility on Android or any other way to achieve my scenario?

Error on Build, after adding ARCore XR Plugin / ARFoundation package via Unity Package Manager.

Hi. My goal was to set up an AR scene that will be used in a native app.

First of all I had trouble building and running the native app after following the article
https://github.com/Unity-Technologies/uaal-example/blob/master/docs/android.md

but I solved it by making sure target architecture ARMv8 was enabled in Unity Player Settings.

Next, I added the package ARFoundation, and also ARCore XR Plugin, latest preview version 3.1.0-preview-8

Exported from Unity.
I got an error that libmain.so is missing, so I had to add ARMv8 and switch to IL2CPP scripting backend, to let it copy the libmain.so into the appropriate folder, it only copied for ARMv7 before that. (I had to do this twice for some reason.... deleting the folder where I exported the android project and exporting again fixed it)

Then I got some other weird errors when building in Android Studio:
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':unityLibrary:javaPreCompileDebug'.

Could not resolve all files for configuration ':unityLibrary:debugCompileClasspath'.
Failed to transform artifact 'ARPresto.aar (:ARPresto:)' to match attributes {artifactType=android-classes, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: D:\Unity\superwe-app\androidExport\unityLibrary\libs\ARPresto.aar.
> entry
Failed to transform artifact 'UnityARCore.aar (:UnityARCore:)' to match attributes {artifactType=android-classes, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: D:\Unity\superwe-app\androidExport\unityLibrary\libs\UnityARCore.aar.
> entry

Solution was to go in build.gradle (Project: NativeAndroidApp) and change the gradle version to
classpath 'com.android.tools.build:gradle:3.1.4'
instead of 3.6.1 which is the latest.

Rebuild and it worked.

I may have had to copy a file manually before this worked though, and I can't remember the order when I did it, but here it is:
the file OverrideUnityActivity.java from the Unity project, in Plugins/Android/ (weird cause it was marked as an Android native plugin but it was still not copied).
had to go in the folder unityLibrary/src/main/java/com/company/product/
as per another closed issue reported here in this repo:
#14

The issue I'm reporting is that I had to do this stuff manually when I was expecting it to "just work" when I add the ARCore package. Also it's weird it doesn't work with the latest gradle.

Hope this helps someone.

Improvement for real-world applications

Hey, thanks for the sample!

I think there is something where everyone struggles though: making the app work in a real application context, i.e.,

  • Unity runs in the background window
  • UI is in the foreground window
  • Events that do not go through foreground windows are forwarded to the background window.

I know that it already kind of works, but it still seems weird to me. There is a window right now that simply host nothing.
The views are added directly as a child of the UnityView, which will not work at all with stuff like SwiftUI.

Cannot find OverrideUnityActivity class

Following the instruction , this project crash with this error:

/Users/admin/Desktop/uaal-example-master/NativeAndroidApp/app/src/main/java/com/unity/mynativeapp/MainUnityActivity.java:10: error: package com.company.product does not exist
import com.company.product.OverrideUnityActivity;

changing MainUnityActivity with: import com.unity.mynativeapp.OverrideUnityActivity; same error..

AndroidX seems to break the player

Hope this isn't a bad place to ask this.

I tried to migrate the project to AndroidX using the instructions Flutter provides here

The project then builds, but when I try to load Unity the whole app crashes. How do I handle this?

How to show unity's object in android?

Hi, I'd like to show unity's objects in android.

In this tutorial, for example, I'd like to show a cube object in the android main layout like below.
Is there any idea?

image

Failed to make uaal work with IL2CPP scripting backend. Any ideas?

I tried to export unity project with ARFoundation + 2020 LTS + IL2CPP scripting backend to Android Studio (I assume that it should be working because I encountered actual working examples). It seems that IL2CPP requires .cpp code to be generated before actual build. Unfortunately, generated .c code has links to .h files, but files themselves are missing.

Is that a known issue or some additional context is needed?

Option to build unityLibrary as an AAR

We have an AR Android app that embeds the exported unityLibrary using AR Foundation. For our Unity developers the build process works great. However not all of our Android developers are set up to use Unity which is required to be installed in order to build the android app.

Is it possible to add a post-build script to Unity which builds the unityLibrary into an aar which can then be imported into the native Android app. This way Android developers can easily just clone the repo without having to first install the proper version of Unity just to build the section of the app that they do not develop.

Android apk or aab file limitation

Play store has limitations for apk(100mb) and aab(150mb) files. How can we handle if aab file is over 150mb on native android project? Can we use Play asset delivery or dynamic feature?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.