Unity-ETH is a Unity project that combines multiplayer gaming capabilities using Unity's Netcode for GameObjects with Ethereum blockchain integration. This project enables players to interact within a multiplayer environment while facilitating Ethereum transactions directly from the Unity application.
- Multiplayer Support: Utilizes Unity's Netcode for GameObjects to provide a seamless multiplayer experience
- Ethereum Integration: Allows users to connect their Ethereum wallets and perform transactions within the game
- User-to-User Transactions: Enables direct Ethereum transactions between players
- Unity 6000.0.41f1 or later
- .NET 6 SDK: Required for Ethereum integration functionalities
-
Clone the repository:
git clone https://github.com/ETH-Unity/UnityNethereum -
Open the project:
- Launch Unity Hub and open the cloned project
-
Install Dependencies:
- Follow Unity's official guide to install the Netcode package: Install Netcode for GameObjects
Via OpenUPM:
- Open Edit > Project Settings > Package Manager
- Add a new Scoped Registry:
- Name:
package.openupm.com - URL:
https://package.openupm.com - Scope(s):
com.nethereum.unitycom.reown
- Name:
- Click Save or Apply
- Open Window > Package Manager
- Click the + button and select "Add package by name..."
- Enter
com.nethereum.unityand click Add - Enter
com.unity.multiplayer.playmodeand click Add - Enter
com.reown.coreand click Add - Enter
com.reown.appkit.unityand click Add - Enter
com.reown.signand click Add
Manual Installation:
- Download the latest Nethereum Unity package from the official repository
- Import the package into your Unity project
- The project includes a
configKeys.jsonfile in the Resources folder - Fill in the required fields:
- networkID
- rpcUrl
- door device's private key
- temperature sensor device's private key
- deployed smart contract addresses
- A NetworkManager component is configured to manage multiplayer sessions
- Review and adjust its settings to match your project's requirements
- Navigate to the Room folder in Unity and start the BasicRoom-scene and start the game
- Use the in-game UI to host or join multiplayer sessions
- Use your Metamask, TrustWallet or WalletConnect to connect your wallet via login button, or private key in the "Enter Private Key..." UI input field
- When the wallet is connected, interact with the in-game UI to initiate Ethereum transactions
- The project includes functionalities to send Ether and messages to other players and interact with smart contracts
- There is three rooms in the scene with different role accesses, physical, digital and admin room. Only admins can control other accounts accesses to the rooms and service role can access any room by default. Admins and service role has access to the admin room, where they can see all the logs of actions happened in the scene (as access granted, door opened etc.) If someone outside of the game has access and interacts with the smart contract, he spawns in the physical room as a NPC (simulating real world person and room).
- Movement: WASD
- Interact: "E"
- Admin panel: "Q" - Opens UI buttons for Access control
- Assets/Blockchain: Contains scripts related to blockchain and ABI files
- Assets/Network: Contains scripts related to multiplayer networking using Netcode for GameObjects
- Assets/Player: Contains files related to the player, movement and camera
- Assets/Room: Contains all the files for the room scene, door and fan functionalities included
Contributions are welcome! Please fork the repository and submit a pull request with your enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.