Skip to content

Commit fc4dcb7

Browse files
Added auto sync persistent data path to the docs
1 parent 275f1fb commit fc4dcb7

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Auto Sync Persistent Data Path
2+
3+
Enables or disables auto synchronization of the persistent data path.
4+
5+
## Type Definition
6+
7+
```tsx title="Type Definition"
8+
const autoSyncPersistentDataPath: boolean = false;
9+
```
10+
11+
## Implementation
12+
13+
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.
14+
15+
## Example Usage
16+
17+
A basic implementation could look something like this. In the following example we'll enable auto synchronization of the persistent data path.
18+
19+
```jsx {10} showLineNumbers title="App.jsx"
20+
import React from "react";
21+
import { Unity, useUnityContext } from "react-unity-webgl";
22+
23+
function App() {
24+
const { unityProvider } = useUnityContext({
25+
loaderUrl: "build/myunityapp.loader.js",
26+
dataUrl: "build/myunityapp.data",
27+
frameworkUrl: "build/myunityapp.framework.js",
28+
codeUrl: "build/myunityapp.wasm",
29+
autoSyncPersistentDataPath: true,
30+
});
31+
32+
return <Unity unityProvider={unityProvider} />;
33+
}
34+
```

documentation/sidebars.json

+5
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@
196196
"type": "doc",
197197
"id": "api/canvas-id",
198198
"label": "Custom Canvas ID"
199+
},
200+
{
201+
"type": "doc",
202+
"id": "api/auto-sync-persistent-data-path",
203+
"label": "Auto Sync Persistent Data Path"
199204
}
200205
]
201206
}

0 commit comments

Comments
 (0)