Search Unity

Resolved ARKit support for iOS via Unity-ARKit-Plugin

Discussion in 'AR' started by jimmya, Jun 5, 2017.

Thread Status:
Not open for further replies.
  1. Fl0oW

    Fl0oW

    Joined:
    Apr 24, 2017
    Posts:
    21
    No, they were done with the iOS 11.3 Beta and XCode 9.3 Beta. iOS 11.3 is expected to be released this Spring, but you can already download the Betas in your Apple developer portal.
     
  2. dav10001

    dav10001

    Joined:
    Nov 30, 2015
    Posts:
    10
    Really nice stuff it was actually really quick to setup worked fast at detection the vertical wall, just wondering if you have tried the same image detection arkit project and if you can integrate that into a unity example like you did with this vertical plane example got the link for that below would be amazing if we could recognise a image on a vertical plane like vuforia does

    Link for image recognition: https://developer.apple.com/documentation/arkit/recognizing_images_in_an_ar_experience
     
  3. sam598

    sam598

    Joined:
    Sep 21, 2014
    Posts:
    60
    Awesome, I had not seen that sample code. I must have missed the download button.

    I'll leave it to the Unity devs to figure out the best workflow for image recognition. But looking at the Apple API, I don't see any reason Texture2D objects can't be used as ARReferenceImages.
     
  4. Pilot-365

    Pilot-365

    Joined:
    Aug 9, 2017
    Posts:
    11
    Yes. iOS 11.3 is in beta right now but ARKit 1.5 is available to developers using Swift as of today. Don't think Unity ARKit supports 11.5 yet (correct me if I'm wrong anyone).
    You can build an app with ARKit 1.5 now, but the additional features won't be usable for people until 11.3 is released.
    https://developer.apple.com/arkit/

    Anyone know if Unity plans on supporting ARKit 1.5 soon?
     
    hungrybelome and dienat like this.
  5. jhurlbut

    jhurlbut

    Joined:
    Aug 24, 2015
    Posts:
    2
    Is there a timeline for adding Image anchors to the UnityARKit repo on bitbucket? I am making my own additions but don't want to waste time duping features if it's coming soon. Thanks
     
  6. atcjavad

    atcjavad

    Joined:
    Jan 8, 2018
    Posts:
    14
    HeyBro

    U are right
    If the user at the first surface detection , he dosnt need to change the position of game object , we have to set a button for rechecking again if user wanted to change the object pisition
    U can check the" AR Dragon" game

    It has a awsom surface detection
    It is so fast and exact .

    Plz gide me , How can i make a such as this ar plane anchore
     
  7. atcjavad

    atcjavad

    Joined:
    Jan 8, 2018
    Posts:
    14
    HeyBro

    U are right
    If the user at the first surface detection , he dosnt need to change the position of game object , we have to set a button for rechecking again if user wanted to change the object pisition
    U can check the" AR Dragon" game

    It has a awsom surface detection
    It is so fast and exact .

    Plz gide me , How can i make a such as this ar plane anchore
     
  8. Transform

    Transform

    Joined:
    Jan 24, 2018
    Posts:
    1
    Hi,What do I need to set up for ARKitRemote? College I packaged EditorTestScene scene on the device and then link equipment in Unity, press the "Start Remote ARKit Session" button is no response, how do I solve?
    Thank you for your answer.
     
  9. AytoMaximo

    AytoMaximo

    Joined:
    Aug 26, 2015
    Posts:
    76
  10. atcjavad

    atcjavad

    Joined:
    Jan 8, 2018
    Posts:
    14
    Hi guys
    I am trying to make a customized plane generator
    U can such as this sample in the clip.

    I wanna have a button (SUMMON) for choosing suggested place .
    After choosing the plane by Button , The GameObject would be fixed on the screen , then , If u didnt choise the right place , U can reset GameObject place by refresh button .

    Plz Guide me how can make it .
     
  11. atcjavad

    atcjavad

    Joined:
    Jan 8, 2018
    Posts:
    14
    Hi Bro
    I am sure about it that u will guide me
    That is my code .
    I wanna Rotate an object in arkit Scene
    so if u touch the screen , it will just change the position of object , because of this , i have to disable " Unity Ar Hit test "
    But it is not running , It can not detect the surface and does not show the object after touching screen .
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine.EventSystems;
    4.  
    5. namespace UnityEngine.XR.iOS
    6. {
    7.     public class UnityARHitTestExample : MonoBehaviour
    8.     {
    9.         public Transform m_HitTransform;
    10.         private bool isDetecting;
    11.  
    12.         bool HitTestWithResultType (ARPoint point, ARHitTestResultType resultTypes)
    13.         {
    14.             List<ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface ().HitTest (point, resultTypes);
    15.             if (hitResults.Count > 0) {
    16.                 foreach (var hitResult in hitResults) {
    17.                     Debug.Log ("Got hit!");
    18.                     m_HitTransform.position = UnityARMatrixOps.GetPosition (hitResult.worldTransform);
    19.                     m_HitTransform.rotation = UnityARMatrixOps.GetRotation (hitResult.worldTransform);
    20.                     Debug.Log (string.Format ("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
    21.                     return true;
    22.                 }
    23.             }
    24.             return false;
    25.         }
    26.  
    27. /// <summary>
    28. /// S/////////////////////////////////////////////////////////////////////////////////////////////////////////// </summary>
    29.          
    30.         public void start () {
    31.        
    32.             isDetecting = true;
    33.        
    34.         }
    35.  
    36.         public void TurnOff () {
    37.             isDetecting = false;
    38.         }
    39.  
    40.         private bool IsPointerOverUIObject() {
    41.             PointerEventData eventDataCurrentPosition = new PointerEventData(EventSystem.current);
    42.             eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
    43.             List<RaycastResult> results = new List<RaycastResult>();
    44.             EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
    45.             return results.Count > 0;
    46.         }
    47.         /// <summary>
    48.         /// U/////////////////////////////////////////////////////////////////////////////////        /// </summary>
    49.         // Update is called once per frame
    50.         void Update () {
    51.             if ((Input.touchCount > 0 && m_HitTransform != null )&& isDetecting == true && !IsPointerOverUIObject())
    52.             {
    53.                 var touch = Input.GetTouch(0);
    54.                 if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved)
    55.                 {
    56.                     var screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
    57.                     ARPoint point = new ARPoint {
    58.                         x = screenPosition.x,
    59.                         y = screenPosition.y
    60.                     };
    61.  
    62.                     // prioritize reults types
    63.                     ARHitTestResultType[] resultTypes = {
    64.                         ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent,
    65.                         // if you want to use infinite planes use this:
    66.                         //ARHitTestResultType.ARHitTestResultTypeExistingPlane,
    67.                         //ARHitTestResultType.ARHitTestResultTypeHorizontalPlane,
    68.                         //ARHitTestResultType.ARHitTestResultTypeFeaturePoint
    69.                     };
    70.                    
    71.                     foreach (ARHitTestResultType resultType in resultTypes)
    72.                     {
    73.                         if (HitTestWithResultType (point, resultType))
    74.                         {
    75.                             return;
    76.                         }
    77.                     }
    78.                 }
    79.             }
    80.         }
    81.  
    82.    
    83.     }
    84. }
    85.  
    86.  
     
  12. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    I would like also know when the arkit plugin is going to have support for arkit 1.5 or if there is any way to access the new beta methods that are available for that arkit version
     
  13. SkaZonic

    SkaZonic

    Joined:
    Jun 20, 2017
    Posts:
    23
    Same!
     
  14. apaix

    apaix

    Joined:
    Aug 10, 2017
    Posts:
    21
    On the page before this, there is code to update for vertical planes.

    As far as image recognition, update the UnityARSessionNativeInterface to include the 2 new functions. ARImageAnchor and ARReferenceImage. All the other functions have slight modifications that you can reverse engineer through the current code.

    https://developer.apple.com/documentation/arkit
     
  15. apaix

    apaix

    Joined:
    Aug 10, 2017
    Posts:
    21
    You can see what is supported in the native interface file.

    https://bitbucket.org/Unity-Technol...iewer=file-view-default#ARSessionNative.mm-50
     
    AytoMaximo likes this.
  16. apaix

    apaix

    Joined:
    Aug 10, 2017
    Posts:
    21
  17. sam598

    sam598

    Joined:
    Sep 21, 2014
    Posts:
    60
    Enum for both Horizontal and Vertical planes:

    Code (CSharp):
    1. public enum UnityARPlaneDetection
    2. {
    3.     None = 0,
    4.     Horizontal = (1 << 0),
    5.     Vertical = (1 << 1),
    6.     HorizontalAndVertical = Horizontal | Vertical
    7. }
    I have a feeling jimmya and co are quiet about updating the plugin because they're busy updating the plugin.
     
    macdude2, flyingdeutschman and apaix like this.
  18. intropy

    intropy

    Joined:
    Jan 5, 2015
    Posts:
    5
    @jimmya could you possibly spell out how to stop plane detection while keeping existing planes / anchors?

    I have tried the following but it is not working:

    ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration (UnityARAlignment.UnityARAlignmentGravityAndHeading, UnityARPlaneDetection.None);
    UnityARSessionNativeInterface.GetARSessionNativeInterface ().RunWithConfigAndOptions (sessionConfig, UnityARSessionRunOption.ARSessionRunOptionResetTracking);

    There is an option:
    ARSessionRunOptionRemoveExistingAnchors
    but there does not appear to be the option:

    "ARSessionRunOptionKeepExistingAnchors"
     
  19. intropy

    intropy

    Joined:
    Jan 5, 2015
    Posts:
    5
    "ARSessionRunOptionKeepExistingAnchors" does not exist
     
  20. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    Add with what code? With the vertical planes he did it based on existing code made by unity
     
  21. apaix

    apaix

    Joined:
    Aug 10, 2017
    Posts:
    21
  22. mm_sto

    mm_sto

    Joined:
    Aug 28, 2017
    Posts:
    16
    Huh weird. I added the code to the Enum and the serialized value in the inspector, but I still get no vertical planes showing up! Did I miss something crucial?
     
  23. parth4054

    parth4054

    Joined:
    Nov 6, 2017
    Posts:
    2
    Did you change the deployment target to 11.3?
     
  24. mm_sto

    mm_sto

    Joined:
    Aug 28, 2017
    Posts:
    16
    I did! I wonder what's up with my device. The apple-demo on image recognition doesn't seem to work as well. Gonna do some fail searching on the broader scope. might just be me!
     
  25. dav10001

    dav10001

    Joined:
    Nov 30, 2015
    Posts:
    10
    Hi guys I am trying to reverse engineer the ARKit image recognition code, so Im using the image recognition example they have trying to add that correctly in the ARSessionnNative.mm but I'm not sure how to do so I've created a ARReferenceImage struct and called it from the
    GetARSessionConfigurationFromARKitWorldTrackingSessionConfiguration function to add the detection image property just like the arkit documentation does but how do I create a reference for the image that will be recognised and then simply create a plane like the image recognition example does?

    Anyone got any ideas how to add the Image recognition stuff correctly I'm not really a objective c programmer or swift so translating the swift to objective c for it work as a plugin is tricky for me? Anyone adding the image recognition let me know
     
  26. xj1982xj

    xj1982xj

    Joined:
    Sep 19, 2017
    Posts:
    35
    Hi Guys , One question want to consult :
    If Arkit detect an 1m*1m floor , and generated a 1m*1m Arkit plane for this floor , is there any way that the real floor's texture can be transfer to the this generated plane ? so that i can get a Plane mesh with the real world floor texture.
     
  27. ch0arrim

    ch0arrim

    Joined:
    Jul 18, 2012
    Posts:
    10
    Hi

    I use the following:
    Latest version of ARkit (1.0.14)
    Unity 2017.3.0f3
    MAC OS 10.13.3

    Whenever I try the ARkit, unity just spews out massive amount of errors which all looks like:
    Assertion failed: Screen position out of view frustum (screen pos 2048.000000, 0.000000, 30.000000) (Camera rect 0 0 2048 2732)

    I have googled around and any answer I have found seems to be that their camera clipping planes or size was wrong or that they had to reopen the scene view.

    I have also tried this in my other Unity versions; 2018B2, 2017.2, 2017.1 but the issue is the same.

    I have tried this in existing projects and even brand new projects with only the ARKit installed. I also tried to do it on a win 10 laptop with the same result.

    I tried to upload a clean project from my computer but it seems as if even 10Mb is too huge for this forum :(

    I have tried to reinstall every Unity I had, but I get the same error everytime!
    Please, I really need some help here, I feel like I have tried everything but can't seem to solve it!

    As far as I can see; Unity throws out all these errors when ARkit calls "GetCameraProjection" in the UnityARSessionNativeInterface.cs.

    Its just blind luck that I happened to have 1 project with an older ARKit on it, which I can copy and use elsewhere (The 1.0.13 version works as it should btw).
     
  28. anm8tr

    anm8tr

    Joined:
    Oct 26, 2016
    Posts:
    2
    I have an error when installing the ARKit plugin with version 2017.3.0p3 & 2017.3.0p4

    Assets/UnityARKitPlugin/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs(4,19): error CS0234: The type or namespace name `iOS' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?

    Any feedback would be appreciated, I wasted an entire day downloading the updates due to slow as molasses download speeds only to find this error in both versions.
     
  29. mm_sto

    mm_sto

    Joined:
    Aug 28, 2017
    Posts:
    16
    Get the latest build from Bitbucket. They've fixed it there.
     
    ch0arrim likes this.
  30. ch0arrim

    ch0arrim

    Joined:
    Jul 18, 2012
    Posts:
    10
    YES THAT FIXED IT!!!

    You can't believe how much this is helping me!

    A virtual hug for you!
     
    mm_sto likes this.
  31. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    An AR app I was working on got released to the app store just now, thanks @jimmya and everyone in this thread!



     
  32. mm_sto

    mm_sto

    Joined:
    Aug 28, 2017
    Posts:
    16
    Glad to help!
     
  33. anm8tr

    anm8tr

    Joined:
    Oct 26, 2016
    Posts:
    2

    Note: The iOS portion of the install was incomplete. Re downloaded, installed all good now! Damn I'm good!
     
  34. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    That looks awesome, @hawken! Great work!
     
  35. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    249
    Cool! Do you live in Norway?? And is that an in-app screen or render?
     
  36. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    249
    How can I make the MobileArShadow shader show less shadow?
    I know you'd normally change the light's shadow intensity, but the situation is that I have some indirect lighting on the normal mesh, that makes the shadow there less strong. But on the MobileARShow the shadows are 100% black.



    I tried changing the 1.0 values here, but that makes the whole Plane semi transparent.

    fixed4 frag(v2f i) : COLOR {

    // 6.) The LIGHT_ATTENUATION samples the shadowmap (using the coordinates calculated by TRANSFER_VERTEX_TO_FRAGMENT
    // and stored in the structure defined by LIGHTING_COORDS), and returns the value as a float.
    float attenuation = LIGHT_ATTENUATION(i);
    return fixed4(1.0,1.0,1.0,1.0) * attenuation;
    }
     
  37. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    heh no thats part of the marketing PR video, the video is a mix "aspirational" AR and shots from the app.
    The app proper looks like this


    I'm out in Japan, the team was a mix of people in different countries.
     
  38. NEEEU

    NEEEU

    Joined:
    Mar 8, 2013
    Posts:
    4
    Pretty surreal potential,
    Nice work. Really like the level of detail in the track-modules.
    Also the little audio eastereggs.

    The track creating part could be a bit more intuitive, imho.

     
  39. rayfigs

    rayfigs

    Joined:
    Feb 8, 2009
    Posts:
    41
    I've was lured to try my hand at getting sloth to work ARKit. You've made it very easy to do thank-you for making this available.

    Do you know what format Apple's animoji are being sent as?

    Is there a framework available which would Unity apps to be created as a iMessage app extension? I would like to be able to launch my app directly from iMessage.
     
  40. xj1982xj

    xj1982xj

    Joined:
    Sep 19, 2017
    Posts:
    35
    Hi Guys , One question want to consult :
    If Arkit recogize an 1m*1m floor , and generated a 1m*1m Arkit plane for this floor , is there any way that this real world floor's texture can be transfer to the this generated plane ? so that i can get a Plane mesh with the real world floor texture.
     
  41. dav10001

    dav10001

    Joined:
    Nov 30, 2015
    Posts:
    10
    The new arkit 1.5 has image recognition but its not yet part of the arkit unity plugin from that you could've recognised the texture image then done something from that but as thats not possible you could check out this scaled arkit example here:
    https://bitbucket.org/Unity-Technologies/unity-arkit-plugin/branch/alt-scaled-content

    I'm guessing ur plane is fixed and scaled to be 1m by 1m and this example might help.... in terms of making the floor's texture being recognised I would disable the arkit plane renderer, then when its big enough make copy of the arkit plane's mesh. Create a new gameobject and set the mesh to be the arkit plane's mesh at the same position it was detecting the floor and set this new object's texture to be ur floor so it looks like your floors texture is recognised... might take a bit longer as ur still recognising the plane then showing the texture onto
     
    Last edited: Feb 6, 2018
  42. xj1982xj

    xj1982xj

    Joined:
    Sep 19, 2017
    Posts:
    35
    Hi dav10001 , many thank for your suggestion. i will check this branch project to see whether it works .
     
  43. _Amael_

    _Amael_

    Joined:
    Aug 20, 2012
    Posts:
    19
    Thanks for making this plugin available! It's a life saver :)

    One issue that I've been having though is with the blue planes (that should be generated by GeneratePlanes) - no matter what I do, I can't get them them to appear? I've downloaded the latest version of the plugin and added it to a fresh project in 2017.1, but they just don't seem to work for me.

    Everything else appears to be working fine despite this (like the Point Cloud stuff and other functionality), but it's annoying as I'd like to use the planes (and it interferes with demos like the Focus Square).

    Does anyone have any idea what might be going wrong with the planes?

    Many thanks
     
  44. dav10001

    dav10001

    Joined:
    Nov 30, 2015
    Posts:
    10
    Im not sure exactly what it could be.. best thing I can think of is to check a few thing
    1. is the plane prefab being rendered correctly - is the mesh renderer on and prefab attached?
    2. try creating a delegate function which is called when the function responsible for creating the plane is called.. in
    UnityARUtility.cs func: CreatePlaneInScene() line 21 have ur event here if your function is called then you know its not something in the code.
    3. check in the configurations is planeDetection.Horizontal enabled?
    4. check the log to see if you any errors or warning are there (I usually do that in xCode).
     
  45. ezonecom

    ezonecom

    Joined:
    Jul 23, 2013
    Posts:
    17
    cstenson, Aiursrage2k and jimmya like this.
  46. sdprasad

    sdprasad

    Joined:
    Jun 20, 2017
    Posts:
    3

    Hi, I am having the same problem, but am not using Vuforia. when ever am switching ARscene to non-Arscene and then to ARScene again it doesnt work. Please help me out.
     
  47. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
  48. bluemode

    bluemode

    Joined:
    Jun 1, 2017
    Posts:
    2
    Hi, I'm trying to create a scene in which the camera collides with the walls/columns, however after implementing the above the camera still passes through objects. I have a sphere with a collider and a rigibody (non kinematic) as the camera's child, and box colliders on my objects. Do you have any suggestions on what could be wrong? Thank you
     
  49. Grislymanor

    Grislymanor

    Joined:
    Aug 15, 2014
    Posts:
    23
    Any update on when/if the new ARKit "vertical plane" and "marker detection" will be added to the Unity plugin?
     
  50. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    The vertical plane you have a solution in the previous page, the marker detection no idea
     
Thread Status:
Not open for further replies.