예제 #1
0
    private void ComputeResolution()
    {
        float deviceWidth;
        float deviceHeight;
        float leftX, rightX, topY, bottomY;

        deviceWidth  = Screen.width;
        deviceHeight = Screen.height;

        if (constraint == Constraint.Landscape)
        {
            camera.orthographicSize = 1f / camera.aspect * UnitsSize / 2f;
        }
        else
        {
            camera.orthographicSize = UnitsSize / 2f;
        }

        _height = 2f * camera.orthographicSize;
        _width  = _height * camera.aspect;

        float cameraX, cameraY;

        cameraX = camera.transform.position.x;
        cameraY = camera.transform.position.y;

        leftX   = cameraX - _width / 2;
        rightX  = cameraX + _width / 2;
        topY    = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl      = new Vector3(leftX, topY, 0);
        _tc      = new Vector3(cameraX, topY, 0);
        _tr      = new Vector3(rightX, topY, 0);
        Instance = this;

        /*	//камера йде вниз
         *      float pix = camera.orthographicSize * 2 * 100;
         *      Debug.Log(pix);
         *      float div = 1536/2 - pix/2;
         *      div /= 100.0f;
         *      camera.transform.position = new Vector3(0,-1*div,-10);
         */
    }
예제 #2
0
    private void ComputeResolution()
    {
        float deviceWidth;
        float deviceHeight;
        float leftX, rightX, topY, bottomY;

#if UNITY_EDITOR
        deviceWidth  = GetGameView().x;
        deviceHeight = GetGameView().y;
#else
        deviceWidth  = Screen.width;
        deviceHeight = Screen.height;
#endif

        /* Set the ortograpish size (shich is half of the vertical size) when we change the ortosize of the camera the item will be scaled
         * autoamtically to fit the size frame of the camera
         */
        GetComponent <Camera>().orthographicSize = 1f / GetComponent <Camera>().aspect *UnitsForWidth / 2f;

        //Get the new height and Widht based on the new orthographicSize
        _height = 2f * GetComponent <Camera>().orthographicSize;
        _width  = _height * GetComponent <Camera>().aspect;

        float cameraX, cameraY;
        cameraX = GetComponent <Camera>().transform.position.x;
        cameraY = GetComponent <Camera>().transform.position.y;

        leftX   = cameraX - _width / 2;
        rightX  = cameraX + _width / 2;
        topY    = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl = new Vector3(leftX, topY, 0);
        _tc = new Vector3(cameraX, topY, 0);
        _tr = new Vector3(rightX, topY, 0);

        GetComponent <Camera>().transform.position = new Vector3(GetComponent <Camera>().transform.position.x, _height * yFactor, -10);

        Instance = this;
    }
예제 #3
0
파일: CameraFit.cs 프로젝트: jreala/Numbers
    private void ComputeResolution()
    {
#pragma warning disable 219
        float deviceWidth;
        float deviceHeight;
#pragma warning restore 219
        float leftX, rightX, topY, bottomY;

#if UNITY_EDITOR
        deviceWidth  = GetGameView().x;
        deviceHeight = GetGameView().y;
#else
        deviceWidth  = Screen.width;
        deviceHeight = Screen.height;
#endif

        GetComponent <Camera>().orthographicSize = 1f / GetComponent <Camera>().aspect *UnitsForWidth / 2f;
        //GetComponent<Camera>().orthographicSize = UnitsForWidth / 2f;

        _height = 2f * GetComponent <Camera>().orthographicSize;
        _width  = _height * GetComponent <Camera>().aspect;

        float cameraX, cameraY;
        cameraX = GetComponent <Camera>().transform.position.x;
        cameraY = GetComponent <Camera>().transform.position.y;

        leftX   = cameraX - _width / 2;
        rightX  = cameraX + _width / 2;
        topY    = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl      = new Vector3(leftX, topY, 0);
        _tc      = new Vector3(cameraX, topY, 0);
        _tr      = new Vector3(rightX, topY, 0);
        Instance = this;
    }
예제 #4
0
    private void ComputeResolution()
    {
        float deviceWidth;
        float deviceHeight;
        float leftX, rightX, topY, bottomY;

        deviceWidth  = Screen.width;
        deviceHeight = Screen.height;

        if (constraint == Constraint.Landscape)
        {
            camera.orthographicSize = 1f / camera.aspect * UnitsSize / 2f;
        }
        else
        {
            camera.orthographicSize = UnitsSize / 2f;
        }

        _height = 2f * camera.orthographicSize;
        _width  = _height * camera.aspect;

        float cameraX, cameraY;

        cameraX = camera.transform.position.x;
        cameraY = camera.transform.position.y;

        leftX   = cameraX - _width / 2;
        rightX  = cameraX + _width / 2;
        topY    = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl      = new Vector3(leftX, topY, 0);
        _tc      = new Vector3(cameraX, topY, 0);
        _tr      = new Vector3(rightX, topY, 0);
        Instance = this;
    }
예제 #5
0
    private void ComputeResolution()
    {
        float deviceWidth;
        float deviceHeight;
        float leftX, rightX, topY, bottomY;

        deviceWidth = Screen.width;
        deviceHeight = Screen.height;

        if (constraint == Constraint.Landscape)
        {
            camera.orthographicSize = 1f / camera.aspect * UnitsSize / 2f;
        }
        else
        {
            camera.orthographicSize = UnitsSize / 2f;
        }

        _height = 2f * camera.orthographicSize;
        _width = _height * camera.aspect;

        float cameraX, cameraY;
        cameraX = camera.transform.position.x;
        cameraY = camera.transform.position.y;

        leftX = cameraX - _width / 2;
        rightX = cameraX + _width / 2;
        topY = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl = new Vector3(leftX, topY, 0);
        _tc = new Vector3(cameraX, topY, 0);
        _tr = new Vector3(rightX, topY, 0);
        Instance = this;
    }
예제 #6
0
    private void ComputeResolution()
    {
        float deviceWidth;
        float deviceHeight;
        float leftX, rightX, topY, bottomY;

        #if UNITY_EDITOR
        deviceWidth = GetGameView().x;
        deviceHeight = GetGameView().y;
        #else
        deviceWidth = Screen.width;
        deviceHeight = Screen.height;
        #endif

        GetComponent<Camera>().orthographicSize = 1f / GetComponent<Camera>().aspect * UnitsForWidth / 2f;

        if (landscape)
        {
            _height = 2f * GetComponent<Camera>().orthographicSize;
            _width = _height * GetComponent<Camera>().aspect;
        }
        else
        {
            _width = 2f * GetComponent<Camera>().orthographicSize;
            _height = _width * GetComponent<Camera>().aspect;

        }

        float cameraX, cameraY;
        cameraX = GetComponent<Camera>().transform.position.x;
        cameraY = GetComponent<Camera>().transform.position.y;

        leftX = cameraX - _width / 2;
        rightX = cameraX + _width / 2;
        topY = cameraY + _height / 2;
        bottomY = cameraY - _height / 2;

        //*** bottom
        _bl = new Vector3(leftX, bottomY, 0);
        _bc = new Vector3(cameraX, bottomY, 0);
        _br = new Vector3(rightX, bottomY, 0);
        //*** middle
        _ml = new Vector3(leftX, cameraY, 0);
        _mc = new Vector3(cameraX, cameraY, 0);
        _mr = new Vector3(rightX, cameraY, 0);
        //*** top
        _tl = new Vector3(leftX, topY, 0);
        _tc = new Vector3(cameraX, topY, 0);
        _tr = new Vector3(rightX, topY, 0);
        Instance = this;
    }
예제 #7
0
 private void Awake()
 {
     camera   = GetComponent <Camera>();
     Instance = this;
     ComputeResolution();
 }