// Update is called once per frame
    void Update()
    {
        if (manager && manager.IsInitialized())
        {
            Texture2D depthImage = manager ? manager.GetUsersLblTex() : null;

            if (bodySlicer && bodySlicer.getLastFrameTime() != lastFrameTime)
            {
                lastFrameTime = bodySlicer.getLastFrameTime();
                int sliceCount = bodySlicer.getBodySliceCount();

                if (depthImage)
                {
                    //depthImage = GameObject.Instantiate(depthImage) as Texture2D;

                    for (int i = 0; i < sliceCount; i++)
                    {
                        BodySliceData bodySlice = bodySlicer.getBodySliceData((BodySlice)i);

                        if (depthImage && bodySlice.isSliceValid &&
                            bodySlice.startDepthPoint != Vector2.zero && bodySlice.endDepthPoint != Vector2.zero)
                        {
                            KinectInterop.DrawLine(depthImage, (int)bodySlice.startDepthPoint.x, (int)bodySlice.startDepthPoint.y,
                                                   (int)bodySlice.endDepthPoint.x, (int)bodySlice.endDepthPoint.y, Color.red);
                        }
                    }

                    depthImage.Apply();
                }

                if (statusText)
                {
                    if (bodySlicer.getCalibratedUserId() != 0)
                    {
                        userHeight = bodySlicer.getUserHeight();
                        string sUserInfo = string.Format("User {0} Height: {1:F2} m", bodySlicer.playerIndex, userHeight);

                        float w1 = bodySlicer.getSliceWidth(BodySlice.TORSO_1);
                        float w2 = bodySlicer.getSliceWidth(BodySlice.TORSO_2);
                        float w3 = bodySlicer.getSliceWidth(BodySlice.TORSO_3);
                        float w4 = bodySlicer.getSliceWidth(BodySlice.TORSO_4);

                        sUserInfo += string.Format("\n\nTorso-4: {3:F2} m\nTorso-3: {2:F2} m\nTorso-2: {1:F2} m\nTorso-1: {0:F2} m", w1, w2, w3, w4);

                        statusText.text = sUserInfo;
                    }
                    else
                    {
                        statusText.text = string.Format("User {0} not found", bodySlicer.playerIndex);;
                    }
                }
            }

            if (backgroundImage)
            {
                backgroundImage.texture = depthImage;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (manager && manager.IsInitialized())
        {
            Texture2D depthImage = manager ? manager.GetUsersLblTex2D() : null;

            if (bodySlicer && bodySlicer.getLastFrameTime() != lastFrameTime)
            {
                lastFrameTime = bodySlicer.getLastFrameTime();
                int sliceCount = bodySlicer.getBodySliceCount();

                if (depthImage)
                {
                    //depthImage = GameObject.Instantiate(depthImage) as Texture2D;

                    for (int i = 0; i < sliceCount; i++)
                    {
                        BodySliceData bodySlice = bodySlicer.getBodySliceData((BodySlice)i);

                        if (depthImage && bodySlice.isSliceValid &&
                            bodySlice.startDepthPoint != Vector2.zero && bodySlice.endDepthPoint != Vector2.zero)
                        {
                            KinectInterop.DrawLine(depthImage, (int)bodySlice.startDepthPoint.x, (int)bodySlice.startDepthPoint.y,
                                                   (int)bodySlice.endDepthPoint.x, (int)bodySlice.endDepthPoint.y, Color.red);
                        }
                    }

                    depthImage.Apply();
                }

                if (statusText)
                {
                    if (bodySlicer.getCalibratedUserId() != 0)
                    {
                        userHeight = !float.IsNaN(userHeight) ? Mathf.Lerp(userHeight, bodySlicer.getUserHeight(), smoothFactor * Time.deltaTime) : bodySlicer.getUserHeight();
                        string sUserInfo = string.Format("User {0} Height: {1:F2} m", bodySlicer.playerIndex, userHeight);

                        userW1 = !float.IsNaN(userW1) ? Mathf.Lerp(userW1, bodySlicer.getSliceWidth(BodySlice.TORSO_1), smoothFactor * Time.deltaTime) : bodySlicer.getSliceWidth(BodySlice.TORSO_1);
                        userW2 = !float.IsNaN(userW2) ? Mathf.Lerp(userW2, bodySlicer.getSliceWidth(BodySlice.TORSO_2), smoothFactor * Time.deltaTime) : bodySlicer.getSliceWidth(BodySlice.TORSO_2);
                        userW3 = !float.IsNaN(userW3) ? Mathf.Lerp(userW3, bodySlicer.getSliceWidth(BodySlice.TORSO_3), smoothFactor * Time.deltaTime) : bodySlicer.getSliceWidth(BodySlice.TORSO_3);
                        userW4 = !float.IsNaN(userW4) ? Mathf.Lerp(userW4, bodySlicer.getSliceWidth(BodySlice.TORSO_4), smoothFactor * Time.deltaTime) : bodySlicer.getSliceWidth(BodySlice.TORSO_4);

                        sUserInfo += string.Format("\n\nTorso-4: {3:F2} m\nTorso-3: {2:F2} m\nTorso-2: {1:F2} m\nTorso-1: {0:F2} m", userW1, userW2, userW3, userW4);

                        statusText.text = sUserInfo;
                    }
                    else
                    {
                        statusText.text = string.Format("User {0} not found", bodySlicer.playerIndex);;
                    }
                }
            }

//			if (backgroundImage)
//			{
//				backgroundImage.texture = depthImage;
//			}
        }
    }