WWW加载AssetBundle的坑

xiaoxiao2021-02-28  34

其实就是一个路径的坑,平台不一样,路径也不一样。比如

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 } }
转载请注明原文地址: https://www.6miu.com/read-2622058.html

最新回复(0)