Skip to content

Commit

Permalink
Added auto sync persistent data path to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylanters committed Dec 18, 2024
1 parent 275f1fb commit fc4dcb7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions documentation/docs/api/auto-sync-persistent-data-path.md
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} />;
}
```
5 changes: 5 additions & 0 deletions documentation/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
"type": "doc",
"id": "api/canvas-id",
"label": "Custom Canvas ID"
},
{
"type": "doc",
"id": "api/auto-sync-persistent-data-path",
"label": "Auto Sync Persistent Data Path"
}
]
}
Expand Down

0 comments on commit fc4dcb7

Please sign in to comment.