Select to view content in your preferred language

Adding 3D Buildings to Unity

556
6
Jump to solution
05-09-2024 09:59 AM
AndrewMcLane
New Contributor III

I am creating a map based experience in Unity. I want to add a 3D buildings layer to the map. It is a location based game, so I need there to be 3D buildings wherever a user is in the world. I found this scene layer but I am getting errors when I add it to the layer like this

ArcGISBuildingSceneLayer buildingSceneLayer = new ArcGISBuildingSceneLayer(
"https://basemaps3d.arcgis.com/arcgis/rest/services/OpenStreetMap3D_Buildings_v1/SceneServer", APIKey);
map.Layers.Add(buildingSceneLayer);

The error is 'invalid json'. 
Question 1: how do I add basic 3D buildings to the map wherever in the world a user is located?

Question 2: If I wanted to alter the appearance of these buildings (ie. make them shorter or make the top half of the buildings fade into the air (transparent)), how would I go about doing this?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
and1
by Esri Contributor
Esri Contributor

We just started to support OSM layers in version 1.5. Any versions earlier than that will not work. If you have 1.4 or below, you could update it to the latest version. The current release package can be found here.

View solution in original post

6 Replies
and1
by Esri Contributor
Esri Contributor

It seems that is the incorrect layer type. Please make sure the layer type is a 3DObjectSceneLayer instead of a BuildingSceneLayer. And also be sure you are in Global mode.

So it would be:

 

var buildingLayer = new Esri.GameEngine.Layers.ArcGIS3DObjectSceneLayer("https://basemaps3d.arcgis.com/arcgis/rest/services/OpenStreetMap3D_Buildings_v1/SceneServer", "Building Layer", 1.0f, true, "");
map.Layers.Add(buildingLayer);

 

If you want to make the building transparent as a whole, you can try the example below:

 

buildingLayer.Opacity = 0.5f;

 

But I don't think you can alter the individual appearance/height of these buildings.

and1_1-1715277765677.png

Hope that helps!

 

 

AndrewMcLane
New Contributor III

Thanks for responding, @and1! I have altered my code to use the type you suggested and also changed the map type to global. I am getting a different error this time. It's 
"ArcGISLayerViewState Building Layer changed to : Error (Layer type is not supported.)
Additional info: Error processing service metadata response.
Unsupported scene layer version
UnityEngine.Debug:Log (object)"

0 Kudos
and1
by Esri Contributor
Esri Contributor

Hi @AndrewMcLane , what version of the ArcGIS Maps SDK plugin are you currently using for this project?

0 Kudos
and1
by Esri Contributor
Esri Contributor

We just started to support OSM layers in version 1.5. Any versions earlier than that will not work. If you have 1.4 or below, you could update it to the latest version. The current release package can be found here.

AndrewMcLane
New Contributor III

Yes! Thank you. This resolved it. 

0 Kudos
AndrewMcLane
New Contributor III

This is also part of the solution, @and1 ! Thank you!

0 Kudos