예제 #1
0
    public void SetHeight()
    {
        height = float.Parse(h.text.Trim());



        float a, b;

        //a = (float)resizeImage.aspectRatio.width;
        // b = (float)resizeImage.aspectRatio.height;
        a = (float)ResizeImage.GetImageWidth(resizeImage.aspectRatio);
        b = (float)ResizeImage.GetImageHeight(resizeImage.aspectRatio);
        float temp = Convert.ToSingle(a / b);

        if (temp < 1)
        {
            temp = Convert.ToSingle(b / a);
        }

        Debug.Log("Aspect " + temp);
        if (a > b)
        {
            resizeImage.plane.transform.localScale = new Vector3(-height * temp, resizeImage.plane.transform.localScale.y, height);
        }
        else
        {
            resizeImage.plane.transform.localScale = new Vector3(-height / temp, resizeImage.plane.transform.localScale.y, height);
        }
    }
예제 #2
0
    public void SetPictureSize()
    {
        height = float.Parse(h.text.Trim());
        width  = float.Parse(w.text.Trim());
        depth  = float.Parse(d.text.Trim());



        float a, b;

        //a = (float)resizeImage.aspectRatio.width;
        // b = (float)resizeImage.aspectRatio.height;
        a = (float)ResizeImage.GetImageWidth(resizeImage.aspectRatio);
        b = (float)ResizeImage.GetImageHeight(resizeImage.aspectRatio);
        float temp = Convert.ToSingle(a / b);

        Debug.Log(temp);
        if (width > 0.0f)
        {
            if (temp < 1)
            {
                temp = Convert.ToSingle(b / a);
            }

            Debug.Log("Aspect " + temp);

            if (a > b)
            {
                resizeImage.plane.transform.localScale = new Vector3(-width, resizeImage.plane.transform.localScale.y, width / temp);
            }
            else
            {
                resizeImage.plane.transform.localScale = new Vector3(-width, resizeImage.plane.transform.localScale.y, width * temp);
            }
        }
        else if (height > 0.0f)
        {
            if (temp < 1)
            {
                temp = Convert.ToSingle(b / a);
            }

            Debug.Log("Aspect " + temp);
            if (a > b)
            {
                resizeImage.plane.transform.localScale = new Vector3(-height * temp, resizeImage.plane.transform.localScale.y, height);
            }
            else
            {
                resizeImage.plane.transform.localScale = new Vector3(-height / temp, resizeImage.plane.transform.localScale.y, height);
            }
        }

        //Debug.Log(width);
    }