nextjs-test/app/unity/page.tsx

31 lines
1.0 KiB
TypeScript

"use client";
import { Unity, useUnityContext } from "react-unity-webgl";
export default function Home() {
const { unityProvider, isLoaded, loadingProgression } = useUnityContext({
loaderUrl: "/unity/test-project/build.loader.js",
dataUrl: "/unity/test-project/build.data",
frameworkUrl: "/unity/test-project/build.framework.js",
codeUrl: "/unity/test-project/build.wasm",
});
const loadingPercentage = Math.round(loadingProgression * 100);
return (
<>
<div className="mb-5 mt-5">
Unity , WebGL로
react-unity-webgl .
</div>
<div className="relative h-[600px] w-[800px]">
{isLoaded === false && (
<div className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-gray-500">
<p>Loading... ({loadingPercentage}%)</p>
</div>
)}
<Unity className="h-full w-full" unityProvider={unityProvider} />
</div>
</>
);
}