This example shows you how to create and use your own materials and apply them to the map elements.
To see this in action, open the
Wrld/Demo/Examples.unity scene in Unity, click the Play button, and select Custom Materials from the dropdown.
The WRLD Unity package contains simple and default materials that can be used as a starting point along with existing textures that can be modified. The textures are provided under a Creative Commons Attribution 4.0 International Public License. Follow the steps below to copy the existing base materials to start modifying them. To learn more about modifying and working with Unity materials checkout the Unity documentation page for materials.
- Create a
Resourcesfolder in your
Assetsdirectory if it doesn’t exist
- Create a new folder in
- Copy all the materials (
*.mat) present in
MyMaterialsfolder using a file browser
- Similarly create a
MyTexturesfolder in the
- Copy all the texture files (*.png) from the
- Select the Wrld Map object from the scene hierarchy and expand the WrldMap script
- In the Theme Settings set the Materials Directory to “MyMaterials”
Note: The materials have been named semantically and should not be renamed.
Making changing to the materials is pretty straightforward from there on. Any changes to the materials in the
MyMaterials directory will be directly applied to the map.
Making changes to any of these materials during runtime will apply those changes as well.
If creating a material from scratch, prefer to use the Standard Unity shader/material. This type has the best interoperability with mobile platforms and minimizes the difference between each. All values in the shaders can be customized and will work as expected.
All diffuse textures in the
MyMaterials folder, or in the
Assets/Wrld/Resources/WrldMaterials/ directory if materials have not been modified, are referencing textures in the
Assets/Wrld/Textures folder and should be changed to use the ones in the
If any textures are modified, the diffuse texture of the appropriate material should be updated.
Modifying textures in the
MyTextures folder requires some prerequisite knowledge of the texture atlas layout and the UVs.
Click here for further instructions on modifying or creating new textures.
Modifying Landmark Materials
Landmarks are special buildings or locations in the world. These locations often have their own unique texture which is requested and loaded during runtime. Therefore to customize the look of the landmarks, you can provide a base Unity material which is then copied for each different landmark and assigned a diffuse texture at runtime.
- Create a new Standard Unity material (
MyLandmarkMaterial) in any folder of your choosing
- Modify the material as you see fit. Any diffuse texture assigned will be overriden, however the diffuse
Albedowill be retained
- Select the
WrldMapgame object in the scene hierarchy and expand the script with the same name
- In the
Theme Settings, drag and drop
Landmark Override Materialinput box
- This should apply your base
MyLandmarkMaterialto all the landmarks that are streamed and assign the diffuse texture accordingly