-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from finol-digital/develop
Develop
- Loading branch information
Showing
11 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import Footer from "@/components/footer"; | ||
import UnityWeb from "@/components/unityWeb"; | ||
import { getGame } from "@/lib/firebase/firestore"; | ||
import { notFound } from "next/navigation"; | ||
import Script from "next/script"; | ||
|
||
export default async function Page({ params }: { params: { slug: string } }) { | ||
const game = (await getGame(params.slug))?.at(0); | ||
if (!game) return notFound(); | ||
return ( | ||
<> | ||
<canvas id="unity-canvas" width="960" height="600"></canvas> | ||
<Script src="/Unity/WebGL.loader.js" /> | ||
<Script src="/UnityWebGL.js" /> | ||
</> | ||
<main className="main-container"> | ||
<UnityWeb url={game.autoUpdateUrl} /> | ||
<Footer /> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { Unity, useUnityContext } from "react-unity-webgl"; | ||
|
||
export default function UnityWeb({ | ||
url = "https://www.cardgamesimulator.com/games/Standard/Standard.json", | ||
}: { | ||
url?: string; | ||
}) { | ||
const { unityProvider } = useUnityContext({ | ||
loaderUrl: "/Unity/WebGL.loader.js", | ||
dataUrl: "/Unity/WebGL.data", | ||
frameworkUrl: "/Unity/WebGL.framework.js", | ||
codeUrl: "/Unity/WebGL.wasm", | ||
}); | ||
|
||
// We'll use a state to store the device pixel ratio. | ||
const [devicePixelRatio, setDevicePixelRatio] = useState( | ||
window.devicePixelRatio, | ||
); | ||
|
||
useEffect( | ||
function () { | ||
// A function which will update the device pixel ratio of the Unity | ||
// Application to match the device pixel ratio of the browser. | ||
const updateDevicePixelRatio = function () { | ||
setDevicePixelRatio(window.devicePixelRatio); | ||
}; | ||
// A media matcher which watches for changes in the device pixel ratio. | ||
const mediaMatcher = window.matchMedia( | ||
`screen and (resolution: ${devicePixelRatio}dppx)`, | ||
); | ||
// Adding an event listener to the media matcher which will update the | ||
// device pixel ratio of the Unity Application when the device pixel | ||
// ratio changes. | ||
mediaMatcher.addEventListener("change", updateDevicePixelRatio); | ||
return function () { | ||
// Removing the event listener when the component unmounts. | ||
mediaMatcher.removeEventListener("change", updateDevicePixelRatio); | ||
}; | ||
}, | ||
[devicePixelRatio], | ||
); | ||
|
||
return ( | ||
<> | ||
<Unity | ||
unityProvider={unityProvider} | ||
style={{ width: 1280, height: 720 }} | ||
devicePixelRatio={devicePixelRatio} | ||
/> | ||
</> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.