Unity3D 改为按宽度缩放的方法

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {
    
    public float backgoundWidthInpixel;
      

    // Use this for initialization
    void Start () {     
    
        float backgoundWidth = backgoundWidthInpixel/100;  //100 is the pixels to unit value
    
        float retio =(float) (Screen.width)/(float) (Screen.height);

        float newSize =  backgoundWidth/retio;
        
        camera.orthographicSize = newSize/2;
    }
    
    // Update is called once per frame
    void Update () {
    
        }
}

原文地址:https://www.cnblogs.com/qqqeeebbb/p/3611532.html