Unity에서 webgl 빌드 후, 빌드 된 파일을 로컬 서버로 실행.(Webgl은 비압축 형태로 빌드)
vscode에서 프로젝트 폴더를 만들고 express설치.
이 프로젝트 폴더에 webgl파일들을 넣어야 하는데,
빌드된 파일들을 "WebGLTEST" 이라는 폴더에 담고, vscode 프로젝트 폴더에 넣는다.
서버측 코드
const express = require("express");
const app = express();
const http = require("http")
const path = require("path");
const port = 8000;
app.use(express.static(path.join(__dirname, "/WebGLTEST")));
app.get("/", (req, res) =>{
res.sendFile(path.join(__dirname, "WebGLTEST", "index.html"));
})
http.createServer(app).listen(port, () => {
console.log(`Server runiing ${port}`)
})
주소창에 "localhost:8000" 으로 접속하면 잘 실행된다.
참고자료:
https://tycovds.medium.com/build-a-unity-webgl-game-and-serve-it-with-an-express-server-771e60267e10
'유니티(Unity)' 카테고리의 다른 글
3D 애니메이션 문제 및 해결법 (0) | 2024.08.04 |
---|---|
코루틴 확장하기 (0) | 2024.05.06 |
vscode와 유니티에서 async 스레드 테스트 (0) | 2024.05.01 |
자바스크립트 Dll 사용하기 (0) | 2024.04.30 |
Unity 텍스처 압축 시 주의 할 점. (0) | 2024.04.14 |