private void CreateSenseAR() { if (SenseARInstance == null) { SenseARInstance = (GameObject)Instantiate(SenseARBasePrefab, transform.position, transform.rotation); slamController = SenseARInstance.GetComponentInChildren <SenseARSLAMController>(); updateTexture = SenseARInstance.GetComponentInChildren <SenseARUpdateTexture>(); slamCameraPose = SenseARInstance.GetComponentInChildren <SenseARCameraPose>(); // display size return screen size when portrait mode //int ScreenWidth = 0, ScreenHeight = 0; //Session.GetNativeSession().SessionApi.GetDisplaySize(ref ScreenWidth, ref ScreenHeight); if (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight) { //Screen.SetResolution(ScreenHeight, ScreenWidth, true); Screen.SetResolution(Screen.width, Screen.height, true); } else { //Screen.SetResolution(ScreenWidth, ScreenHeight, true); Screen.SetResolution(Screen.height, Screen.width, true); } } }
// Use this for initialization void Start() { m_NativeSession = Session.GetNativeSession(); standardARCameraPose = GetComponent <SenseARCameraPose>(); m_NativeSession.getTextureSize(ref FrameWidth, ref FrameHeight); AspectRatio = (float)FrameWidth / FrameHeight; Debug.Log("frame width: " + FrameWidth + " frame height: " + FrameHeight + " aspect: " + AspectRatio); _videoTexture_Y_bytes = new byte[FrameWidth * FrameHeight]; _videoTexture_uv_RGB_bytes = new byte[FrameWidth * FrameHeight / 4 * 3]; }
// Use this for initialization void Start() { m_NativeSession = Session.GetNativeSession(); SenseARCameraPose = GetComponent <SenseARCameraPose> (); #if UNITY_EDITOR genUnityTexturesForEditor(); _Material = rgbMaterial; #elif UNITY_ANDROID m_NativeSession.getTextureSize(ref FrameWidth, ref FrameHeight); AspectRatio = (float)FrameWidth / FrameHeight; Debug.Log("frame width: " + FrameWidth + " frame height: " + FrameHeight + " aspect: " + AspectRatio); //m_NativeSession.SessionApi.GetDisplaySize (ref ScreenWidth, ref ScreenHeight); //Debug.Log("screen width: " + ScreenWidth + " screen height: " + ScreenHeight); //Screen.SetResolution (Screen.width, Screen.height, true); _Material = yuvMaterial; bCommandBufferInitialized = false; genUnityTextures(); #endif }