Exemple #1
0
        // Token: 0x0600BF9A RID: 49050 RVA: 0x00357244 File Offset: 0x00355444
        protected override void OnStop()
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_OnStop_hotfix != null)
            {
                this.m_OnStop_hotfix.call(new object[]
                {
                    this
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            base.OnStop();
            InviteNotifyUITask.EnableDispaly();
            NoticeUIController.IsForceHide = false;
            UnityARSessionNativeInterface          arsessionNativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTrackingSessionConfiguration config = default(ARKitWorldTrackingSessionConfiguration);

            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = false;
            config.enableLightEstimation = false;
            if (config.IsSupported)
            {
                arsessionNativeInterface.RunWithConfig(config);
            }
            arsessionNativeInterface.Pause();
        }
        private void ConfigureSession(bool togglePlaneDetection, bool clearOldPlanes)
        {
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

            if (togglePlaneDetection)
            {
                if (UnityARSessionNativeInterface.IsARKit_1_5_Supported())
                {
                    config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;
                }
                else
                {
                    config.planeDetection = UnityARPlaneDetection.Horizontal;
                }
            }
            else
            {
                config.planeDetection = UnityARPlaneDetection.None;
            }

            if (clearOldPlanes)
            {
                mPlaneGenerator.ClearPlanes();
            }

            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;

            UnityARSessionRunOption options = new UnityARSessionRunOption();

            //options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors;
            mSession.RunWithConfigAndOptions(config, options);
        }
Exemple #3
0
        // Use this for initialization
        public override IEnumerator StartService(Settings settings)
        {
            m_SessionConfig = new ARKitWorldTrackingSessionConfiguration(
                UnityARAlignment.UnityARAlignmentGravity,
                settings.enablePlaneDetection ? UnityARPlaneDetection.Horizontal : UnityARPlaneDetection.None,
                settings.enablePointCloud,
                settings.enableLightEstimation);

            if (!IsSupported)
            {
                Debug.LogError("The requested ARKit session configuration is not supported");
                return(null);
            }

            UnityARSessionRunOption runOptions =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            nativeInterface.RunWithConfigAndOptions(
                m_SessionConfig, runOptions);

            // Register for plane detection
            UnityARSessionNativeInterface.ARAnchorAddedEvent       += AddAnchor;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent     += UpdateAnchor;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent     += RemoveAnchor;
            UnityARSessionNativeInterface.ARFrameUpdatedEvent      += UpdateFrame;
            UnityARSessionNativeInterface.ARUserAnchorUpdatedEvent += UpdateUserAnchor;

            IsRunning = true;

            return(null);
        }
Exemple #4
0
        public override IEnumerator Start(Configuration _config)
        {
            m_config = new ARKitWorldTrackingSessionConfiguration(
                UnityARAlignment.UnityARAlignmentGravity,
                (UnityARPlaneDetection)_config.mode,
                _config.enablePointCloud,
                _config.enableLightEstimation
                );

            if (!IsSupported)
            {
                throw new NotSupportedException("ARKit not supported, your device may not be powerful enough.");
            }

            var runOptions =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            NativeInterface.RunWithConfigAndOptions(m_config, runOptions);

            //Register Callbacks
            UnityARSessionNativeInterface.ARAnchorAddedEvent       += AddAnchor;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent     += UpdateAnchor;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent     += RemoveAnchor;
            UnityARSessionNativeInterface.ARFrameUpdatedEvent      += UpdateFrame;
            UnityARSessionNativeInterface.ARUserAnchorUpdatedEvent += UpdateUserAnchor;

            IsRunning = true;

            return(null);
        }
    /// <summary>
    /// Resumes the AR session, if paused.
    /// </summary>
    public override void ResumeSession()
    {
        if (isSessionPaused)
        {
            isSessionPaused = false;

            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.alignment      = cameraAlignment;
            config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;

            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            config.enableAutoFocus       = true;

            if (arImageDatabase != null)
            {
                config.referenceImagesGroupName = arImageDatabase.resourceGroupName;
                Debug.Log("ResumeSession - config.arResourceGroupName set to: " + arImageDatabase.resourceGroupName);
            }

            UnityARSessionRunOption runOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                                                 UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOptions);
        }
    }
        public UniTask Load(string dirPath)
        {
            string     path     = GetPath(dirPath);
            ARWorldMap worldMap = ARWorldMap.Load(path);

            Debug.Log($"ARWorldMap loaded from {path}");

            ARKitWorldTrackingSessionConfiguration config = _camera.sessionConfiguration;

            config.worldMap = worldMap;

            const UnityARSessionRunOption runOption =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            UnityARSessionNativeInterface
            .ARSessionShouldAttemptRelocalization = true;

            UnityARSessionNativeInterface
            .GetARSessionNativeInterface()
            .RunWithConfigAndOptions(config, runOption);

            Debug.Log("Restarted session with worldMap");

            return(UniTask.CompletedTask);
        }
Exemple #7
0
    //arkit manager

    //

    void OnEnable()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();


#if !UNITY_EDITOR
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //put some defaults so that it doesnt complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
    }
Exemple #8
0
        public void Start()
        {
            //Debug.Log("ARKitBridge: Start: Setting Input.compensateSensors from " + Input.compensateSensors + " to false.");
            Input.compensateSensors = false;

            UnityARSessionNativeInterface.ARFrameUpdatedEvent             += FrameUpdate;
            UnityARSessionNativeInterface.ARAnchorAddedEvent              += AddAnchor;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent            += UpdateAnchor;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent            += RemoveAnchor;
            UnityARSessionNativeInterface.ARUserAnchorAddedEvent          += AddUserAnchor;
            UnityARSessionNativeInterface.ARUserAnchorUpdatedEvent        += UpdateUserAnchor;
            UnityARSessionNativeInterface.ARUserAnchorRemovedEvent        += RemoveUserAnchor;
            UnityARSessionNativeInterface.ARSessionFailedEvent            += SessionFailed;
            UnityARSessionNativeInterface.ARSessionInterruptedEvent       += SessionInterrupted;
            UnityARSessionNativeInterface.ARSessioninterruptionEndedEvent += SessionInterruptionEnded;
            UnityARSessionNativeInterface.ARSessionTrackingChangedEvent   += SessionTrackingChanged;

            arSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            arSession.RunWithConfig(config);
#endif
        }
    private void Awake()
    {
        instance = this;                    // インスタンス取得
        Application.targetFrameRate = 60;   // fpsセット
        DontDestroyOnLoad(gameObject);      // 永続化

        // ARKitセッションの初期化 ----
        session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = UnityARPlaneDetection.Horizontal;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = false;
        session.RunWithConfig(config);  // セッション実行

        // Cameraがなければ取得
        if (trackingCamera == null)
        {
            trackingCamera = Camera.main;
        }
        // Cardboardの自動ヘッドトラッキング停止
        UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(trackingCamera, true);
        // シーン遷移時のイベント登録
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Exemple #10
0
        private void OnGUI()
        {
            if (GUI.Button(new Rect(100f, 100f, 200f, 50f), "Stop"))
            {
                UnityARSessionNativeInterface.GetARSessionNativeInterface().Pause();
            }
            if (GUI.Button(new Rect(300f, 100f, 200f, 50f), "Start"))
            {
                ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(alignmentOptions[currentAlignmentIndex], planeOptions[currentPlaneIndex]);
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOptions[currentOptionIndex]);
            }
            if (GUI.Button(new Rect(100f, 300f, 200f, 100f), "Start Non-WT Session"))
            {
                ARKitSessionConfiguration config2 = new ARKitSessionConfiguration(alignmentOptions[currentAlignmentIndex], getPointCloudData: true, enableLightEstimation: true);
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfig(config2);
            }
            string str = (currentOptionIndex == 0) ? "Full" : ((currentOptionIndex == 1) ? "Tracking" : ((currentOptionIndex != 2) ? "None" : "Anchors"));

            if (GUI.Button(new Rect(100f, 200f, 150f, 50f), "RunOption:" + str))
            {
                currentOptionIndex = (currentOptionIndex + 1) % 4;
            }
            string str2 = (currentAlignmentIndex == 0) ? "Camera" : ((currentAlignmentIndex != 1) ? "GravityAndHeading" : "Gravity");

            if (GUI.Button(new Rect(300f, 200f, 150f, 50f), "AlignOption:" + str2))
            {
                currentAlignmentIndex = (currentAlignmentIndex + 1) % 3;
            }
            string str3 = (currentPlaneIndex != 0) ? "None" : "Horizontal";

            if (GUI.Button(new Rect(500f, 200f, 150f, 50f), "PlaneOption:" + str3))
            {
                currentPlaneIndex = (currentPlaneIndex + 1) % 2;
            }
        }
    public void StartSession(ARWorldMap arWorldMap = null)
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration
        {
            planeDetection        = planeDetection,
            alignment             = startAlignment,
            getPointCloudData     = getPointCloud,
            enableLightEstimation = enableLightEstimation,
            enableAutoFocus       = enableAutoFocus,
            worldMap = arWorldMap
        };

        if (detectionImages != null)
        {
            config.referenceImagesGroupName = detectionImages.resourceGroupName;
        }

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
Exemple #12
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }

        UnityARSessionRunOption options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        m_session.RunWithConfigAndOptions(config, options);
    }
Exemple #13
0
    public void ResetScene()
    {
        Debug.Log("session reset");
        ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.Horizontal, true, false);

        UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking);
    }
Exemple #14
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        config = new ARKitWorldTrackingSessionConfiguration();
        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        config.enableAutoFocus       = enableAutoFocus;
        if (detectionImages != null)
        {
            config.arResourceGroupName = detectionImages.resourceGroupName;
        }

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
    }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if UNITY_EDITOR
        //UNITY EDITOR

        // Set tracking to Tracker or Headset Relay; Calibration/ARKit are not suitable
        // in the Unity Editor as it lacks 6DoF tracking
        tracking = TrackingType.TrackerRelay;

        //put some defaults so that it doesn't complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#else
        //iOS
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.startAlignment        = startAlignment;
        config.getPointCloudData     = false;
        config.enableLightEstimation = true;
        m_session.RunWithConfig(config);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#endif
    }
Exemple #16
0
    public void ToggleVideo()
    {
        UnityARVideo arVideo = m_camera.gameObject.GetComponent <UnityARVideo>();
        ARKitWorldTrackingSessionConfiguration _config = new ARKitWorldTrackingSessionConfiguration();

        if (arVideo.enabled && arVideo != null)
        {
            _config.enableAutoFocus       = false;
            _config.planeDetection        = UnityARPlaneDetection.None;
            _config.enableLightEstimation = false;
            _config.getPointCloudData     = false;
            m_session.Pause();
            arVideo.enabled = false;
        }
        else
        {
            _config.planeDetection        = planeDetection;
            _config.alignment             = startAlignment;
            _config.getPointCloudData     = getPointCloud;
            _config.enableLightEstimation = enableLightEstimation;
            _config.enableAutoFocus       = enableAutoFocus;
            m_camera.clearFlags           = CameraClearFlags.SolidColor;
            m_session.RunWithConfig(_config);
            arVideo.enabled = true;
        }
    }
    private void ConfigureSession(bool clearPlanes)
    {
                #if !UNITY_EDITOR
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        if (mPlaneDetectionToggle.GetComponent <Toggle>().isOn)
        {
            if (UnityARSessionNativeInterface.IsARKit_1_5_Supported())
            {
                config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;
            }
            else
            {
                config.planeDetection = UnityARPlaneDetection.Horizontal;
            }
            mPNPlaneManager.StartPlaneDetection();
        }
        else
        {
            config.planeDetection = UnityARPlaneDetection.None;
            if (clearPlanes)
            {
                mPNPlaneManager.ClearPlanes();
            }
        }

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        mSession.RunWithConfig(config);
                #endif
    }
Exemple #18
0
    public void Load(string fileName)
    {
        var worldMap = ARWorldMap.Load(Path.Combine(Application.persistentDataPath, string.Concat(fileName, ".worldmap")));

        if (worldMap != null)
        {
            windowManager.SpawnGuideToLoad();

            loadedWorldMapName = fileName;

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;
            relocalizing = true;
            startTime    = Time.time;

            ARKitWorldTrackingSessionConfiguration config = m_ARCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Line"))
            {
                Destroy(go);
            }

            session.RunWithConfigAndOptions(config, runOption);
        }
    }
Exemple #19
0
 void InitARConfig()
 {
     m_arconfig = new ARKitWorldTrackingSessionConfiguration();
     m_arconfig.planeDetection        = UnityARPlaneDetection.Horizontal;
     m_arconfig.alignment             = UnityARAlignment.UnityARAlignmentGravity;
     m_arconfig.getPointCloudData     = true;
     m_arconfig.enableLightEstimation = true;
 }
 private ARKitWorldTrackingSessionConfiguration setConfig(ARKitWorldTrackingSessionConfiguration config)
 {
     config.alignment             = startAlignment;
     config.getPointCloudData     = getPointCloud;
     config.enableLightEstimation = enableLightEstimation;
     config.enableAutoFocus       = enableAutoFocus;
     return(config);
 }
    public void ResetScene()
    {
        ballMaker.ClearBalls();


        ARKitWorldTrackingSessionConfiguration sessionConfig = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.HorizontalAndVertical, true, true);

        UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking);
    }
Exemple #22
0
    private void RunARkit(ARKitWorldTrackingSessionConfiguration configuration)
    {
        if (configuration.IsSupported && m_currentARkitStatus == false)
        {
            onSessionIsReady?.Invoke();

            m_session.RunWithConfig(configuration);
            m_currentARkitStatus = true;
        }
    }
 void PlaneDetectorSwitcher.turn_on_Detector(bool on_off)
 {
     if (!on_off)
     {
         ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
         config.planeDetection = UnityARPlaneDetection.None;
         config = setConfig(config);
         m_session.RunWithConfig(config);
     }
 }
Exemple #24
0
        // Use this for initialization
        void Start()
        {
            // Initialize some variables
            m_arMode = false;

            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            UnityARSessionNativeInterface.ARImageAnchorAddedEvent   += AddImageAnchor;
            UnityARSessionNativeInterface.ARImageAnchorUpdatedEvent += UpdateImageAnchor;
            UnityARSessionNativeInterface.ARImageAnchorRemovedEvent += RemoveImageAnchor;
            scene = GameObject.Find("Scene");

#if !UNITY_EDITOR
            Application.targetFrameRate = 60;
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = planeDetection;
            config.alignment             = startAlignment;
            config.getPointCloudData     = getPointCloud;
            config.enableLightEstimation = enableLightEstimation;
            config.enableAutoFocus       = enableAutoFocus;
            //config.maximumNumberOfTrackedImages = maximumNumberOfTrackedImages;
            //config.environmentTexturing = environmentTexturing;
            if (detectionImages != null)
            {
                //config.referenceImagesGroupName = detectionImages.resourceGroupName;
                config.arResourceGroupName = detectionImages.resourceGroupName;
            }

            //if (detectionObjects != null)
            //{
            //    config.referenceObjectsGroupName = "";  //lets not read from XCode asset catalog right now
            //    config.dynamicReferenceObjectsPtr = m_session.CreateNativeReferenceObjectsSet(detectionObjects.LoadReferenceObjectsInSet());
            //}

            if (config.IsSupported)
            {
                m_session.RunWithConfig(config);
                UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
            }

            if (m_camera == null)
            {
                m_camera = Camera.main;
            }
#else
            //put some defaults so that it doesnt complain
            UnityARCamera scamera = new UnityARCamera();
            scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
            Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
            scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

            UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
        }
    public void PlaneDetectionOFF()
    {
        planeDetection = UnityARPlaneDetection.None;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = false;
        config.enableLightEstimation = false;
        m_session.RunWithConfig(config);
    }
        private void StartARKit()
        {
            Application.targetFrameRate = 60;
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

            config.planeDetection        = UnityARPlaneDetection.Horizontal;
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            mSession.RunWithConfig(config);
        }
    private void SessionSleep()
    {
        ARKitWorldTrackingSessionConfiguration newConfig = new ARKitWorldTrackingSessionConfiguration();

        newConfig.planeDetection        = UnityARPlaneDetection.None;
        newConfig.alignment             = UnityARAlignment.UnityARAlignmentGravityAndHeading;
        newConfig.getPointCloudData     = false;
        newConfig.enableLightEstimation = false;

        UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfig(newConfig);
    }
    public void ResetScence()
    {
        ClearPoints();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(
            UnityARAlignment.UnityARAlignmentGravity,
            UnityARPlaneDetection.Vertical,
            true, true
            );

        m_session.RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors);
    }
Exemple #29
0
    private void ConfigureSession(bool clearPlanes)
    {
#if !UNITY_EDITOR
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
        config.planeDetection        = UnityARPlaneDetection.None;
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.getPointCloudData     = true;
        config.enableLightEstimation = true;
        mSession.RunWithConfig(config);
#endif
    }
Exemple #30
0
    public void StopTracking()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = UnityARPlaneDetection.None;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        m_session.RunWithConfig(config);
    }