private void _OnBeforeResumeSession(IntPtr sessionHandle) { if (SessionComponent == null || sessionHandle == IntPtr.Zero) { return; } NativeSession tempNativeSession = _GetNativeSession(sessionHandle); var listHandle = tempNativeSession.CameraConfigListApi.Create(); tempNativeSession.SessionApi.GetSupportedCameraConfigurationsWithFilter( SessionComponent.CameraConfigFilter, listHandle, m_TempCameraConfigHandles, m_TempCameraConfigs, SessionComponent.DeviceCameraDirection); if (m_TempCameraConfigHandles.Count == 0) { Debug.LogWarning( "Unable to choose a custom camera configuration because none are available."); } else { var configIndex = 0; if (SessionComponent.GetChooseCameraConfigurationCallback() != null) { configIndex = SessionComponent.GetChooseCameraConfigurationCallback()( m_TempCameraConfigs); } if (configIndex >= 0 && configIndex < m_TempCameraConfigHandles.Count) { var status = tempNativeSession.SessionApi.SetCameraConfig( m_TempCameraConfigHandles[configIndex]); if (status != ApiArStatus.Success) { Debug.LogErrorFormat( "Failed to set the ARCore camera configuration: {0}", status); } } for (int i = 0; i < m_TempCameraConfigHandles.Count; i++) { tempNativeSession.CameraConfigApi.Destroy(m_TempCameraConfigHandles[i]); } } // clean up tempNativeSession.CameraConfigListApi.Destroy(listHandle); m_TempCameraConfigHandles.Clear(); m_TempCameraConfigs.Clear(); }
private ApiPrestoCallbackResult OnBeforeResumeSession(IntPtr sessionHandle) { ApiPrestoCallbackResult result = ApiPrestoCallbackResult.InvalidCameraConfig; if (SessionComponent == null || sessionHandle == IntPtr.Zero) { return(result); } NativeSession tempNativeSession = GetNativeSession(sessionHandle); var listHandle = tempNativeSession.CameraConfigListApi.Create(); tempNativeSession.SessionApi.GetSupportedCameraConfigurationsWithFilter( SessionComponent.CameraConfigFilter, listHandle, _tempCameraConfigHandles, _tempCameraConfigs, SessionComponent.DeviceCameraDirection); if (_tempCameraConfigHandles.Count == 0) { Debug.LogWarning( "Unable to choose a custom camera configuration because none are available."); } else { var configIndex = 0; if (SessionComponent.GetChooseCameraConfigurationCallback() != null) { configIndex = SessionComponent.GetChooseCameraConfigurationCallback()( _tempCameraConfigs); } if (configIndex >= 0 && configIndex < _tempCameraConfigHandles.Count) { var status = tempNativeSession.SessionApi.SetCameraConfig( _tempCameraConfigHandles[configIndex]); if (status != ApiArStatus.Success) { Debug.LogErrorFormat( "Failed to set the ARCore camera configuration: {0}", status); } else { result = ApiPrestoCallbackResult.Success; // sync the session configuration with the new camera direction. ExternApi.ArPresto_setConfigurationDirty(); } } for (int i = 0; i < _tempCameraConfigHandles.Count; i++) { tempNativeSession.CameraConfigApi.Destroy(_tempCameraConfigHandles[i]); } } // clean up tempNativeSession.CameraConfigListApi.Destroy(listHandle); _tempCameraConfigHandles.Clear(); _tempCameraConfigs.Clear(); return(result); }