Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

ARKit support for iOS via Unity-ARKit-Plugin

Discussion in 'ARKit Preview' started by jimmya, Jun 5, 2017.

  1. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    44
    When running an ARKit app goes into the background, what happens with ARKit tracking? My experience is that when returning from the background, objects placed based on the previous tracking data can be in totally different positions because the tracking has drifted while the app was in the bg.

    Am I missing any key features of ARKit that would help with this issue? Sometimes when the app returns from the background, the drift is minimal while others its unusable.

    Also, as far as I can tell, an iOS system dialog (your battery is at 20%) can report the app as having gone into the background, so its hard to distinguish between actual backgrounding because the app gets OnApplicationDidBecomeActive() in either situation.

    -A
     
    DerekLerner likes this.
  2. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    The second project I linked does not use rendertextures.
     
  3. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    Yes, in any case where the app is backgrounded, the app loses camera feed and sensor data, and you have to reset tracking. This is the current way ARKit works.
     
  4. showmevirtual

    showmevirtual

    Joined:
    Sep 10, 2017
    Posts:
    3
    I get the same error in an empty project with only ARKit example scenes. Thank you in advance for your help

    Edit: Getting same error in earlier versions of Unity too, an earlier 2017 beta and 5.6.

    Edit: Reverting to an older version of ARKit let's me build to my phones, but everything is crashing at launch because the phones are on the latest iOS 11, and the ARKit build is much older.
     
    Last edited: Sep 12, 2017
  5. wyattdesouza

    wyattdesouza

    Joined:
    Aug 14, 2015
    Posts:
    4
    I hadn't updated to the latest iOS beta, the camera works now but extremely slow and there are no elements from the scene on the phones sceen.
     
  6. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27

    Thanks for your response. I tried what you have said, but I get Mach O linker errors on Xcode. The errors outline Vuforia which is not even being used in my project, how did you solve it? @jimmya is this a known unity issue?
    GVR - 1.7
    Unity - 2017.2.0b8
    Xcode 9 beta 6
    Screen Shot 2017-09-12 at 3.41.41 PM.png
     
    Last edited: Sep 12, 2017
  7. mm_sto

    mm_sto

    Joined:
    Aug 28, 2017
    Posts:
    5
    How do i make this work with Deferred rendering? It's acting very messy and laggy around it currently.
     
  8. skdev3

    skdev3

    Joined:
    Jul 15, 2015
    Posts:
    19
    Delete GVR, Unity 2017 avtomatic added SDK.
    Steps:
    How I'm set up ARkit + Cardboard:
    0. Create an empty Unity project, and add ARKit SDK
    1. Added Virtual Reality Supported.
    [​IMG]

    2. My code to Switching to Virtual Reality mode:
    Code (csharp):
    1.  
    2. [*] public override void SetupVR(bool isVR)
    3. [*]    {  
    4. [*]        Camera[] camers = (Camera[])GameObject.FindObjectsOfType<Camera>();
    5. [*]        StartCoroutine(LoadDevice(isVR,  camers));
    6. [*]    }
    7. [*]
    8.  
    9. [*]    IEnumerator LoadDevice(bool isVR, Camera[] camers)
    10. [*]    {
    11. [*]        // VRDeviceName none
    12. [*]        string newDevice = VRSettings.supportedDevices.Length>0 ? VRSettings.supportedDevices[0] : "none";
    13. [*]        if (isVR)
    14. [*]        {
    15. [*]            //VRDeviceName Cardboard or Split
    16. [*]#if UNITY_EDITOR
    17. [*]            newDevice = "Split";
    18. [*]#else
    19. [*]            newDevice = VRSettings.supportedDevices.Length > 1 ? VRSettings.supportedDevices[1] : "none";
    20. [*]#endif
    21. [*]        }
    22. [*]        Debug.Log("VRDeviceName " + newDevice);
    23. [*]        VRSettings.LoadDeviceByName(newDevice);
    24. [*]        yield return null;
    25. [*]        Debug.Log(VRSettings.loadedDeviceName + " is loaded");
    26. [*]#if !UNITY_EDITOR
    27. [*]        foreach (Camera cam in camers)
    28. [*]            {
    29. [*]                if (cam != null)
    30. [*]                {
    31. [*]                    VRDevice.DisableAutoVRCameraTracking(cam, isVR);
    32. [*]                }
    33. [*]            }
    34. [*]        if(Camera.main)
    35. [*]        VRDevice.DisableAutoVRCameraTracking(Camera.main, isVR);
    36. [*]#endif
    37. [*]        VRSettings.enabled = isVR;
    38. [*]    }
    39. [*]
    40.  
    41. [*]
    42.  
    43.  
    PostBuild Code:
    Code (csharp):
    1.  
    2. #if UNITY_IOS || UNITY_IPHONE
    3. using UnityEngine;
    4. using UnityEditor;
    5. using UnityEditor.Callbacks;
    6. using System.Collections;
    7. using UnityEditor.iOS.Xcode;
    8. using System.IO;
    9.  
    10.  
    11. public class PostBuildProcessor : MonoBehaviour
    12. {
    13.     [PostProcessBuild]
    14.     public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
    15.     {
    16.         if(buildTarget == BuildTarget.iOS)
    17.         {
    18.             string plistPath = pathToBuiltProject + "/Info.plist";
    19.             PlistDocument plist = new PlistDocument();
    20.             plist.ReadFromString(File.ReadAllText(plistPath));
    21.             PlistElementDict rootDict = plist.root;
    22.             rootDict.SetString("NSCameraUsageDescription", "$(PRODUCT_NAME) camera use");
    23.             rootDict.SetString("NSMicrophoneUsageDescription", "$(PRODUCT_NAME) microphone use");
    24.             File.WriteAllText(plistPath, plist.WriteToString());
    25.  
    26.  
    27.  
    28.             UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject();
    29.             //Construct the full path to the project.pbxproj file
    30.             string projPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
    31.             //Load the project into the PBXProject utility
    32.             proj.ReadFromString(File.ReadAllText(projPath));
    33.             //Find your target guid, which by default is Unity-iPhone for Unity
    34.             //Set your Bitcode value here
    35.             proj.SetBuildProperty(proj.TargetGuidByName("Unity-iPhone"), "ENABLE_BITCODE", "NO");
    36.             //Save the project out for use by Xcode
    37.             File.WriteAllText(projPath, proj.WriteToString());
    38.  
    39.             UnityEditor.iOS.Xcode.PBXProject projPods = new UnityEditor.iOS.Xcode.PBXProject();
    40.             //Construct the full path to the project.pbxproj file
    41.             string projPathPods = pathToBuiltProject + "/Pods/Pods.xcodeproj/project.pbxproj";
    42.             //Load the project into the PBXProject utility
    43.             projPods.ReadFromString(File.ReadAllText(projPathPods));
    44.             //Find your target guid, which by default is Unity-iPhone for Unity
    45.             //Set your Bitcode value here
    46.             projPods.SetBuildProperty(projPods.TargetGuidByName("Pods-Unity-iPhone"), "ENABLE_BITCODE", "NO");
    47.             projPods.SetBuildProperty(projPods.TargetGuidByName("GoogleToolboxForMac"), "ENABLE_BITCODE", "NO");
    48.             projPods.SetBuildProperty(projPods.TargetGuidByName("GTMSessionFetcher"), "ENABLE_BITCODE", "NO");
    49.             //Save the project out for use by Xcode
    50.             File.WriteAllText(projPathPods, projPods.WriteToString());
    51.  
    52.         }
    53.     }
    54.  
    55. }
    56. #endif
    57.  
    p.s.
    1. Do not add GVR to the project, this is done automatically (if use Added Virtual Reality Supported).
    2. Do not add Vuforia when creating a project.
     
    Last edited: Sep 12, 2017
    Arvin6 likes this.
  9. UCS

    UCS

    Joined:
    Nov 7, 2014
    Posts:
    2
    Hello all,

    I am currently using the ARKit for developing an app, but when I build and load it onto my iPad, the real world which is displayed seems to be zoomed in, compared to the camera which is displayed in the iOS camera app.
    I have not tested this on a phone.
    Is this something anyone else has experienced?

    Thanks in advance

    Edit:
    As per:
    https://forums.developer.apple.com/thread/81301
    and
    https://forums.developer.apple.com/thread/83900

    I assume that this is not something which is possible currently. Can anyone confirm this?
     
    Last edited: Sep 12, 2017
  10. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    893
    AR Ambient Script.
    I have everything attached correctly, and the AR ambient Script attached to my Directional light. ...
    but it does not seem to be reading the ambient environment light.
    Any advice appreciated.
    [​IMG]
     
    Last edited: Sep 12, 2017
  11. HaimBendanan

    HaimBendanan

    Joined:
    May 10, 2016
    Posts:
    13
    Thank you
     
  12. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    Sounds like you do NOT have the latest version of the plugin.
     
  13. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    We do not recommend using deferred rendering on mobile currently.
     
  14. wrutkowski

    wrutkowski

    Joined:
    Aug 9, 2017
    Posts:
    6
    Hi, question about App Store (Test Flight) submission. I have troubles exporting and uploading game created with Unity and UnityARKit Plugin - Xcode crashes on trying to Upload the build to iTunes Connect or exporting app to ipa.
    I posted a question on Stack Overflow as well: https://stackoverflow.com/questions...ort-and-upload-to-app-store-crashing/46147623

    I thought it was my game but I tried simple project with only UnityARPlugin in it and the issue persists. I can upload the simple project if someone is keen to look into that.

    My setup:
    Unity 2017.1.1f1
    Xcode 9 GM
    macOS Sierra 10.12.6
     
  15. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    10
     
  16. danbfx

    danbfx

    Joined:
    Feb 22, 2011
    Posts:
    10
    Hi there and thanks for this!

    Running AR Remote on latest iOS 11 beta on Iphone 6S. Running Unity 2017.1.1 and the ARKit Example Editor scene when I select the device from the drop down the button appears for a sec then it ends with Connection Failed. Unity is running on Windows 10. What are we doing wrong?

    Thx again
     
  17. showmevirtual

    showmevirtual

    Joined:
    Sep 10, 2017
    Posts:
    3
    Thanks for your help jimmya, the GM xcode seems to have fixed the problem on my end
     
    Last edited: Sep 13, 2017
  18. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    I was able to archive with XCode 9 GM, albeit with Development Profile. It might be something to do with some time needed after XCode updates are put out before TestFlight, archives and certs are in sync again.

    I've heard elsewhere that people had to wait for an hour or so until iTunesConnect had been flagged to accept builds from the GM.
     
    Last edited: Sep 13, 2017
  19. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    First of all, see if you can connect to the profiler from the editor on an empty scene on iOS. Then check if you built the ARKit Remote app with the same version of Unity? And make sure you're running the same version of the plugin on both sides.
     
  20. sticklezz

    sticklezz

    Joined:
    Oct 27, 2015
    Posts:
    16
    Have you looked into if a "soft occlusion" shader would be possible, that might make the artifacts look less jarring?
     
  21. rain330047

    rain330047

    Joined:
    Jun 3, 2016
    Posts:
    10
    Hi all,
    Here is a question I need help.
    I used GeneratePlane script and debug plane prefab for the plane which detected by ARKIT;
    First time load AR scene, the plane show perfectly; then I load another scene without AR stuff; however when I load AR scene back, then I can only see the point cloud, hardly see the planes.

    And I put some log on the UnityARAnchorManager.cs, I found that second time when I load AR scene, AddAnchor/RemoveAnchor/UpdateAnchor seems not worked.

    any advice? please.
     
    wrutkowski likes this.
  22. dreamplanet

    dreamplanet

    Joined:
    Jun 17, 2017
    Posts:
    7
    Chris is right on this one, Zyshaq .. I couldn't get the above to work. It seemed to just scale the particles (rather than the terrain and all the models) and cause everything to rapidly swim left (or right) with zoom. The multicam approach that Christopher posted is the right one .. it's a bit confusing, but to anyone out there facing this same scaling challenge for tabletop dev - his multicam branch is the way to go for this problem. Thanks for trying, amigo. As always, I appreciate the help. The power of Unity is its community.
     
  23. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27
    You have a camera array? Did you add another camera for the stereo view? If so, where did you add it? Did you also attach UnityARVideo script to it? I thought all this is handled by unity itself. And I have tried what you suggested, it didn't work for me. I get the same linker error. I never added vuforia. What version of unity do you use?
     
  24. thw0609000

    thw0609000

    Joined:
    Sep 13, 2017
    Posts:
    1
    I build a xcode project success, but I got an error with "This application does not support this device's CPU type" when running the project on my iPhone7.
    unity : 5.6.3f1
    xcode: 9.0 beta 6
    iOS: 11.0
     
  25. oliver-jones

    oliver-jones

    Joined:
    Nov 8, 2010
    Posts:
    24
    Sadly not, I keep getting the same error. I'm hoping that when iOS11 is officially released - I can use one of my Apple Developer support tickets (they don't do technical support for beta).
     
  26. Terry_Stark

    Terry_Stark

    Joined:
    Jun 16, 2017
    Posts:
    5
    Did you open .xcworkplace or .xcodeproj to compile? If you use .xcodeproj, please use .xcworkplace instead!
     
  27. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    153
    When can we expect face tracking API support?
     
  28. mcmstrgames

    mcmstrgames

    Joined:
    Jun 22, 2017
    Posts:
    2
    Hello,
    Will you publish an update of Unity ARKit for IOS GM version?
    Is there someone who has already tested current asset store version with IOS & XCode GM version?
    Thanks
     
    DerekLerner likes this.
  29. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27
    I'm using build and run, that supposedly opens the xcworkspace by default. I have also tried opening the xcworkspace file manually, still got the same error. Which version of unity are you using? Do you use any special build scripts?
     
  30. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27
    I'm currently running the iOS GM version with the existing plugin and have no issues.
     
  31. unity_1Pe5zGwTRS_Riw

    unity_1Pe5zGwTRS_Riw

    Joined:
    Sep 13, 2017
    Posts:
    1
    On iOS 11 GM and Xcode 9 GM and Unity 2017.2.0b9 I can see only a black screen when running samples. I tried to run every scene from the project and it shows splash and then black screen (sometimes parts of UI like buttons are visible) but there is no image from camera.
     
    DerekLerner likes this.
  32. Arvin6

    Arvin6

    Joined:
    Jun 2, 2017
    Posts:
    27

    It was indeed a unity bug. I was on 2017.2.0b8 and it had problems with GVR / XR I guess. Now I got it to run on the iphone. But the results are quite worse, not even close to what you guys have gotten. I have attached a screenshot of it. How did you tweak it to look like side-by-side view (without black edges) and also reduce distortion to an extent? Mine appears too wrapped up. Thanks for your inputs :)
    Screen Shot 2017-09-13 at 6.05.33 PM.png
     
    Last edited: Sep 13, 2017
  33. phil-harvey

    phil-harvey

    Joined:
    Aug 27, 2014
    Posts:
    50
    Yep I was wondering this as well.
     
    lingoded likes this.
  34. skdev3

    skdev3

    Joined:
    Jul 15, 2015
    Posts:
    19
    Tap to settings and scan other QR code from this doc https://docs.google.com/document/d/1Korlk8wnAlzvlWM_PkM9wU5siM3CCo-2XVZH4BD6qKE
    Im use "QR Code for NOTON"
     
  35. Kowciany

    Kowciany

    Joined:
    Feb 24, 2015
    Posts:
    5
    @KarelA Thx for help ! Really appreciate your support. I'm sorry for late reply. I had other work to do. Setup was the same as yours, but I've tested this on AR Remote and this was the problem that camera from AR remote scene had 30 on clipping plane (or then it only works for one camera - didn't tested this), but making real build and running app showed that this is working solution. Conclusion for anybody who has problem with far clipping set for 30 - attaching UnityARCameraNearFar solves the issue even if you use scaling trick with 2 cameras - just attach it to both.
     
    KarelA likes this.
  36. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    do you see anything in the logs in Xcode? Please post as much information as you can. There is an FAQ posted in JImmy's first post. Please read that and post accordingly. The plugin was tested against the latest GM seed and appeared to work.
     
  37. noahmilam

    noahmilam

    Joined:
    Mar 4, 2015
    Posts:
    4
    not sure if this was answered but this helped me.
    this is a simple how to get it working. make sure you build with debug.
    https://docs.unity3d.com/Manual/ProfilerWindow.html
     
  38. matthewpruitt

    matthewpruitt

    Unity Technologies

    Joined:
    Sep 15, 2016
    Posts:
    9
    Hi all - just a quick heads-up that I've moved this thread to the new "ARKit Preview" sub-forum under "AR/VR (XR) Discussion". I've set up a redirect, so it'll continue to appear in this forum for another 24 hours.
     
    christophergoy likes this.
  39. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    Yes we have and it works without any changes.
     
  40. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    377
    We're working on it. But you realize you will not be able to use it until you get an iPhone X (earliest Nov 3)?
     
  41. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    You actually need to make sure "Development Build" is checked. It doesn't matter if it's debug or release.
     
    pixelsteam likes this.
  42. aas395

    aas395

    Joined:
    Aug 26, 2017
    Posts:
    4
    I'm trying to set up the ARKit remote to help streamline my workflow. My app builds correctly in Xcode 9 and i've gotten Unity (2017.2.0b11) to connect to my iphone via USB, but when I build in xcode and press the play button in unity and then click the "Start Remote ARKit Session" button in the game view window, nothing happens. Anyone have any thoughts about where I might be going wrong?

    Thanks for all your good work, guys!
     
  43. DigitalBeach

    DigitalBeach

    Joined:
    Jan 17, 2015
    Posts:
    8
    Does the content from the branch work on the latest plugin? I tried out just the content since the plugin in the branch is significantly different from latest and it runs but the tracking doesn't work at all and the marker and object move all over the place.

    Are there other changes in the core plugin that are needed for the scaled-content also? Hard to tell from the changelists.
     
  44. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    Make sure "Development Player" is selected in the build settings window.
     
  45. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    One of the things I've seen people do is not respect the layer rules that were set up in that branch. So if the tracking data game objects are not on the ARKitTrackingData layer, they will be rendering incorrect. Conversely, if the content you want rendered in a scaled fashion is on the ARKitTrackingData layer, it will also be rendered incorrectly. If you are instantiating the tracking data yourself you need to make sure you are creating the gameobjects on the correct layer. Same for the content you want scaled.

    Since I don't know exactly what you're doing with the branch it's hard to know if something is broken. I will give it a quick test today.
     
  46. DigitalBeach

    DigitalBeach

    Joined:
    Jan 17, 2015
    Posts:
    8
    I also see the changes in UnityARCameraManager, UnityARGeneratePlane, UnityARUtility, and UnityARVideo. Adding those make it work a bit better. The content looks locked and scales but the plane markers don't stay aligned when you change the scale. Still hard to see if that is everything since the files are all in different folders now in the SDK.
     
  47. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    Read my post above
     
  48. DigitalBeach

    DigitalBeach

    Joined:
    Jan 17, 2015
    Posts:
    8
    Thanks. I am using the exact scene from the branch. No changes. But I had to integrate it myself to the new plugin since things have changed so I may have missed a bit.
     
  49. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    462
    Ok, i'll try to update the branch tonight since there was a reorganization of the folders after it was made.
     
  50. DigitalBeach

    DigitalBeach

    Joined:
    Jan 17, 2015
    Posts:
    8
    Ahh. I think the layer tags were lost since I can't just merge in the branch. I think I can recreate. But you may want to make a sample that is compatible with latest is this technique is going forward.
     
    christophergoy likes this.