From fc4dcb76a07402e18dc6b0fe84feeade89a28677 Mon Sep 17 00:00:00 2001 From: Jeffrey Lanters Date: Wed, 18 Dec 2024 11:17:32 +0100 Subject: [PATCH] Added auto sync persistent data path to the docs --- .../api/auto-sync-persistent-data-path.md | 34 +++++++++++++++++++ documentation/sidebars.json | 5 +++ 2 files changed, 39 insertions(+) create mode 100644 documentation/docs/api/auto-sync-persistent-data-path.md diff --git a/documentation/docs/api/auto-sync-persistent-data-path.md b/documentation/docs/api/auto-sync-persistent-data-path.md new file mode 100644 index 0000000..c898531 --- /dev/null +++ b/documentation/docs/api/auto-sync-persistent-data-path.md @@ -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 ; +} +``` diff --git a/documentation/sidebars.json b/documentation/sidebars.json index 7f75953..0081253 100644 --- a/documentation/sidebars.json +++ b/documentation/sidebars.json @@ -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" } ] }