Advertisement

Unity 2D 游戏界面相机适配

阅读量:

之前写的关于2D游戏界面相机的不同模式(包括水平方向、垂直方向以及以人为中心的方向)的三种方式的相机控制,在写作过程中发现操作起来有些麻烦,并且效果不太好。开发多平台时由于资源限制我不确定是否完全实现了适配。今天为大家带来了……把代码放在下方让各位参考使用。

复制代码
 using UnityEngine;

    
 using System.Collections;
    
  
    
 public class CameraControl_2D : MonoBehaviour {
    
  
    
     // 默认屏幕大小
    
     float width = 854.0f;
    
     float height = 480.0f;
    
  
    
     // Use this for initialization
    
     void Awake()
    
     {
    
     
    
     // 屏幕适配
    
     float orthographicSize = this.GetComponent<Camera>().orthographicSize;
    
     print("aa:" + orthographicSize);
    
     orthograph

全部评论 (0)

还没有任何评论哟~