Example #1
0
        void InitializeARKit(serializableARKitInit sai)
        {
                        #if !UNITY_EDITOR
            //get the config and runoption from editor and use them to initialize arkit on device
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTackingSessionConfiguration config = sai.config;
            UnityARSessionRunOption runOptions           = sai.runOption;
            m_session.RunWithConfigAndOptions(config, runOptions);

            UnityARSessionNativeInterface.ARFrameUpdatedEvent  += ARFrameUpdated;
            UnityARSessionNativeInterface.ARAnchorAddedEvent   += ARAnchorAdded;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved;
                        #endif
        }
Example #2
0
        void InitializeARKit(MessageEventArgs mea)
        {
            Debug.Log("init ARKit");
                        #if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTackingSessionConfiguration config = new ARKitWorldTackingSessionConfiguration();
            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFrameUpdatedEvent  += ARFrameUpdated;
            UnityARSessionNativeInterface.ARAnchorAddedEvent   += ARAnchorAdded;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved;
                        #endif
        }
Example #3
0
        void OnGUI()
        {
            if (GUI.Button(new Rect(100, 100, 200, 50), "Stop"))
            {
                UnityARSessionNativeInterface.GetARSessionNativeInterface().Pause();
            }

            if (GUI.Button(new Rect(300, 100, 200, 50), "Start"))
            {
                ARKitWorldTackingSessionConfiguration sessionConfig = new ARKitWorldTackingSessionConfiguration(alignmentOptions [currentAlignmentIndex], planeOptions[currentPlaneIndex]);
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, runOptions[currentOptionIndex]);
            }


            if (GUI.Button(new Rect(100, 300, 200, 100), "Start Non-WT Session"))
            {
                ARKitSessionConfiguration sessionConfig = new ARKitSessionConfiguration(alignmentOptions [currentAlignmentIndex], true, true);
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfig(sessionConfig);
            }


            string runOptionStr = (currentOptionIndex == 0 ? "Full" : (currentOptionIndex == 1 ? "Tracking" : (currentOptionIndex == 2 ? "Anchors" : "None")));

            if (GUI.Button(new Rect(100, 200, 150, 50), "RunOption:" + runOptionStr))
            {
                currentOptionIndex = (currentOptionIndex + 1) % 4;
            }

            string alignmentOptionStr = (currentAlignmentIndex == 0 ? "Camera" : (currentAlignmentIndex == 1 ? "Gravity" :  "GravityAndHeading"));

            if (GUI.Button(new Rect(300, 200, 150, 50), "AlignOption:" + alignmentOptionStr))
            {
                currentAlignmentIndex = (currentAlignmentIndex + 1) % 3;
            }

            string planeOptionStr = (currentPlaneIndex == 0 ? "Both" : (currentPlaneIndex == 1 ? "Horizontal" : (currentPlaneIndex == 2 ? "Vertical" : "None")));

            if (GUI.Button(new Rect(500, 200, 150, 50), "PlaneOption:" + planeOptionStr))
            {
                currentPlaneIndex = (currentPlaneIndex + 1) % 4;
            }
        }
Example #4
0
        public void RunWithConfig(ARKitWorldTackingSessionConfiguration config)
        {
#if !UNITY_EDITOR
            StartWorldTrackingSession(m_NativeARSession, config);
#endif
        }
Example #5
0
        public void RunWithConfigAndOptions(ARKitWorldTackingSessionConfiguration config, UnityARSessionRunOption runOptions)
        {
#if !UNITY_EDITOR
            StartWorldTrackingSessionWithOptions(m_NativeARSession, config, runOptions);
#endif
        }
Example #6
0
 private static extern void StartWorldTrackingSessionWithOptions(IntPtr nativeSession, ARKitWorldTackingSessionConfiguration configuration, UnityARSessionRunOption runOptions);
Example #7
0
 private static extern void StartWorldTrackingSession(IntPtr nativeSession, ARKitWorldTackingSessionConfiguration configuration);