Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

ARKit support for iOS via Unity-ARKit-Plugin

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

  1. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    Disabling that component should work. You could also create a material with a black texture and put it in the place of YUVMaterial in the component.
     
  2. mtpzone

    mtpzone

    Joined:
    Dec 7, 2013
    Posts:
    3
    You can do something like this if you are using the default scripts or rename to match your script name and GameObject name. This will only turn off the hit when clicking over any item it is placed on .. but you can use the the same code to just turn it off and leave it off.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.EventSystems;
    3. using UnityEngine.XR.iOS;
    4.  
    5. public class OverInterface : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
    6.  
    7.     private GameObject HitBox;
    8.  
    9.     void Reset()
    10.     {
    11.         HitBox = GameObject.Find("HitCube");
    12.     }
    13.  
    14.     public void OnPointerEnter (PointerEventData eventData)
    15.     {
    16.         HitBox.GetComponent<UnityARHitTestExample>().enabled=false;
    17.     }
    18.  
    19.     public void OnPointerExit (PointerEventData eventData)
    20.     {
    21.         HitBox.GetComponent<UnityARHitTestExample>().enabled=true;
    22.     }
    23. }
    24.  
    25.  
     
  3. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    Another one in the FAQ: make sure you have Development Build enabled when you build the Remote app.
     
  4. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    Because the example script uses Touches and HitTest. Add the EditorHitTest script (this is a new script) to your HitCube and setup Transform as for other script. Now it should work for both editor/remote and device.
     
    lancehall10 likes this.
  5. Rich0

    Rich0

    Joined:
    Aug 9, 2013
    Posts:
    49
  6. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    One way you could do it is something similar to the scaled-content branch of the repo. When you tap, have the parent of a second camera store the inverse of the translation and rotation offsets from the main camera. Now have the second camera get the camerapose the same way the main camera does. It should now be rendering as if it were starting from the origin. Then create a layer for everything in the portal (or that you want rendered by the second camera), and use that layer on the second camera's CullingMask.
     
    glenrhodes likes this.
  7. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    Sorry then, all I can suggest is submitting a bug report with your project. I had heard that Apple had solved some issues with ReplayKit in their GM code, but you say you have that. Do you have both XCode 9 GM as well as iOS 11 GM?
     
  8. Dipanker_Juego

    Dipanker_Juego

    Joined:
    Jun 28, 2017
    Posts:
    10
    Hi

    I have checked with all example scenes given in plugins (I have not modified anything in the scene, directly building and checking in device). I want to detect plane surface and spawn plane object, but I am facing a problem in plane detection, it wan't detect the floor or empty table at all, but if there is few objects kept in table then it detect properly.

    Its there any way to detect empty table or floor (Should I have to modify something with Unity object or scripts). I am using iPhone SE with iOS 11 beta.
     
  9. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    This is just an inherent limitation of the technology - ARKit does not use depth cameras, so it does not know where your table is if your table does not have some discernible texture or markings that allow the computer vision algorithms determine that there is something there. When it tries to detect floor or empty table, do you see the yellow dots? If not, it is not detecting feature points on the surface.
     
  10. Dipanker_Juego

    Dipanker_Juego

    Joined:
    Jun 28, 2017
    Posts:
    10
    Hi jimmya
    Thanks for the reply
    Yes there is yellow dot but very few like 3-4.
     
  11. arronpoon

    arronpoon

    Joined:
    Jul 25, 2017
    Posts:
    5
    My AR target shooting game was listed on the App Store on the iOS 11 launch date. I would like to thank the Unity ARKit plugin development team. Without your plugin, I could never release an AR game on the App Store. This thread is so helpful that I check a few times a day.

    If you want to taste an Unity-ARKit game, you can download my little game. It's free (and without any Ads and in-app purchase).
    aCen – https://itunes.apple.com/app/id1276116927

    This is my first ever built App, and this is my first Unity project. That's why it is a little bit unfinished, and a little bit buggy. If you have any comment/suggestions on how to improve this game please do not hesitate to send me a message or write me a review on App Store. I will keep improving this game by learning more from you guys.

    Once again, thank you Unity ARKit development team.
     
    DanTaylor and christophergoy like this.
  12. Rich0

    Rich0

    Joined:
    Aug 9, 2013
    Posts:
    49
    Yes - have GM XCode 9 and iOS 11GM.
     
  13. DerekLerner

    DerekLerner

    Joined:
    Jun 12, 2017
    Posts:
    19
    Thank you again! This works.
     
  14. roddles

    roddles

    Joined:
    Jan 22, 2014
    Posts:
    3
    Is there a way to configure UIRequiredDeviceCapabilities (or enter pinfo.list customizations in Unity)?

    I would like to add an entry in the UIRequireDeviceCapabilities array in my compiled iOS app's pinfo.list, of, e.g. 'arkit'. I can do this manually from within Xcode, obviously, but there is a chance that it will be forgotten before AppStore submission. Configuring this within Unity's iOS PlayerSettings inspector would be ideal; is this possible, if so how?

    Background: adding the 'arkit' entry in Req'd Device Capabilities will prevent users from purchasing and installing it on apps that don't support ARKit (something the many of the early ARKit apps are failing to do, thus getting a ton of 1 star ratings from people with unsupported devices. Derp.)
     
  15. lancehall10

    lancehall10

    Joined:
    Jul 13, 2015
    Posts:
    6
    Now I got it working on editor, still not phone.
     
  16. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    ARKit Remote is supposed to allow you to run your project in Editor where you can tweak it in realtime and do all the things Editor allows you to do. When you are done tweaking, build your project out to your phone for final testing.
     
    lancehall10 likes this.
  17. Dipanker_Juego

    Dipanker_Juego

    Joined:
    Jun 28, 2017
    Posts:
    10
    Hi guys

    Is it possible to detect walls ?
     
  18. ProffessoVR

    ProffessoVR

    Joined:
    Jun 22, 2015
    Posts:
    4
    not sure if this has been asked before, but is it possible to get the video passthrough output to a rendertarget texture?

    thanks!
     
  19. lancehall10

    lancehall10

    Joined:
    Jul 13, 2015
    Posts:
    6
    Okay thank you! Just making sure I wasn’t missing anymore steps.
     
  20. syverlauritz

    syverlauritz

    Joined:
    Apr 2, 2015
    Posts:
    1
    As soon as I connect my iPhone 7 using the remote app I get massive stuttering on the phone's camera stream. Like 1 frame per second. The Unity editor doesn't change, still shows the green screen. As soon as I stop playing in Unity the camera stream reverts to 60fps. I did see one other poster with the exact same issue but I couldn't find any answers.

    Does anyone know how to fix this?

    EDIT: To clarify, I'm in EditorTestScene. It has the ARKitRemoteConnetion prefab in it. The remote app is using Development build.

    EDIT: After restarting my computer (MacBook Pro 2017) I managed to get the camera feed into the editor. However, there is still absolutely massive lag. Both my phone and computer only manage about 1 frame per second, and the editor window is lagging about five seconds after the phone. In other words, something is still very wrong and I'm still looking for help.

    SOLUTION: Dear future people with this exact same issue trying to Google your way to a solution: I think I found it. Or at least things are working for me now. When selecting a player under Connected Player, try STARTING with a different player. Specifically, I had the choice between two players which both meant my phone. Every time I tried getting it to work, I started with the top one and then moved down the list. To solve it, I started with the bottom one instead and it started working. Weird, I know. And I have no idea why this solved it, but I was able to recreate the issue by trying to select the top one again.
     
    Last edited: Sep 22, 2017
    KwahuNashoba and paulkre like this.
  21. Mercurial2

    Mercurial2

    Joined:
    Apr 5, 2017
    Posts:
    1
    Should I be able to build remotely with the free Unity license or do I need Unity plus? I keep getting 'Failed to connect to player' error.
     
  22. Caustics

    Caustics

    Joined:
    Jan 5, 2016
    Posts:
    6
    Hey Everyone. This is a great thread! I actually found some helpful info here about the ability to catch a shadow for an AR project. I am not having luck with it at this time and was wondering if anyone can help. I've use the ARKit prefab called "shadowPlanePrefab". I put it in Unity, and I see it under my object. The shadows position though doesn't make contact with my objects. If it grab the plane and move it down in Y I see the whole shadow but the plane is now under the grid 0 0 0. If I move the object up in Y I get the same result, but my object floats. The plane or object only need to be moved slightly, -.6 units or .6 units in Y, but they appear very far apart. I have even built a scene where the object floats and I still don't see the shadows when on my iPad. Please let me know if anyone else has come across this issue, and if you can help me out. Thanks so much!
     
  23. Jason-RT-Bond

    Jason-RT-Bond

    Joined:
    Mar 26, 2012
    Posts:
    62
    Just a thought, but check your light in the inspector and adjust "bias", "normal bias" and/or "near plane"? Could just be a lighting issue rather than an ARKit one.
     
  24. Caustics

    Caustics

    Joined:
    Jan 5, 2016
    Posts:
    6
    Did I mention "It was me"? Thank you SO much that was it in Unity. Building for XCode right now!
     
  25. Caustics

    Caustics

    Joined:
    Jan 5, 2016
    Posts:
    6
    Ok, so in Unity it is perfect, but it doesn't show via my build on the iPad? It's totally something I'm doing but I have no idea what.
     
  26. Sathyamurthy

    Sathyamurthy

    Joined:
    Feb 4, 2016
    Posts:
    4
    I just placed an object under HitCubeParent and when I run in ios it works fine. But I want to rotate the object placed under HitCubeParent. How to rotate it? And if I touch the screen I just want it to place one time. Every time I am touching the screen it is changing the position to where I am touching. How to do it?
     
  27. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    203
    This solution cured my Mapbox/Arkit/Unity app crashes. Thanks for this!

    https://github.com/mapbox/mapbox-arkit-unity
     
  28. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    That is very old code - it was updated a couple of days after the new Beta XCode dropped. Please update your plugin code, get latest XCode and iOS, and everything should be in sync.
     
  29. samchoi

    samchoi

    Joined:
    Jun 1, 2017
    Posts:
    1
    hi ,
    I am newbie in unity. I follow the youtube video,

    and successfully create a Zombie with UNITY ARKit.

    Now I ENABLE the "GeneratePlanes" as well and let the Zombie only can create on a PLANE. It work as well.
    But when I press "Walk" button it will finally run out of the PLANE.

    I have add below script to limit the Zombie position, but it fail.
    //--------------------------------------------------------------------

    // Update is called once per frame
    void Update () {
    if ( isWithinBoundary()==true) {
    transform.Translate (Vector3.forward * Time.deltaTime * (transform.localScale.x * .05f));

    }
    }

    private bool isWithinBoundary()
    {
    ARPoint Apoint = new ARPoint {
    x = transform.position.x,
    y = transform.position.y
    };


    List<ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface ().HitTest (Apoint,
    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent

    //,ARHitTestResultType.ARHitTestResultTypeExistingPlane
    // ,ARHitTestResultType.ARHitTestResultTypeHorizontalPlane
    //ARHitTestResultType.ARHitTestResultTypeFeaturePoint
    );

    if (hitResults.Count > 0) {
    foreach (var hitResult in hitResults) {
    return true;
    }
    }

    return false;
    }

    //--------------------------------------------------------------------
    So, am i do wrong? is there any way to do this?

    thanks in adv,
    sam
     
  30. elitemantis

    elitemantis

    Joined:
    Nov 14, 2012
    Posts:
    5
    Hi, I have a quick question: why do we need the ARkit HitTest? If we put our objects in the scene with ARkit won't they react to normal raycasts any more?

    Basically, when I spawn a Collision Plane, what's the reason for not using a simple Physics.Raycast?

    I have tried raycasting against a collision plane spawned, debug rays go through it (used Debug.Ray to visualise them)and nothing registers (hit my other objects in the scene though). I have also created a component with IPointerDownHandler, but still nothing.

    Would be really useful to consolidate all my input handlers and I have no idea how to prevent UI from blocking the event from happening right now.
     
    Last edited: Sep 25, 2017
  31. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    If you create a plane with a collision when the plane is created, it should work with a raycast. I would check the Layer on the collision and the raycast length etc. And read this page https://docs.unity3d.com/Manual/CollidersOverview.html
     
  32. elitemantis

    elitemantis

    Joined:
    Nov 14, 2012
    Posts:
    5
    Hah, no, I've found the culprit.

    So, you know how colliderPlanPrefab has the child that is on standard set scale to 0.125, 0.125, 0.125? During runtime it scale in Y was set to 0, and thus it ignored collision. Seems that arPlaneAnchor having extent in Y on 0 was causing the problem.

    I went to UnityARUtility.cs and modified the method:

    Code (CSharp):
    1.         public static GameObject UpdatePlaneWithAnchorTransform(GameObject plane, ARPlaneAnchor arPlaneAnchor)
    2.         {
    3.          
    4.             //do coordinate conversion from ARKit to Unity
    5.             plane.transform.position = UnityARMatrixOps.GetPosition (arPlaneAnchor.transform);
    6.             plane.transform.rotation = UnityARMatrixOps.GetRotation (arPlaneAnchor.transform);
    7.  
    8.             MeshFilter mf = plane.GetComponentInChildren<MeshFilter> ();
    9.  
    10.             if (mf != null) {
    11.                 //since our plane mesh is actually 10mx10m in the world, we scale it here by 0.1f
    12.                 //mf.gameObject.transform.localScale = new Vector3(arPlaneAnchor.extent.x * 0.1f ,arPlaneAnchor.extent.y * 0.1f ,arPlaneAnchor.extent.z * 0.1f );
    13.                 mf.gameObject.transform.localScale = new Vector3(arPlaneAnchor.extent.x * 0.1f ,1 ,arPlaneAnchor.extent.z * 0.1f ); // change the Y scale to 1
    14.  
    15.                 //convert our center position to unity coords
    16.                 mf.gameObject.transform.localPosition = new Vector3(arPlaneAnchor.center.x,arPlaneAnchor.center.y, -arPlaneAnchor.center.z);
    17.             }
    18.  
    19.             return plane;
    20.         }
    This fixed it. Is this intended behaviour?
     
    Last edited: Sep 25, 2017
    roddles likes this.
  33. devnoid

    devnoid

    Joined:
    Feb 3, 2016
    Posts:
    9
    Would you mind expanding on this a bit more? How does one restart the session and what is the benefit of doing so?
     
  34. geozebra_unity

    geozebra_unity

    Joined:
    Sep 26, 2017
    Posts:
    1
    hi,how arkit tracks 3d object just like "Apple Park AR" , url =
     
    JelmerV and sama-van like this.
  35. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,596
    Hi!
    It's been a while :)

    Got the smart idea to update Xcode 9 and my device with iOS11 to the last revision which aren't beta anymore...
    Below a cool message I do not success to override... Screen Shot 2017-09-26 at 16.37.36.png
    - closed properly every single software
    - delete my Xcode project.
    - mac reboot
    - made a new xcode project
    - then once installing on device the pop up remains... :(

    Any idea?
     
  36. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,596
    Gonna answer to myself in case someone is having the same issue...
    iOS11 really doesn't want armv7 anymore.
    Then if you compile from Unity with mono2x it will (of course) remove IL2CPP (64bits).

    I think Unity should remove this from the build settings? to force IL2CPP anyway?
     
  37. prabhusam

    prabhusam

    Joined:
    Aug 3, 2017
    Posts:
    6
  38. 4NDDYYYY

    4NDDYYYY

    Joined:
    Jan 28, 2016
    Posts:
    13
    no.
     
  39. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,596
    woops one more issue...

    Using Prime31 Etcetera plugins with the feature "imagePicker" to select a pic from the library or to take a picture.

    Once done with it and back the camera freeze (not refreshed anymore), and then the following message from xCode which concern the ARkit :

    Any idea what is happening?

    Thank you :)

    EDIT : Not related directly to Unity but someone is having a similar issue with the ARkit :
    https://stackoverflow.com/questions...nce-is-being-affected-by-resource-constraints

    EDIT 2: Tried to *.Pause() the current session (which works) then to *.Run() it again, but I have a new list of messages poping as below :

    EDIT 3 :
    Actually it sometime works but the tracking become very unstable...
    Something like this :
    https://stackoverflow.com/questions/19391300/avcapture-session-slow-launch-after-session-restart

    Does the ARKit included OnApplicationPause() ?
    Or should we do it on our end finally?
    That could be the issue...
     
    Last edited: Sep 27, 2017
  40. DanTaylor

    DanTaylor

    Joined:
    Jul 6, 2013
    Posts:
    92
    Quick question...
    I see it is possible to open an AR Session.
    But how the devil does one close it?

    Longer version...
    Having a lot of fun adding AR to our little app, Tsuro. Almost got it working. The plug-in is awesome!
    If the player decides that he (or she) would rather play in the traditional fashion, and exits AR mode, we'll need to shut down the AR Session. So far I can't seem to find a way of doing this. Any ideas?

    Suggestions welcome!

    Thanks,
    Dan
     
  41. MikkoHaapoja

    MikkoHaapoja

    Joined:
    Dec 2, 2016
    Posts:
    6
    Hey. I've been working on the app Placer Cam. I had some really bad issues with ReplayKit so I've ripped it out and replaced it with another screen recording library. This library requires an OpenGL context.

    For awhile I've been using the opengl compatibility branch that was merged in here: https://bitbucket.org/Unity-Technol...support-opengl-es-2-as-the-rendering-api/diff

    I noticed that this branch was merged so I updated the ARKit plugin and now I'm seeing this issue that was discussed earlier:

    ```
    "_MTLCreateSystemDefaultDevice", referenced from: -[UnityARSession setupMetal] in ARSessionNative.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ```
     
    ina, ryo0ka and sama-van like this.
  42. DanTaylor

    DanTaylor

    Joined:
    Jul 6, 2013
    Posts:
    92
    Ah... I think I understand... You can't close a session, but you can pause it and use the options to reset it when you restart it. All good! :D
     
    petey and sama-van like this.
  43. idorurei

    idorurei

    Joined:
    Sep 20, 2017
    Posts:
    7
    Has anyone successfully used SetCamera(<camera>) in UnityARCameraManager.cs? If so, what was the intended goal?
     
  44. DanTaylor

    DanTaylor

    Joined:
    Jul 6, 2013
    Posts:
    92
    Another question. The AR tracking jitters a little bit when stationary... presumably as the tacking adjusts. How might one dampen this jitter? I tried a few methods, but none did the trick. Lerping made the AR tracking slushy, and setting a movement threshold made the tracking choppy. Any suggestions?
     
  45. MrXLR8

    MrXLR8

    Joined:
    Sep 22, 2017
    Posts:
    3
    Is it possible to register "Hits" when connected using Remote connection method? When I run app it registers hits well, but when I am doing it in editor it registers no hit. (Yes I optimised script for mouse)
     
  46. MMVR-2

    MMVR-2

    Joined:
    Feb 17, 2017
    Posts:
    1
    Can anyone help me understand how I can tap on a ball inside the example "ARBallz" scene? Currently, if you tap on a detected plane, the Ballmaker.cs script generates a ball. How can I modify this touch input code to select a ball if the user taps on one, or generate a ball if the user taps on the detected plane? I'm very new to Unity, thanks for your help!

    /////// From Ballmaker.cs script
    void Update () {
    if (Input.touchCount > 0 )
    {
    var touch = Input.GetTouch(0);
    if (touch.phase == TouchPhase.Began)
    var screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
    ARPoint point = new ARPoint
    {
    x = screenPosition.x,
    y = screenPosition.y
    };
    List<ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(point,
    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent);
    if (hitResults.Count > 0)
    {
    foreach (var hitResult in hitResults)
    {
    Vector3 position = UnityARMatrixOps.GetPosition(hitResult.worldTransform);
    CreateBall(new Vector3(position.x, position.y + createHeight, position.z));
    break;
    }
    }

    } ...
     
  47. ftarnogol

    ftarnogol

    Joined:
    Feb 2, 2013
    Posts:
    5
    Hi Guys,

    I am using the ARFrameUpdated script to post statuses to a UI Text. But when I assign the Text to the UI Variable it seems that the values are not passed since in the editor and on the phone I still see "New Text" instead of the string.

    I've tried attaching the script to its own GameObject, to the camera and other components but I still get the same result.

    Thank you!
     
    Last edited: Sep 28, 2017
  48. HaimBendanan

    HaimBendanan

    Joined:
    May 10, 2016
    Posts:
    28
    I have the same issues sometimes after playing a movie full screen (inside the app) and coming back to the plane tracking.
     
  49. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    115
  50. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    250
    jimmya likes this.
unityunity