Skip to content

decentraland/unity-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decentraland Unity Renderer

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 UI
  • browser-interface to connect to the different aspects requiring of a web browser, such as connection with a wallet and WebRTC communications

Running the Explorer

Main Dependencies

  • 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

Steps

Check: Multiplatform in Editor

  1. Download and install Unity 2022.3.6f1
  2. Open the scene named InitialScene
  3. Within the scene, select the DebugConfig GameObject.
  4. On DebugConfig inspector, make sure that Base url mode is set to Custom and Base url custom is set to https://play.decentraland.zone/?
  5. Run the Initial Scene in the Unity editor
  6. 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 the Game View.
  7. 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.

Troubleshooting

Missing git lfs extension

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


Testing your branch using automated builds

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>

Links for Contributors

  1. Contribution Guidelines
  2. Coding Guidelines
  3. Code Review Standards
  4. Architecture

Advanced debugging scenarios

Running the browser-interface

In order to run browser interface in any platform follow the next instructions

How to run make watch

  1. Open browser-interface with Visual Studio Code
  2. Make sure you have the devcontainers extension installed
  3. Make sure Docker Desktop is running
  4. At Visual Studio Code press F1 execute Reopen in Container and wait for it to finish.
  5. Go to Terminal > New Terminal menu and run make watch command.

How to run browser-interface unit tests

  1. Follow the previous process to run make watch
  2. Open localhost:8080/test in your browser
  3. Watch the results

Debug with Unity Editor + local Browser Interface

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.

Steps

  1. Make sure you have the proper Unity version up and running
  2. Make sure you are running browser-interface through make watch command on browser-interface path.
  3. Back in unity editor, open the DebugConfig component inspector of InitialScene
  4. Make sure that the component is setup correctly
  5. Hit 'Play' button

Debug with browsers + local Unity build

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.

Steps

  1. Make sure you have the proper Unity version up and running
  2. Make sure you are running browser-interface correctly by running npm install, make build-unity-local and make watch commands in that directory and leave that server running.
  3. Produce a Unity wasm targeted build using the Build menu (the build should be named just "unity" to avoid renamings later).
  4. When the build finishes, copy all the files inside the resulting /build folder (unity.loader.js may not be necessary) and paste them inside browser-interface/node_modules/@dcl/explorer.
  5. 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.
  6. 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

  1. Make sure you have the explorer website repository cloned.
  2. 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).
  3. 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 inside explorer-website/node_modules/@dcl/explorer.
  4. Access using localhost:3000

Troubleshooting

MacOS: Missing xcrun

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

MacOS: Build fails throwing System.ComponentModel.Win32Exception (2): No such file or directory...

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.

Frameworks and Tools

Technical how-to guides and explainers

Setup CircleCI

Setup CircleCI

Copyright info

This repository is protected with a standard Apache 2 license. See the terms and conditions in the LICENSE file.