Skip to content

Commit

Permalink
Metamask DLL should only be available on webGL (#1074)
Browse files Browse the repository at this point in the history
Fixing metamask processing so that we don't ever get the iOS build error.
  • Loading branch information
kantagara authored Jul 31, 2024
1 parent cae0523 commit 94e664d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/UnitySampleProject/Assets/Scripts/Editor/DllPlatformFixing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using UnityEditor;

public class DllPlatformFixing : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
string[] movedFromAssetPaths)
{
for (var i = 0; i < importedAssets.Length; i++)
if (importedAssets[i].Contains("ChainSafe.Gaming.Unity.MetaMask"))
{
var importer = (PluginImporter)AssetImporter.GetAtPath(importedAssets[i]);
if (importer == null) continue;
//If it's already set to false, that means we've been here and can early return.
if(!importer.GetCompatibleWithAnyPlatform())
return;

importer.SetCompatibleWithAnyPlatform(false);
importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true);
importer.SetCompatibleWithPlatform(BuildTarget.iOS, false);
importer.SetCompatibleWithPlatform(BuildTarget.Android, false);
importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false);
importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false);
importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false);
importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false);
importer.SetCompatibleWithEditor(false);


EditorUtility.SetDirty(importer);
importer.SaveAndReimport();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94e664d

Please sign in to comment.