UnityWebRequest は Mac と Windows で異なります

開発中に、UnityWebRequest にはウィンドウ上では正常に実行されるパスがあることが判明しましたが、Mac 上で実行するとエラーが報告され、パスが見つかりません。

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


Windows では、パス内の特殊記号の置換もあります。

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