Skip to content

Commit e33fee3

Browse files
Updated Unity Argument Generation
1 parent 452ccbb commit e33fee3

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

module/source/hooks/use-unity-arguments.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const useUnityArguments = (unityProps: UnityProps): UnityArguments => {
5050

5151
// Assigns the match WebGL to canvas size value to the Unity arguments
5252
// object. If the match WebGL to canvas size value is not defined via the
53-
// Unity Props, the default value of `false` will be used.
54-
matchWebGLToCanvasSize: unityProps.matchWebGLToCanvasSize || false,
53+
// Unity Props, the default value of `true` will be used.
54+
matchWebGLToCanvasSize: unityProps.matchWebGLToCanvasSize || true,
5555

5656
// Assigns the disabled canvas events to the Unity arguments object. If
5757
// the disabled canvas events are not defined via the Unity Props, the
@@ -85,12 +85,7 @@ const useUnityArguments = (unityProps: UnityProps): UnityArguments => {
8585
// TODO -- Re-implement this hook.
8686
},
8787
}),
88-
[
89-
unityProps.unityProvider.unityConfig,
90-
unityProps.devicePixelRatio,
91-
unityProps.matchWebGLToCanvasSize,
92-
unityProps.disabledCanvasEvents,
93-
]
88+
[]
9489
);
9590
};
9691

testing/src/unity-test.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ function UnityTest() {
3030
preserveDrawingBuffer: true,
3131
},
3232
cacheControl: handleCacheControl,
33-
disabledCanvasEvents: ["dragstart"],
3433
});
3534

3635
const canvasRef = useRef<HTMLCanvasElement>(null);
3736
const [screenshots, setScreenshots] = useState<string[]>([]);
37+
const [canvasWidth, setCanvasWidth] = useState(500);
3838

3939
function handleClickRequestFullScreen() {
4040
requestFullscreen(true);
@@ -52,6 +52,10 @@ function UnityTest() {
5252
UNSAFE__detachAndUnloadImmediate();
5353
}
5454

55+
function handleClickSetRandomCanvasWidth() {
56+
setCanvasWidth(Math.floor(Math.random() * 500) + 250);
57+
}
58+
5559
function handleClickSetLogText() {
5660
sendMessage(
5761
"Persistent",
@@ -134,11 +138,21 @@ function UnityTest() {
134138
<br />
135139
Communication:
136140
<button onClick={handleClickSetLogText}>Set Log Text</button>
141+
<br />
142+
Other:
143+
<button onClick={handleClickSetRandomCanvasWidth}>
144+
Set Random Canvas Width
145+
</button>
137146
</p>
138147
<Unity
139148
unityProvider={unityProvider}
140-
style={{ border: "1px solid red", height: 400, width: 500 }}
141-
devicePixelRatio={window.devicePixelRatio}
149+
style={{
150+
border: "1px solid red",
151+
height: 400,
152+
width: canvasWidth,
153+
}}
154+
// devicePixelRatio={window.devicePixelRatio}
155+
// disabledCanvasEvents={["dragstart"]}
142156
ref={canvasRef}
143157
/>
144158
</Fragment>

0 commit comments

Comments
 (0)