Tutorial
Heading
Apr 29, 2022

How to import Decentraland SkyboxEditor into Unity

We are importing this third-party tool created by the official Decentraland team into our Unity project

Introduction

Being able to preview the final result of the Decentraland scene is crucial for the development and testing process in the project.

Otherwhise, we would need to export the scene and test it to check the visual results at different times in the day and night cycle.

That’s why we are importing this third-party tool created by the official Decentraland team into our Unity project.

To get this tool working, we will start importing a few dependencies like the lighting settings and Universal RP. Then, we will import the tool and make some fixes to get everything working.

Static skybox preview (only day time)
Dynamic skybox preview (full cycle)

Objective

  • Preview DCL scenes in Unity before the export process.
  • Import Dependencies:
    i. Universal Render Pipeline
    ii. Lighting Settings
  • Import Skybox Editor Tool from the official DCL repository.
  • Import ToonShader included in the Skybox package.

Resources

  • Unity3D 2020.3.0f1
    https://unity3d.com/es/get-unity/download/archive
  • Official DCL GitHub Repository
    https://github.com/decentraland/unity-renderer.git
  • Universal RP Package (Unity)
    https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@11.0/manual/

Import lighting settings

First of all, you will need to drag and drop the Lighting settings from the packaged resources to the assets folder in the project. This resource is called InitialSceneSettings.lighting and contains different parameters and settings.

To start using this lighting configuration go to Window/Rendering/Lighting in the Unity Editor and switch your lighting settings with the new one.

Lighting set up in the Lighting Editor

With this simple step, your lighting settings are configured to preview DCL scenes.

Import Universal RP

To import the required URP version (the one used in the official repository), go to the Json file called manifest.json and add this code line inside the dependencies section:

"com.unity.render-pipelines.universal": "10.5.1",

You can find this file at C:\...\UnityProject\Packages\manifest.json

It should look something like this:

URP added to the Manifest.json

Now, you have to import the custom package called dcl-UniversalRenderPipeline.unitypackage into the project. You can find this package in the packaged resources.

The next step is selecting the imported URP in the editor.

Open Edit/ProjectSettings/Graphics in the editor and select the new Render Pipeline.

URP set up in Unity project settings

Once the previous steps are completed, your new Render Pipeline is set and ready to use, but most of your materials will appear broken with a full pink colour.

To fix this, go to Edit/Render Pipeline/Universal RP and click “Upgrade Materials to UniversalRP Materials”.

Unity Editor to upgrade Materials into URP
Before Material Upgrade to URP

After Material Upgrade to URP

To fix all the materials, you will need to make a few changes:

  • Select the original materials from the assets folder instead of using instances.
  • Create a new material to use as new DefaultMaterial.
  • Change your script references to target the new Render Pipeline if needed.

That’s all for the Universal RP. If you followed the instructions step by step, your URP is now set and ready to be used with the skybox editor.

Import Skybox Editor tool

It’s time to import the last custom package from our packaged resources: dcl-ProceduralSkybox.unitypackage.

Once imported, you may see a few errors in your console log, but don’t panic, it’s normal and we will fix it right now.

  • First, you’re going to remove packages in conflict (if u have any of them).

    A good example is Version Control or Unity Analytics. Those packages’ assemblies conflict with ours and must be removed or renamed to avoid these  warnings, depending on the warning.

Multiple errors in the Unity Editor due to unnecessary packages

  • The second step is to edit the manifest.json file at C:\...\UnityProject\Packages\manifest.json and add the following lines of code to import a few packages with dependencies that must be installed to get the skybox working:

"net.tnrd.nsubstitute": "https://github.com/decentraland/Unity3D-NSubstitute.git",
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
"com.unity.test-framework.performance": "1.3.3-preview",
"com.unity.cinemachine": "2.7.4",

  • For the third step, you have to drag and drop the content in the folder “dcl-AssemblyAssets” to your Unity Assets folder. This folder contains all the assembly references and metadata that the Unity custom package is missing from the original DCL project Unity-Renderer.

Folders to drop in to Unity Assets folder

  • To end with this process, you may need to fix a few code errors that appears if you are using other third-party plugins like UniGif.

Now, you can go to Window/SkyboxEditor in the Unity Editor to open a new tab, allowing you to control the skybox day and night cycle.

Additionally, you have just installed the ToonShader used by DCL to preview the final appearance of the avatars inside the Unity Editor.

Conclusion

The Skybox is a big time saver for previewing the final result of the project and understand how diferent lighting conditions can affect our materials and models in the day/night cycle without repeatedly exporting the scene until we achieve the desired outcome.

However, this process could be easier if Unity exporting all the files with .asmdef and .asmdef.meta extensions in its custom packages, but it doesn’t do so. That’s why I created the dcl-AssemblyAssets folder with a folder hierarchy that combines with the assets imported in the Skybox package, solving all those dependencies to get the skybox working properly.

Dynamic skybox preview (full cycle)
Code
Decentraland
Carlos Castro
Coder
Tutorial
How to import Decentraland SkyboxEditor into Unity
Tutorial
Doing a MANA transaction in a Decentraland scene
Tutorial
Canvas (2D UI) Manager in Decentraland