using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraSpace : MonoBehaviour { //最初に作った画面のwidth public float defaultWidth = Screen.currentResolution.width; //最初に作った画面のheight public float defaultHeight = Screen.currentResolution.height; private void Start() { Debug.Log("Screen currentResolution : " + Screen.currentResolution); //camera.mainを変数に格納 Camera mainCamera = Camera.main; //最初に作った画面のアスペクト比 float defaultAspect = defaultWidth / defaultHeight; //実際の画面のアスペクト比 float actualAspect = (float)Screen.width / (float)Screen.height; //実機とunity画面の比率 float ratio = actualAspect / defaultAspect; //サイズ調整 mainCamera.orthographicSize /= ratio; } } コード
andoroidようにカメラの画面サイズを書き換えるスクリプトを作りましたが、pcの方ではエラーが出て、カメラが映らなくなりました。
改善点のご教授お願いします
エラーが出たのであれば、そのエラーを記載してください。
回答1件
あなたの回答
tips
プレビュー