Unity WebGL的項目在編輯器下運行一切順利,
然而
打包出來發現在瀏覽器裏使用www或UnityWebRequest向服務器發送請求發現問題來了
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:54692' is therefore not allowed access.
主要因爲跨域訪問存在安全問題
目前已知解決辦法
1.把項目放在服務器目錄下
把IP地址刪了,直接訪問資源路徑或方法
2.服務器方法加上 header("Access-Control-Allow-Origin: *");
這裏使用的是php