MetaMask / MetaMask/metamask-sdk

Unity Scripting Define Symbol

Open
#827 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
338
Forks
260
PR merge metrics
No merged PRs in 30d

Description

# Feature Request
Add a versioned scripting define symbol such as `METAMASK_{Version Number}` to the Unity project settings when Metamask Unity is installed.

## Why it is needed
1. This allows developers to conditionally compile code for tools that are designed with an optional feature to use Metamask Unity.
2. Scripts made using these scripting defines can be more easily upgraded to support the latest Metamask Unity version.

## Possible implementation
Add a csc.rsp file in Assets/ with contents
```
-define:METAMASK_V1
```

### Code sample
Code can be conditionally compiled when Metamask is included in the Unity project. The version should be increased any time there is major changes.
```
#if METAMASK_V1
//Metamask version 1 specific code
#elif METAMASK_V2
//Metamask version 2 specific code
#endif
```
### Example
This example script shows usage of a manually added METAMASK scripting define symbol. The script can exist in the project, without compilation errors, when Metamask Unity is not installed and the METAMASK scripting define has not been added.
https://github.com/WoodsFiend/Moralis-Unity-SDK/blob/master/Scripts/MetaMask/MetaMaskProxyServerLogin.cs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed Assets/csc.rsp file and review the Unity project settings behavior described in the issue. Done means installing Metamask Unity adds a versioned symbol such as METAMASK_V1, allowing the shown conditional compilation pattern to work without errors when the SDK is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
unity
Domain
game-dev
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.