Exemple #1
0
        CGSize MakeBackgroundTextureSize()
        {
            int width  = 0;
            int height = 0;

            unsafe
            {
                SDPlugin.SixDegreesSDK_GetBackgroundTextureSize(&width, &height);
            }
            if (width > 0 && height > 0)
            {
                return(new CGSize(width, height));
            }
            else
            {
                return(CGSize.Empty);
            }
        }
        void SetupARBackgroundTexture()
        {
            IntPtr texturePtr = IntPtr.Zero;

#if UNITY_IOS && !UNITY_EDITOR
            if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3)
            {
                int textureId = SDPlugin.SixDegreesSDK_GetEAGLBackgroundTexture();
                texturePtr = new IntPtr(textureId);
            }
            else
#endif
            {
                texturePtr = SDPlugin.SixDegreesSDK_GetBackgroundTexture();
            }

            if (texturePtr != IntPtr.Zero)
            {
                int width  = 1920;
                int height = 1080;
                unsafe
                {
                    int *widthPtr = &width, heightPtr = &height;
                    SDPlugin.SixDegreesSDK_GetBackgroundTextureSize(widthPtr, heightPtr);
                }

                Debug.Log("Create External Texture:" + texturePtr + "(" + width + "x" + height + ")");
                _ARBackgroundTexture = Texture2D.CreateExternalTexture(
                    width,
                    height,
                    TextureFormat.RGBA32,
                    false,
                    false,
                    texturePtr);
                _ARBackgroundTexture.filterMode = FilterMode.Point;
                _ARBackgroundTexture.name       = "AR_Background_Texture";
            }
        }