Unity게임

itch.io 에 게임 배포시 개발 주의사항

Khookie 2024. 1. 16. 23:38

로컬 개발을 끝내고 배포하면서 겪었던 시행착오를 정리하려고 한다.

 

1. 비디오 문제

오류:

 webgl로 배포시 비디오가 나오지 않음

gzip.framework.js:1792 Embedded video clips are not supported by the WebGL player: Assets/Resources/ETC/Splash/movie.mp4. Use the Video Player component's URL option instead.

 

원인:

WebGL 플레이어에서 Unity의 비디오 클립을 직접 지원하지 않기 때문에 발생.

 

해결:

대신 Unity의 Video Player 컴포넌트의 URL 옵션을 사용하고 

비디오 리소스 위치를 바꿔야 한다

public VideoPlayer videoPlayer;
    
    void Start()
    {
        string videoPath = Application.streamingAssetsPath + "/movie.mp4";
        videoPlayer.url = videoPath;
        videoPlayer.isLooping = true;
		videoPlayer.Prepare();
        videoPlayer.Play();
    }

 

해당 비디오 파일이 WebGL로 빌드된 프로젝트의 StreamingAssets 폴더에 위치해야함.

Assets 폴더 아래에 StreamingAssets 폴더를 만들고 그안에 비디오를 넣으면 빌드시 StreamingAssets  폴더가 만들어져 정상적으로 비디오가 플레이된다

 

2.WebGlInput 패키지 오류

 

오류:

gzip.loader.js:1 exception thrown: TypeError: Cannot read properties of null (reading 'getElementsByTagName'),TypeError: Cannot read properties of null (reading 'getElementsByTagName') at _WebGLInputCreate (https://html-classic.itch.zone/html/951728/gzip/Build/gzip.framework.js.gz:3:75042) at https://html-classic.itch.zone/html/951728/gzip/Build/gzip.wasm.gz:wasm-function[25908]:0x9d2a1e at https://html-classic.itch.zone/html/951728/gzip/Build/gzip.wasm.gz:wasm-function[14903]:0x52c1f3 at https://html-

 

아래 글에 해결책이 나와있다

https://github.com/kou-yeung/WebGLInput/issues/90

 

I always receive the exception: Cannot read properties of null (reading 'getElementsByTagName') · Issue #90 · kou-yeung/WebGLI

I'm using the WebGLInput script in my input field (it is a TMP_InputField), and when I test it in my WebGL build, just when I put the focus on the input textbox, the execution is frozen and I recei...

github.com

요약하면

빌드시 나오는

"webgl-build.framework.js" 파일에서 아래처럼 수정 *하지만 난 이파일이 없었다

 

id ="unityContainer" 이 부분

id ="unity-container" 이렇게

 

또는WebGLInput.cs을 아래처럼 파일 수정

In my case I replaced this:

static WebGLInput()
 {
#if UNITY_2020_1_OR_NEWER
    WebGLInput.CanvasId = "unity-container";
#elif UNITY_2019_1_OR_NEWER
    WebGLInput.CanvasId = "unityContainer";
#else
    WebGLInput.CanvasId = "gameContainer";
#endif
    WebGLInputPlugin.WebGLInputInit();
}

*하지만 난 이부분 또한 라이브러리가 업데이트되어  내용이 달랐다

 라이브러리 자체에서 아직 미해결된 이슈로 남아있는듯하여
임시 방편으로 이전 1.2.1버전으로 바꾸어 해결했다
https://github.com/kou-yeung/WebGLInput/releases