Unity:使用宏定义和Application.platform判断运行平台

宏定义判断平台:

        //Android平台
#if UNITY_ANDROID
        debug.log("Android");
#endif
 
        //苹果平台
#if UNITY_IPHONE
        debug.log("IOS");
#endif
        //Windows平台
#if UNITY_STANDALONE_WIN
        Debug.Log("Windows");
#endif

Application.platform判断平台:

if (Application.platform == RuntimePlatform.Android)
        {
    
    
            Debug.Log("Android");
        }else if(Application.platform == RuntimePlatform.IPhonePlayer)
        {
    
    
            Debug.Log("IOS");
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
    
    
            Debug.Log("Window");
        }

两种使用代码判断使用平台的操作


学习日程记录

猜你喜欢

转载自blog.csdn.net/zhangay1998/article/details/113242974