1+ import { ReactUnityEventParameter } from "react-unity-webgl/distribution/types/react-unity-event-parameters" ;
12import { Unity , useUnityContext } from "react-unity-webgl" ;
23import { useCallback , useEffect , useState } from "react" ;
34import {
@@ -25,11 +26,14 @@ import "./App.css";
2526
2627 const loadingPercentage = Math . round ( loadingProgression * 100 ) ;
2728
28- const handleGoogleSignIn = useCallback ( ( googleClientId : string , nonce : string ) => {
29- setGoogleClientId ( googleClientId ) ;
30- setNonce ( nonce ) ;
31- setShowLogin ( true ) ;
32- } , [ ] ) ;
29+ const handleGoogleSignIn = useCallback ( ( ...parameters : ReactUnityEventParameter [ ] ) : ReactUnityEventParameter => {
30+ const googleClientId = parameters [ 0 ] as string ;
31+ const nonce = parameters [ 1 ] as string ;
32+ setGoogleClientId ( googleClientId ) ;
33+ setNonce ( nonce ) ;
34+ setShowLogin ( true ) ;
35+ return '' ;
36+ } , [ ] ) ;
3337
3438 const [ googleClientIdState , setGoogleClientId ] = useState ( "" ) ;
3539 const [ nonce , setNonce ] = useState ( "" ) ;
@@ -52,8 +56,11 @@ import "./App.css";
5256
5357 useEffect ( ( ) => {
5458 addEventListener ( "GoogleSignIn" , handleGoogleSignIn ) ;
59+ window . addEventListener ( "resize" , handleResize ) ;
60+ handleResize ( )
5561 return ( ) => {
5662 removeEventListener ( "GoogleSignIn" , handleGoogleSignIn ) ;
63+ window . removeEventListener ( "resize" , handleResize ) ;
5764 } ;
5865 } , [ ] ) ;
5966
@@ -68,6 +75,23 @@ import "./App.css";
6875 setShowLogin ( false ) ;
6976 } ;
7077
78+ const handleResize = ( ) => {
79+ const container = document . querySelector ( '.container' ) as any ;
80+
81+ let w = window . innerWidth * 0.98 ;
82+ let h = window . innerHeight * 0.98 ;
83+
84+ const r = 600 / 960 ;
85+ if ( w * r > window . innerHeight ) {
86+ w = Math . min ( w , Math . ceil ( h / r ) ) ;
87+ }
88+
89+ h = Math . floor ( w * r ) ;
90+
91+ container . style . width = w + "px" ;
92+ container . style . height = h + "px" ;
93+ }
94+
7195 return (
7296 < div className = "outer-container" >
7397 < div className = "container" >
0 commit comments