From b5356375f1185121a4798a0efbf3e91696a9b59f Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Thu, 14 Sep 2023 11:30:11 +0300 Subject: [PATCH 1/3] Revert "automated duplicating imported samples modifications (#595)" This reverts commit a5558941827a91df51e2dd200648dcd13a1231c8. --- .github/workflows/duplicate_sample.yaml | 28 ------------------- duplicate_package_sample.sh | 14 ---------- .../Samples~/Web3.Unity/Prefabs.meta | 8 ------ .../Samples~/Web3.Unity/Scenes.meta | 8 ------ .../Samples~/Web3.Unity/Scripts.meta | 8 ------ .../Samples~/Web3.Unity/Sprites.meta | 8 ------ 6 files changed, 74 deletions(-) delete mode 100644 .github/workflows/duplicate_sample.yaml delete mode 100644 duplicate_package_sample.sh delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta delete mode 100644 src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta diff --git a/.github/workflows/duplicate_sample.yaml b/.github/workflows/duplicate_sample.yaml deleted file mode 100644 index 793149e56..000000000 --- a/.github/workflows/duplicate_sample.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Duplicate-Package-Sample - -on: - push: - branches: - - main - -jobs: - duplicate: - name: duplicate package sample - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Run duplicate script file - run: bash ${GITHUB_WORKSPACE}/duplicate_package_sample.sh - - - name: Commit and Push - run: | - git config --global user.email $git_email - git config --global user.name "${{ github.actor }}" - git add ./src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/. -f - git diff-index --cached --quiet HEAD || git commit -m "Auto-duplicate Package Samples" - git push - env: - git_email: "${{ github.actor }}@users.noreply.github.com" \ No newline at end of file diff --git a/duplicate_package_sample.sh b/duplicate_package_sample.sh deleted file mode 100644 index f3a677742..000000000 --- a/duplicate_package_sample.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Specify the source directory and the destination directory -SOURCE_DIRECTORY="src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0-pre001/Web3.Unity Samples/" -DESTINATION_DIRECTORY="src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/" - -# clear destination directory first -rm -r "$DESTINATION_DIRECTORY" - -# Copy source to the destination -cp -r "$SOURCE_DIRECTORY" "$DESTINATION_DIRECTORY" - -#add all modified files -git add "src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/." -f \ No newline at end of file diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta deleted file mode 100644 index 5b35daff8..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 45a04d2621549e3458049c6c447c3941 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta deleted file mode 100644 index 5488a62ed..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scenes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f39f8dda9616349489a7803d7e0aff30 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta deleted file mode 100644 index 9a1e8b8d4..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: eaef630f284e6e04a88b5939e0eb1cc5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta b/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta deleted file mode 100644 index 7175ee89d..000000000 --- a/src/UnityPackages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Sprites.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0c06517aee7843642a091a67c72b1379 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From 0398dba3ee0010fa0c29472b549d66d67dccbbcf Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Tue, 21 Nov 2023 11:28:52 +0300 Subject: [PATCH 2/3] added WebGL threading patcher from - https://github.com/VolodymyrBS/WebGLThreadingPatcher.git --- src/UnitySampleProject/Packages/manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/UnitySampleProject/Packages/manifest.json b/src/UnitySampleProject/Packages/manifest.json index 38ca12ddc..377e19650 100644 --- a/src/UnitySampleProject/Packages/manifest.json +++ b/src/UnitySampleProject/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.tools.webglthreadingpatcher": "https://github.com/VolodymyrBS/WebGLThreadingPatcher.git", "com.unity.collab-proxy": "2.0.7", "com.unity.feature.2d": "1.0.0", "com.unity.ide.rider": "3.0.25", From 69a84eceb55861b3d6940119f8b7ca6d6648959b Mon Sep 17 00:00:00 2001 From: robGG1997 Date: Wed, 22 Nov 2023 13:20:41 +0300 Subject: [PATCH 3/3] WebGLThreadingPatcherInstaller dialog --- .../Editor/WebGLThreadPatcherInstaller.cs | 61 +++++++++++++++++++ .../WebGLThreadPatcherInstaller.cs.meta | 11 ++++ 2 files changed, 72 insertions(+) create mode 100644 Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs create mode 100644 Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs.meta diff --git a/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs b/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs new file mode 100644 index 000000000..8463e17de --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Newtonsoft.Json; +using UnityEditor; +using UnityEngine; + +[InitializeOnLoad] +public static class WebGLThreadPatcherInstaller +{ + private const string WebGLThreadPatchedInstalled = "IsWebGLThreadPatcherInstalled"; + + private const string ManifestPath = "Packages/manifest.json"; + + private const string WebGLThreadPatcherPackageName = "com.tools.webglthreadingpatcher"; + + private const string WebGLThreadPatcherPackageLink = "https://github.com/VolodymyrBS/WebGLThreadingPatcher.git"; + + static WebGLThreadPatcherInstaller() + { +#if UNITY_WEBGL + if (SessionState.GetBool(WebGLThreadPatchedInstalled, false)) + { + return; + } + + TryInstallThreadPatcher(); + + SessionState.SetBool(WebGLThreadPatchedInstalled, true); +#else + // reset. + SessionState.SetBool(WebGLThreadPatchedInstalled, false); +#endif + } + + [MenuItem("Window/ChainSafe SDK/Install WebGLThreadingPatcher")] + public static void TryInstallThreadPatcher() + { + Manifest manifest = JsonConvert.DeserializeObject(File.ReadAllText(ManifestPath)); + + // check if ThreadPatcher is already installed. + if (manifest.Dependencies.ContainsKey(WebGLThreadPatcherPackageName)) + { + return; + } + + if (EditorUtility.DisplayDialog("Web3.Unity", "For Web3.Unity to fully work on a WebGL build you need to install a WebGLThreadingPatcher, this will make sure async operations can run to completion.\nInstall WebGLThreadingPatcher?", "Yes", "No")) + { + // Add the package as a dependency. + manifest.Dependencies.Add(WebGLThreadPatcherPackageName, WebGLThreadPatcherPackageLink); + + File.WriteAllText(ManifestPath, JsonConvert.SerializeObject(manifest, Formatting.Indented)); + } + } + + private struct Manifest + { + [JsonProperty("dependencies")] + public Dictionary Dependencies { get; private set; } + } +} \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs.meta b/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs.meta new file mode 100644 index 000000000..c20e586af --- /dev/null +++ b/Packages/io.chainsafe.web3-unity/Editor/WebGLThreadPatcherInstaller.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3324985ba731c20459fcc27adef8426f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: