-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added disabled canvas events api to documentation
- Loading branch information
1 parent
76ed5a2
commit f693c58
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Disabled Canvas Events | ||
|
||
Overwrites the default disabled canvas events. | ||
|
||
## Type Definition | ||
|
||
```tsx title="Type Definition" | ||
<Unity disabledCanvasEvents={string[]} /> | ||
``` | ||
|
||
## Implementation | ||
|
||
> By default Unity disables the `contextmenu` and `dragstart` events on the canvas element. This is done to prevent the user from right clicking on the canvas and dragging the page while interacting with the Unity Application. Note that by setting the `disabledCanvasEvents` property you'll override the default values. If you don't want this to happen, you'll need to add events these to the array. | ||
## Example Usage | ||
|
||
A basic implementation could look something like this. In the following example overwrite the default values and disable the `dragstart` and `scroll` events. This will also allow the user to right click on the canvas to open the context menu. | ||
|
||
```jsx {10-21} showLineNumbers title="App.jsx" | ||
import React from "react"; | ||
import { Unity, useUnityContext } from "react-unity-webgl"; | ||
|
||
function App() { | ||
const { unityProvider } = useUnityContext({ | ||
loaderUrl: "build/myunityapp.loader.js", | ||
dataUrl: "build/myunityapp.data", | ||
frameworkUrl: "build/myunityapp.framework.js", | ||
codeUrl: "build/myunityapp.wasm", | ||
}); | ||
|
||
return ( | ||
<Unity | ||
unityProvider={unityProvider} | ||
disabledCanvasEvents={["dragstart", "scroll"]} | ||
/> | ||
); | ||
} | ||
``` |
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