-
-
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 auto sync persistent data path to the docs
- Loading branch information
1 parent
275f1fb
commit fc4dcb7
Showing
2 changed files
with
39 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,34 @@ | ||
# Auto Sync Persistent Data Path | ||
|
||
Enables or disables auto synchronization of the persistent data path. | ||
|
||
## Type Definition | ||
|
||
```tsx title="Type Definition" | ||
const autoSyncPersistentDataPath: boolean = false; | ||
``` | ||
|
||
## Implementation | ||
|
||
If set to true, all file writes inside the Unity `Application.persistentDataPath` directory automatically persist so that the contents are remembered when the user revisits the website the next time. If unset (or set to false), you must manually sync file modifications inside the `Application.persistentDataPath` directory by calling the `JS_FileSystem_Sync()` JavaScript function. | ||
|
||
## Example Usage | ||
|
||
A basic implementation could look something like this. In the following example we'll enable auto synchronization of the persistent data path. | ||
|
||
```jsx {10} 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", | ||
autoSyncPersistentDataPath: true, | ||
}); | ||
|
||
return <Unity unityProvider={unityProvider} />; | ||
} | ||
``` |
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