Q:

Unity : UI Elements out of Camera .. (all images & Code inside)

I finished my first simple 2D game finally .. but now i hit a wall .. i'm trying to adjust the game for multiple screens (Android ) . I build the game on 1080 x 1920 resolution.. And now to make it adapt with different screens resolutions i used this Code and its working for me ..
public class ControllingCameraAspectScript : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
        // set the desired aspect ratio (the values in this example are
        // hard-coded for 16:9, but you could make them into public
        // variables instead so you can set them at design time)
        float targetaspect = 1080.0f / 1920.0f;

        // determine the game window's current aspect ratio
        float windowaspect = (float)Screen.width / (float)Screen.height;

        // current viewport height should be scaled by this amount
        float scaleheight = windowaspect / targetaspect;

        // obtain camera component so we can modify its viewport
        Camera camera = GetComponent<Camera>();

        // if scaled height is less than current height, add letterbox
        if (scaleheight < 1.0f)
        {
            Rect rect = camera.rect;

            rect.width = 1.0f;
            rect.height = scaleheight;
            rect.x = 0;
            rect.y = (1.0f - scaleheight) / 2.0f;

            camera.rect = rect;
        }
        else // add pillarbox
        {
            float scalewidth = 1.0f / scaleheight;

            Rect rect = camera.rect;

            rect.width = scalewidth;
            rect.height = 1.0f;
            rect.x = (1.0f - scalewidth) / 2.0f;
            rect.y = 0;

            camera.rect = rect;
        }
    }

}

thank god the Game Objects in place .. but the UI Elements out of the Camera .. please look to the images ..
This is 1080 x 1920 .. my original work .
and this is on another device 1536 x 2048 ..
And i'm already using Canvas Scaler and Anchors with UI elements ..

A:

The simple solution i found for my problem is to follow this tutorial ..
http://gamedesigntheory.blogspot.ie/2010/09/controlling-aspect-ratio-in-unity.html

