其实就是一个路径的坑,平台不一样,路径也不一样。比如
Win是file:///,三杠
其他是file://,两杠
public static string PERSISTENT_PATH_DATABASE //= LGameConfig.LOCAL_URL_PREFIX + Application.persistentDataPath + "/DataBase/"; { get { #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN return "file:///"+ Application.persistentDataPath + "/Test/"; #else return "file://"+ Application.persistentDataPath + "/Test/"; #endif } }Application.StreamingAsset目录又不一样
public static string STREAMING_PATH_DATABASE { //这样写,因为安卓Unity平台是Application.isMobilePlatform==false, 而宏定义中又 ==UNITY_ANDROID。 //因为我们项目中是需要同时在PC下安卓平台和PC下 Standard平台,哈哈 get { if (!Application.isMobilePlatform) { return "file://" + Application.dataPath + "/StreamingAssets" + "/DataBase/"; } else { return #if UNITY_ANDROID Application.streamingAssetsPath+ "/DataBase/"; #else "file://" + Application.dataPath + "/StreamingAssets" + "/DataBase/"; #endif } }