using UnityEngine;
using System.Collections;
public class Scaler : MonoBehaviour
{
public int baseWidth = 1024;
public int baseHeight = 600;
Transform _tran;
void Awake()
{
_tran = transform;
}
void Start()
{
float size= Camera.main.orthographicSize;
float scale_x = Screen.width * 1f / baseWidth * 1f;
float scale_y = Screen.height * 1f / baseHeight * 1f;
_tran.localScale = new Vector3(scale_x, scale_y, 1);
Camera.main.orthographicSize = size * scale_y;
}
}
Unity 2D场景缩放
最新推荐文章于 2024-04-23 00:41:46 发布