Giter Site home page Giter Site logo

juicycleff / flutter-unity-arkit-demo Goto Github PK

View Code? Open in Web Editor NEW
226.0 12.0 77.0 29.9 MB

This demo uses flutter unity view widget to show AR KIT with Unity3D

Java 0.21% Ruby 1.24% Swift 0.25% Objective-C 5.12% Dart 3.56% C# 88.73% ShaderLab 0.88%
unity3d flutter flutter-unity-view-widget demo arkit

flutter-unity-arkit-demo's Introduction

flutter_unity_widget ARKIT DEMO

Demonstrates how to use the flutter_unity_widget plugin with Unity3D ARKIT using the Unity Foundation Demo.

Run the sample on Android

  1. Open the unity project and build it: Menu -> Flutter -> Export Android
  2. Copy android/UnityExport/libs/unity-classes.jar to android/unity-classes/unity-classes.jar and overwrite the existing file. You only need to do this each time you use a different Unity version.
  3. flutter run

Run the sample on iOS

  1. Open the unity project and build it: Menu -> Flutter -> Export iOS

    Be sure you use at least Unity version 2019.3 or up.

  2. open ios/Runner.xcworkspace (workspace!, not the project) in Xcode and add the exported project in the workspace root (with a right click in the Navigator, not on an item -> Add Files to "Runner" -> add the UnityExport/Unity-Iphone.xcodeproj file

  1. Select the Unity-iPhone/Data folder and change the Target Membership for Data folder to UnityFramework

  1. flutter run

flutter-unity-arkit-demo's People

Contributors

juicycleff 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

flutter-unity-arkit-demo's Issues

Run Example

Hello, I tried to run your example of AR. But I can't

Can you help me?

The log of flutter run is:

Launching lib/main.dart on Redmi Note 8 in debug mode...
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':flutter_unity_widget:generateDebugRFile'.

Could not resolve all task dependencies for configuration ':flutter_unity_widget:debugRuntimeClasspath'.
Could not find :ARPresto:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :UnityARCore:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :UnityAds:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :UnityAdsAndroidPlugin:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :arcore_client:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :unityandroidpermissions:.
Required by:
project :flutter_unity_widget > project :UnityExport

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Finished with error: Gradle task assembleDebug failed with exit code 1

Example crashing iOS

hello please help me. I have desperately been trying to get the example to run on iOS. The app launches, but when the app navigates to the WithARkitScreen widget it crashes. I don't get an error message or a stacktrace. Please help ...

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G2021, locale en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1)
[✓] VS Code (version 1.48.0)
[✓] Connected device (1 available)

• No issues found!

Running unity 2019.3.0b7

Android compile issue

After following the directions in the readme, when I go to run on my android device, I get the following:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':flutter_unity_widget:generateDebugRFile'.
> Could not resolve all task dependencies for configuration ':flutter_unity_widget:debugRuntimeClasspath'.
   > Could not find :ARPresto:.
     Required by:
         project :flutter_unity_widget > project :UnityExport
   > Could not find :UnityARCore:.
     Required by:
         project :flutter_unity_widget > project :UnityExport
   > Could not find :arcore_client:.
     Required by:
         project :flutter_unity_widget > project :UnityExport
   > Could not find :unityandroidpermissions:.
     Required by:
         project :flutter_unity_widget > project :UnityExport

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
Finished with error: Gradle task assembleDebug failed with exit code 1

Gradle Error

When i export the app from unity and try to run it i get this error
Norma Flutter widget project works fine
WhatsApp Image 2020-12-05 at 4 30 13 PM

using unity 2019.3.5f

How to place an existing gameObject in AR Scene?

Instead of dragging prefab into the inspector and instantiating it, how can I place a gameObject in AR scene.

Below is my code:

[SerializeField]
 private GameObject placedPrefab;

 [SerializeField]
 private GameObject placedObject;

 [SerializeField]
 private ARPlaneManager arPlaneManager;

 void Awake() 
 {
     dismissButton.onClick.AddListener(Dismiss);
     arPlaneManager = GetComponent<ARPlaneManager>();
     arPlaneManager.planesChanged += PlaneChanged;
 }

 private void PlaneChanged(ARPlanesChangedEventArgs args)
 {   
     if(args.added != null && placedObject == null)
     {
         ARPlane arPlane = args.added[0];
         //placedObject = Instantiate(placedPrefab, arPlane.transform.position, Quaternion.identity);
         placedPrefab.transform.position = arPlane.transform.position;
     }
 }

Xcode 11.4.1: error "Please resolve the conflict. "

Flutter version: 1.18, Unity version: 2019.3.12 , Xcode Version: 11.4.1,
after build . when i click button "AR Demo" xcode show me errors:

ClassID 100000 (int) conflicts with that of another class (int). Please resolve the conflict.
(Filename: Line: 263)

ClassID 100001 (bool) conflicts with that of another class (bool). Please resolve the conflict.
(Filename: Line: 263)

ClassID 100002 (float) conflicts with that of another class (float). Please resolve the conflict.
(Filename: Line: 263)

ClassID 100011 (void) conflicts with that of another class (void). Please resolve the conflict.
(Filename: Line: 263)

ClassID 100010 (Polygon2D) conflicts with that of another class (Polygon2D). Please resolve the conflict.
(Filename: Line: 263)

Target 'UnityFramework' of project 'Unity-iPhone' was rejected as an implicit dependency for 'UnityFramework.framework' because its architectures 'arm64' didn't contain all required architectures 'armv7 arm64'

I was just trying to run this sample and faced the below error.

 Target 'UnityFramework' of project 'Unity-iPhone' was rejected as an
    implicit dependency for 'UnityFramework.framework' because its architectures
    'arm64' didn't contain all required architectures 'armv7 arm64'

/Flutter/FlutterSDK/flutter/.pub-cache/hosted/pub.dartla
    ng.org/flutter_unity_widget-0.1.6+5/ios/Classes/UnityUtils.mm:5:10: fatal
    error: 'UnityFramework/UnityFramework.h' file not found
    #include <UnityFramework/UnityFramework.h>

Any help will be appreciated

Failure to initialize / Failed to load 'libmain.so'

Hi guys, I'm trying to run this arkit demo. But when ı start application the error show up in the phone. Actually the app run but just "AR Demo Please make sure you exported the ARKIT unity demo example." text it seems.

Appearing error;
"Failure to initialize Your hardware does not support this application. Failed to load libmain.so java.lang.Unsatisfied.... bla bla bla"

-I am using real android device (its working except for ar/this project.)

  • I am created modules for all .aar files

How can i solve this problem anyone can help me ?

Get nothing when running app

I run the sample demo on Samsung s8.
Unity version: 2019.3.4f1
The demo is run successfully, but there is no AR scene or somethings, just

AR Demo
Please make sure you exported the ARKIT unity demo example.

Is that correct ? 😮

ImageTracking is not working while others seems working great

Other scenes worked just fine, only ImageTracking is not working. It showed "No resource group with name "ReferenceImageLibrary_B3FB7092-C2DA-7A4B-AD1E-35B555085B9D" found", so I rebuilt the ReferenceImageLibrary and use cube as prefab, still failed.
unity : 2019.4.3f1
IOS
$ flutter doctor -v
[✓] Flutter (Channel dev, 2.3.0-12.1.pre, on Mac OS X 10.15.4 19E287 darwin-x64, locale zh-Hans)
• Flutter version 2.3.0-12.1.pre at /Users/jack/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f9c825981c (9 weeks ago), 2021-05-18 14:07:52 -0700
• Engine revision 26e217e6c3
• Dart version 2.14.0 (build 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af)
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/jack/Library/Android/sdk
• Platform android-30, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.58.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.24.0

[✓] Connected device (2 available)
• 吴杰的 iPhone7 (mobile) • eed6e3b2d815420621d441672707634130e89e16 • ios • iOS 13.5.1
• Chrome (web) • chrome • web-javascript • Google Chrome 83.0.4103.61
! Error: 吴杰的 iPhone7 is busy: Copying cache files from device. Xcode will continue when 吴杰的 iPhone7 is finished. (code -10)

• No issues found!

$ flutter run
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Launching lib/main.dart on 吴杰的 iPhone7 in debug mode...
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Automatically signing iOS for device deployment using specified development team in Xcode project: 65TSJ9E93J
Running Xcode build...
└─Compiling, linking and signing... 10.7s
Xcode build done. 32.3s
iOS Observatory not discovered after 30 seconds. This is taking much longer than expected...
Installing and launching... 73.2s
Syncing files to device 吴杰的 iPhone7... 121ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

An Observatory debugger and profiler on 吴杰的 iPhone7 is available at: http://127.0.0.1:63023/XW6bxyhUcB0=/
The Flutter DevTools debugger and profiler on 吴杰的 iPhone7 is available at: http://127.0.0.1:9102?uri=http%3A%2F%2F127.0.0.1%3A63023%2FXW6bxyhUcB0%3D%2F
Built from '2019.4/china_unity/release' branch, Version '2019.4.3f1 (ac4571766456)', Build type 'Release', Scripting Backend 'il2cpp'
-> applicationDidFinishLaunching()

Setting UIViewControllerBasedStatusBarAppearance to NO is no longer supported.
Apple actively discourages that, and all application-wide methods of changing status bar appearance are deprecated

-> applicationDidBecomeActive()
[Subsystems] Discovering subsystems at path /var/containers/Bundle/Application/30566353-BB21-42B5-AA10-47D62C5ADD88/Runner.app/Frameworks/UnityFramework.framework/Data/UnitySubsystems
[Subsystems] No descriptors matched for examples in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json.
[Subsystems] 1 'inputs' descriptors matched in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json
[Subsystems] No descriptors matched for displays in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json.
[Subsystems] No descriptors matched for meshings in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json.
Initializing Metal device caps: Apple A10 GPU
Initialize engine version: 2019.4.3f1 (ac4571766456)
flutter: ********************************************
flutter: Controller setup complete
flutter: ********************************************
Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x11e7902f0>.
UnloadTime: 0.357708 ms
[Subsystems] Loading plugin UnityARKit for subsystem ARKit-Input...
[Subsystems] UnityARKit successfully registered Provider for ARKit-Input
Setting up 1 worker threads for Enlighten.
Thread -> id: 16dc6b000 -> priority: 1
flutter: Selected
11
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
GameManager:LoadGameScene(String)

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Unloading 4 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 3.833042 ms
[General] No resource group with name "ReferenceImageLibrary_B3FB7092-C2DA-7A4B-AD1E-35B555085B9D" found
InvalidOperationException: Failed to resolve image library 'ReferenceImageLibrary'. There is no matching resource group, or the resource group does not contain any reference images.
at UnityEngine.XR.ARKit.ARKitImageDatabase..ctor (UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary serializedLibrary) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.ARKit.ARKitImageTrackingSubsystem+ARKitProvider.CreateRuntimeLibrary (UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary serializedLibrary) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem.CreateRuntimeLibrary (UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary serializedLibrary) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.ARFoundation.ARTrackedImageManager.OnBeforeStart () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`2[TSubsystem,TSubsystemDescriptor].OnEnable () [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

[Subsystems] Loading plugin UnityARKit for subsystem ARKit-Input...
[Subsystems] UnityARKit successfully registered Provider for ARKit-Input

Unloading 28 unused Assets to reduce memory usage. Loaded Objects now: 1002.
Total: 2.377000 ms (FindLiveObjects: 0.246375 ms CreateObjectMapping: 0.025875 ms MarkObjects: 1.918542 ms DeleteObjects: 0.185500 ms)

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: MissingPluginException(No implementation found for method dispose on channel unity_view_0)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)

#1 UnityWidgetController._dispose (package:flutter_unity_widget/flutter_unity_widget.dart:55:5)

Application finished.

Update exemple to unity 2021

I'm using unity 2021 from a project, but it's incompatible with the example presented, if possible update the example.

Exception: Build failed Build.DoBuildIOS () (at Assets/Editor/Build.cs:94)

Flutter Export IOS build Failed on Unity

Please help, is this something wrong because i miss some steps or is it bug?

i am exporting using Flutter Export IOS on Unity version 2019.4.4f1 LTS and here's what i got

Error 1 - Used from several location

Plugin 'UnityARKit.a' is used from several locations:
Packages/com.unity.xr.arkit/Runtime/iOS/Xcode1100/UnityARKit.a would be copied to /UnityARKit.a
Packages/com.unity.xr.arkit/Runtime/iOS/Xcode1000/UnityARKit.a would be copied to /UnityARKit.a
Plugin 'libUnityARKitFaceTracking.a' is used from several locations:
Packages/com.unity.xr.arkit-face-tracking/Runtime/iOS/Xcode1100/libUnityARKitFaceTracking.a would be copied to /ARM64/libUnityARKitFaceTracking.a
Packages/com.unity.xr.arkit-face-tracking/Runtime/iOS/Xcode1000/libUnityARKitFaceTracking.a would be copied to /ARM64/libUnityARKitFaceTracking.a
Please fix plugin settings and try again.

Error 2 - Colliding with each other

UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
Build:DoBuildIOS() (at Assets/Editor/Build.cs:86)

Plugins colliding with each other.

Error 3 - Warning

Exception: Build failed
Build.DoBuildIOS () (at Assets/Editor/Build.cs:94)

Could not determine the dependencies of task ':flutter_unity_widget:generateDebugRFile'.

This are the steps which i performed:
step 1: Export Android (Unity 2019.3.*)
step 2: Could not determine the dependencies of task ':flutter_unity_widget:generateDebugRFile'.
step 3: flutter run
but step 3 shows error I don't know what should I do PLEASE HELP !!! This is the output that I got

PS D:\flutter projects\flutter project from github\flutter-unity-arkit-demo-master> flutter run
Running "flutter pub get" in flutter-unity-arkit-demo-master... 777ms
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts, consider enabling software rendering
with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY .

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':flutter_unity_widget:generateDebugRFile'.

Could not resolve all task dependencies for configuration ':flutter_unity_widget:debugRuntimeClasspath'.
Could not find :arcore_client:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :ARPresto:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :unityandroidpermissions:.
Required by:
project :flutter_unity_widget > project :UnityExport
Could not find :UnityARCore:.
Required by:
project :flutter_unity_widget > project :UnityExport

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to
    get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 19s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 21.0s
Exception: Gradle task assembleDebug failed with exit code 1

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.