Select to view content in your preferred language

Issue with embedding *.slpk package in Unity

1715
4
07-29-2022 01:56 AM
WinfriedSchwan
Emerging Contributor

Hi all,

It looks like I'm not able to add an *.slpk package successfully in my Unity project using ArcGIS Maps SDK for Unity 1.0. I created the *.slpk package in ArcGIS Pro and I'm pretty convinced that the package itself is fine because I reimported the package in ArcGIS Pro and it looked like expected. However when I added the package in Unity nothing seems to happen. Not sure if I missed something when embedding the slpk package in Unity.

I wonder if there is a "reference" *.slpk package that is guaranteed to work within Unity. Any hints would be appreciated on how to get rid of this issue.

A minor issue that I also noticed is that the "Layers" section in the Unity Inspector gets somehow messed up after adding something.

Thanks and best regards

Winfried

Tags (3)
0 Kudos
4 Replies
Jade
by Esri Contributor
Esri Contributor

Hi Winfried,

Your data loading issue could have several causes, can you check: 

1. your .slpk file needs to be 1.7 or higher. You can check this by open the .JSON file

2. whether your spatial reference (SR) is supported by the map type. Global scene supports all the geographic coordinate systems. For a projected coordinate system, only Web Mercator (Auxiliary Sphere) (WKID: 3857) is supported. Local scene supports all projected coordinate systems. For the geographic coordinate system, WGS 84 (WKID: 4326) and China Geodetic Coordinate System 2000 (WKID: 4490) are supported. 

3. If the above is correct, your data spatial reference may differ from your map spatial reference which prevents your data from loading. You can remove your basemap and add your slpk as the first layer, or replace your basemap with basemap that shares the same spatial reference with your data. This basemap, or the first layer in the case there's no basemap will set your map spatial reference to be the same with your data. Then add your data, save and reload your scene, click on "zoom to layer" to find your data. 

Regarding the layer bug you mentioned, this is a unity bug that happens in some unity versions. You can either use the modes panel, modify the UI code or change unity version to 2021.3.1f1. 

WinfriedSchwan
Emerging Contributor

Hi Jade,

thanks for your detailed reply, that was very helpful. In fact one of the reasons for my issue seemed to be some trouble with the spatial reference. But I also had some misconfiguration with the camera that seemed to be looking in a slightly wrong direction. After starting over from scratch I found that my *.slpk package showed in Unity. So this is now understood here.

But please let me ask one more thing: As I said the imported slpk is visible in Unity but it seems difficult to get a grip on the related GameObject to change its material for example. Although I can select the slpk in the Scene View and it is visible in the Unity Inspector as GameObject_123456 or similar I was not successful to assign a different material to the imported slpk i.e. I mean I can change the material but once I return from Unity's Play Mode I end up with having the original material again...

Any hints on how to change the material persistently on an imported slpk would be appreciated.

Thanks and best regards
Winfried

0 Kudos
Jade
by Esri Contributor
Esri Contributor

Good to know that your data is loaded. For changing material persistently you can look at the 3D attribute sample scene. There's a variable called MaterialReference that you can interact with. You can also change building material individually. 

WinfriedSchwan
Emerging Contributor

Hi Jade,

again this hint was very helpful. MaterialReference was exactly what I needed. The following code did the job for me 🙂

Thanks and best regards
Winfried

ArcGIS3DObjectSceneLayer boundariesLayer = 
    new ArcGIS3DObjectSceneLayer("D:/tmp/boundaries.slpk", "Boundaries Layer", 
    1.0f, true, "");

boundariesLayer.MaterialReference = 
    new Material(Resources.Load<Material>("Materials/DarkGreyMaterial"));

arcGISMap.Layers.Add(boundariesLayer);