UnityWebRequest 在Mac上与Window上的不同

有一次开发发现,UnityWebRequest有一个路径在window上运行正常,在mac上运行就会报错,找不到路径

  UnityWebRequest request = UnityWebRequest.Get(assetBundleConfigPath);
        //mac必须这样写,前面加"file://"
        #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
                request = UnityWebRequest.Get("file://" +assetBundleConfigPath);
        #endif

还有就是
window上对路径中特殊符号的替换处理

string assetbundleName = directoryInfo.FullName.Substring(Application.dataPath.Length + 1).Replace('\\', '_').ToLower();
#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
         assetbundleName = directoryInfo.FullName.Substring(Application.dataPath.Length + 1).Replace('/', '_').ToLower();
#endif

猜你喜欢

转载自blog.csdn.net/qq_32175379/article/details/125833447
今日推荐