Visual Studio는 Unity WebGL 콘텐츠 디버깅을 지원하지 않습니다.빌드 정보를 얻으려면 다음 팁을 사용하십시오.
Unity WebGL은 파일 시스템에 액세스할 수 없으므로 다른 플랫폼처럼 로그 파일을 작성하지 않습니다.하지만 모든 로깅 정보(Debug.Log
, Console.WriteLine
또는 Unity의 내부 로깅 등)를 브라우저의 JavaScript 콘솔에 작성합니다.
JavaScript 콘솔을 열려면 다음 단계를 따르십시오.
디버깅 목적으로는 Unity에서 개발 빌드를 생성할 수 있습니다(Build Settings 창을 열고 Development Build 체크박스 선택).개발 빌드에서는 프로파일러를 연결할 수 있으며 Unity는 프로파일러를 축소하지 않으므로 출력된 JavaScript 코드에는 여전히 사람이 읽을 수 있는(C++-mangled) 함수 이름이 포함됩니다.
이를 통해 브라우저는 브라우저 오류가 발생하거나, Debug.LogError
를 사용하거나, 예외가 발생하여 예외 지원이 비활성화되었을 때 스택 추적을 표시합니다.전체 예외를 지원하는 경우 발생할 수 있는 관리되는 스택 추적(아래 참조)과는 달리, 이러한 스택 추적은 손상된 이름을 가지며 관리되는 코드뿐만 아니라 내부 UnityEngine 코드도 포함되어 있습니다.
WebGL는 여러 예외 지원 수준을 지원합니다(WebGL용 빌드에 관한 문서를 참조). 기본적으로 Unity WebGL은 명시적으로 발생한 예외만 지원합니다. 하지만 Full 예외 지원을 활성화할 수도 있으며, 이 경우 관리되는 코드에서 null 참조와 범위 초과 배열 요소 접근을 찾아내기 위해, IL2CPP 생성 코드를 통해 추가 검사를 진행할 수 있습니다. 이러한 추가 검사 과정은 성능에 큰 악영향을 주고 코드 용량과 로드 시간을 증가시킵니다. 따라서 디버깅 목적으로만 사용하는 것이 좋습니다.
Full 예외 지원에서는 함수 이름을 내보내 관리되는 코드에 대한 스택 트레이스도 생성합니다. 이러한 이유로 탐지되지 않은 예외와 Debug.Log
문의 스택 트레이스가 콘솔에 표시됩니다. 스택 트레이스 문자열을 얻으려면 System.Environment.Stacktrace
를 사용하십시오.
32비트 브라우저에서 흔히 발생하는 문제입니다. WebGL 메모리 문제와 그 해결 방법에 대한 자세한 내용은 WebGL의 메모리를 참조하십시오.
Unity WebGL는 세션 간에 유지해야 하는 모든 파일(예: PlayerPrefs, 또는 persistentDataPath에 저장된 파일)을 브라우저 IndexedDB에 보관합니다. 이는 비동기 API이므로 완료되는 시점을 알 수 없습니다.
다음 코드를 호출하여 Unity가 모든 보류 중인 파일 시스템 쓰기 작업을 메모리에서 IndexedDB 파일 시스템으로 플러시하십시오.
FS.syncfs(false, function (err) {
if (err) {
console.log("Error: syncfs failed!");
}
});
The browser console log usually prints this error due to incorrect server configuration. For more information on how to deploy a release build, see documentation on Deploying compressed builds.
The browser console log prints this error when the content tries to load an AssetBundle compressed using LZMA, which Unity WebGL doesn’t support. Re-compress the AssetBundle using LZ4 compression to solve this problem. For more information on compression for WebGL, see documentation on WebGL building, particularly the AssetBundles section.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.