unity 平台判断

使用预编译:

 #if UNITY_ANDROID
        Debug.Log("安卓设备");
    #endif
  
    #if UNITY_IPHONE
        Debug.Log("苹果设备");
    #endif
  
    #if UNITY_STANDALONE_WIN
        Debug.Log("windows电脑");
    #endif  

运行时判断:

switch (Application.platform)
        {
        case RuntimePlatform.WindowsEditor:
            print("Windows");
            break;
  
        case RuntimePlatform.Android:
            print("Android");
            break;
  
        case RuntimePlatform.IPhonePlayer:
            print("Iphone");
            break;
        }

你可能感兴趣的:(unity基础)