zoukankan      html  css  js  c++  java
  • unity 根据平板 或者 手机 确立横竖屏

    /*              #########                       
                  ############                     
                  #############                    
                 ##  ###########                   
                ###  ###### #####                  
                ### #######   ####                 
               ###  ########## ####                
              ####  ########### ####               
             ####   ###########  #####             
            #####   ### ########   #####           
           #####   ###   ########   ######         
          ######   ###  ###########   ######       
         ######   #### ##############  ######      
        #######  #####################  ######     
        #######  ######################  ######    
       #######  ###### #################  ######   
       #######  ###### ###### #########   ######   
       #######    ##  ######   ######     ######   
       #######        ######    #####     #####    
        ######        #####     #####     ####     
         #####        ####      #####     ###      
          #####       ###        ###      #        
            ###       ###        ###              
             ##       ###        ###               
    __________#_______####_______####______________
        身是菩提树,心如明镜台,时时勤拂拭,勿使惹尘埃。
                    我们的未来没有BUG           
    * ==============================================================================
    * Filename: Txt 
    * Created:  2019
    * Author:   Light
    * Purpose:  
    * ==============================================================================
    */
    
    using UnityEngine;
    using UnityEngine.UI;
    using UnityEngine.iOS;
    
    public class Txt : MonoBehaviour
    {
        public Text text;
    
        void Start()
        {
    
    #if UNITY_ANDROID
            float physicscreen = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) / Screen.dpi;
            if (physicscreen >= 7f)
            {
                Debug.Log("安卓平板");
                text.text = "安卓平板";
                Screen.orientation = ScreenOrientation.Landscape;
            }
            else
            {
                Debug.Log("安卓手机");
                text.text = "安卓手机";
                Screen.orientation = ScreenOrientation.PortraitUpsideDown;
            }
    #elif UNITY_IPHONE
            string iP_genneration = Device.generation.ToString();
            if (iP_genneration.Substring(0, 3) == "iPa")
            {
                Debug.Log("苹果平板");
                text.text = "苹果平板";
            }
            else
            {
                Debug.Log("苹果手机");
                text.text = "苹果手机";
            }
    #endif
    
        }
    
    
    }
  • 相关阅读:
    本地快速搭建 FTP 服务器
    css 四个角
    时间
    两个json深度对比
    工作常用
    js模块化 中的变量可在局部 中的‘全局共享’
    datatables 的导出button自定义
    css布局技巧
    datables自定义排序
    js判断是否为空 或者全部为空
  • 原文地址:https://www.cnblogs.com/mclll520/p/10494235.html
Copyright © 2011-2022 走看看