This repository contains the reference implementation of the decentraland explorer. It includes two main big components, located in the folders:
unity-renderer
which contains the main 3D experience and UIbrowser-interface
to connect to the different aspects requiring of a web browser, such as connection with a wallet and WebRTC communications
-
Install images and binary files using
git lfs
(git-lfs.github.com). These can be installed from bash or PowerShell by typing:git lfs install git lfs pull
-
The Unity engine and IDE, currently using version 2021.3.14f1
-
node.js, version 16 or later
Check: Multiplatform in Editor
- Download and install Unity 2022.3.6f1
- Open the scene named
InitialScene
- Within the scene, select the
DebugConfig
GameObject. - On
DebugConfig
inspector, make sure thatBase url mode
is set toCustom
andBase url custom
is set tohttps://play.decentraland.zone/?
- Run the Initial Scene in the Unity editor
- A browser tab with
explorer
should open automatically and steal your focus, don't close it! Login with your wallet, go back to Unity and explorer should start running on theGame View
. - As you can see,
DebugConfig
has other special options like the starting position, etc. You are welcome to use them as you see fit, but you'll have to close the tab and restart the scene for them to make effect.
If while trying to compile the Unity project you get an error regarding some libraries that can not be added (for instance Newtonsoft Json.NET or Google Protobuf), please execute the following command in the root folder:
git lfs install
git lfs pull
Then, on the Unity editor, click on Assets > Reimport All
To test against a build made on this repository, you can use a link with this format:
https://play.decentraland.zone/?explorer-branch=<branch-name>
In order to run browser interface in any platform follow the next instructions
- Open browser-interface with
Visual Studio Code
- Make sure you have the
devcontainers
extension installed - Make sure Docker Desktop is running
At Visual Studio Code
pressF1
executeReopen in Container
and wait for it to finish.- Go to
Terminal > New Terminal
menu and runmake watch
command.
- Follow the previous process to run
make watch
- Open
localhost:8080/test
in your browser - Watch the results
Use this approach when working on any features that need both Browser Interface and Unity modifications, and you need to watch Unity code changes fast without the need of injecting a wasm targeted build in the browser.
When the steps are followed, you will be able to test your changes by just pressing the "Play" button within Unity. This will open a tab running the local Browser Interface build and Unity will connect to it using websocket.
This is the most useful debugging scenario for advanced feature implementation.
- Make sure you have the proper Unity version up and running
- Make sure you are running browser-interface through
make watch
command onbrowser-interface
path. - Back in unity editor, open the
DebugConfig
component inspector ofInitialScene
- Make sure that the component is setup correctly
- Hit 'Play' button
This approach works when your Unity modifications run well in the wasm targeted unity build, but you don't want to wait for the CI to kick in. This is also useful for remote profiling.
When the steps are followed, you will be able to run the local Unity build by going to localhost:3000
without the need of CI.
- Make sure you have the proper Unity version up and running
- Make sure you are running browser-interface correctly by running
npm install
,make build-unity-local
andmake watch
commands in that directory and leave that server running. - Produce a Unity wasm targeted build using the Build menu (the build should be named just "unity" to avoid renamings later).
- When the build finishes, copy all the files inside the resulting
/build
folder (unity.loader.js
may not be necessary) and paste them insidebrowser-interface/node_modules/@dcl/explorer
. - Run the browser explorer through
http://localhost:8080/?ENABLE_WEB3
. Now, it should use your local Unity build. Don't mind the white screen at the beginning, that's because the website repo is not being used and it's only loading Browser Interface with the build. - If you need a Unity re-build, you can just replace the files and reload the browser without restarting the
make watch
process.
Alternatively you can go through these steps after step 3 and load the build locally using localhost:3000
- Make sure you have the explorer website repository cloned.
- Make sure you have the local website up and running by executing
npm run start:linked
in the cloned repo directory (npm i
first just in case). - When the WebGL build finishes, copy all the files inside the resulting
/build
folder (unity.loader.js
is not necessary as we use a modified loader) and paste them insideexplorer-website/node_modules/@dcl/explorer
. - Access using
localhost:3000
If you get the "missing xcrun" error when trying to run the make watch
command, you should download the latest command line tools for macOS, either by downloading them from https://developer.apple.com/download/more/?=command%20line%20tools or by re-installing XCode
If the local WebGL build always fails with the error System.ComponentModel.Win32Exception (2): No such file or directory...
it's because you are missing Python needed version (MacOS 12.3 onwards removes the previously-integrated python installation). So to solve this issue just install this Python version.
- How to use Unity visual tests
- How to profile a local Unity build remotely
- How to connect the Editor with play.decentraland.org
- For more advanced topics, don't forget to check out our Architecture Decisions Records (ADR) repository.
- How to create new components for ECS7
- How to modify the Renderer Protocol
- How to use Asset Bundle Converter
This repository is protected with a standard Apache 2 license. See the terms and conditions in the LICENSE file.