Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Packages/UnityWebBrowser/Runtime/Core/BaseUwbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// This project is under the MIT license. See the LICENSE.md file for more details.

using System;
using System.IO;
using UnityEngine;

namespace VoltstroStudios.UnityWebBrowser.Core
Expand All @@ -25,9 +26,15 @@ public abstract class BaseUwbClientManager : MonoBehaviour
/// </summary>
[Tooltip("The browser client, what handles the communication between the UWB engine and Unity")]
public WebBrowserClient browserClient = new();

private string randomCachePath;

private void Start()
{
//Give random cache path for the browser client
randomCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.Guid.NewGuid().ToString());
FileInfo rcpFileInfo = new FileInfo(randomCachePath);
browserClient.CachePath = rcpFileInfo;

//Start the browser client
browserClient.Init();

Expand All @@ -47,6 +54,9 @@ private void FixedUpdate()

private void OnDestroy()
{
// Delete random assigned cache folders
Directory.Delete(randomCachePath, true);

browserClient.Dispose();
OnDestroyed();
}
Expand Down Expand Up @@ -145,4 +155,4 @@ public void ExecuteJs(string js)

#endregion
}
}
}