Unity 中用平台判断用的多了很混乱,我一般都是统一起来。
public class PlatformUtil { public static bool IsEditor { get { #if UNITY_EDITOR return true; #else return false; #endif } } public static bool IsWinEditor { get { #if UNITY_EDITOR_WIN return true; #else return false; #endif } } public static bool IsOSXEditor { get { #if UNITY_EDITOR_OSX return true; #else return false; #endif } } public static bool IsAndroid { get { #if UNITY_ANDROID return true; #else return false; #endif } } public static bool IsIOS { get { #if UNITY_IOS return true; #else return false; #endif } } public static bool IsWindows { get { #if UNITY_STANDALONE_WIN return true; #else return false; #endif } } public static bool IsOSX { get { #if UNITY_STANDALONE_OSX return true; #else return false; #endif } } }