这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEditor;
using UnityEngine;

Expand All @@ -17,7 +18,7 @@ public static class WebGLThreadPatcherInstaller
private const string AsyncToolPackageLink = "https://github.com/RageAgainstThePixel/com.utilities.async.git#upm";

static WebGLThreadPatcherInstaller()
{
{
#if UNITY_WEBGL
if (SessionState.GetBool(AsyncToolsInstalled, false))
{
Expand All @@ -36,47 +37,48 @@ static WebGLThreadPatcherInstaller()
[MenuItem("ChainSafe SDK/Install WebGLThreadingPatcher", priority = 0)]
public static void TryInstallThreadPatcher()
{
Manifest manifest = JsonConvert.DeserializeObject<Manifest>(File.ReadAllText(ManifestPath));

string json = File.ReadAllText(ManifestPath);

Manifest manifest = JsonConvert.DeserializeObject<Manifest>(json);

// check if ThreadPatcher is already installed.
if (manifest.Dependencies.ContainsKey(AsyncToolsPackageName))
{
return;
}

if (EditorUtility.DisplayDialog("Web3.Unity", "For Web3.Unity to fully work on a WebGL build you need to install Async Utilities, this will make sure async operations can run to completion.\nInstall Async Utilities?", "Yes", "No"))

if (EditorUtility.DisplayDialog("Web3.Unity",
"For Web3.Unity to fully work on a WebGL build you need to install Async Utilities, this will make sure async operations can run to completion.\nInstall Async Utilities?",
"Yes", "No"))
{
// Add the package as a dependency.
manifest.Dependencies.Add(AsyncToolsPackageName, AsyncToolPackageLink);

File.WriteAllText(ManifestPath, JsonConvert.SerializeObject(manifest, Formatting.Indented));
try
{
var parsed = JObject.Parse(json);

parsed.Merge(JObject.Parse(JsonConvert.SerializeObject(new Manifest(new Dictionary<string, string>()
{
{ AsyncToolsPackageName, AsyncToolPackageLink }
}))));

File.WriteAllText(ManifestPath, parsed.ToString(Formatting.Indented));
}
catch (Exception e)
{
Debug.LogError($"Error adding {AsyncToolsPackageName} package. {e}");

throw;
}
}
}

private class Manifest
{
[JsonProperty("dependencies")]
[JsonProperty("dependencies", DefaultValueHandling = DefaultValueHandling.Ignore)]
public Dictionary<string, string> Dependencies { get; private set; }

[JsonProperty("enableLockFile")]
public bool EnableLockFile { get; private set; } = true;

[JsonProperty("resolutionStrategy", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string ResolutionStrategy { get; private set; }

[JsonProperty("testables", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string[] Testables { get; private set; }

[JsonProperty("scopedRegistries", DefaultValueHandling = DefaultValueHandling.Ignore)]
public ScopedRegistry[] ScopedRegistries { get; private set; }
}

public struct ScopedRegistry
{
[JsonProperty("name")] public string Name { get; private set; }

[JsonProperty("url")] public string Url { get; private set; }

[JsonProperty("scopes")] public string[] Scopes { get; private set; }
public Manifest(Dictionary<string, string> dependencies)
{
Dependencies = dependencies;
}
}
}
1 change: 0 additions & 1 deletion src/UnitySampleProject/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"dependencies": {
"com.tools.webglthreadingpatcher": "https://github.com/VolodymyrBS/WebGLThreadingPatcher.git",
"com.unity.collab-proxy": "2.4.4",
"com.unity.ide.rider": "3.0.31",
"com.unity.ide.visualstudio": "2.0.22",
Expand Down
17 changes: 0 additions & 17 deletions src/UnitySampleProject/Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"dependencies": {
"com.tools.webglthreadingpatcher": {
"version": "https://github.com/VolodymyrBS/WebGLThreadingPatcher.git",
"depth": 0,
"source": "git",
"dependencies": {
"nuget.mono-cecil": "0.1.6-preview"
},
"hash": "c2f3628a028373afc8c66e443f7ce21bcb613a47"
},
"com.unity.collab-proxy": {
"version": "2.4.4",
"depth": 0,
Expand Down Expand Up @@ -228,14 +219,6 @@
"io.chainsafe.web3-unity": "2.6.0"
}
},
"nuget.mono-cecil": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1"
}
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
Expand Down