Best way to include 3d objects/tile packages inside Unity build ?

384
3
02-26-2024 11:29 PM
anzago
by
New Contributor

Hi,

I'm trying to build an application that is using 3 local packages to load with the ArcGIS Unity SDK.

In the ArcGISMapComponent I can specify the "source" field for each layer but it seems to only support absolute path. Is there a way to reference a package that could be located inside the Unity "Resources" folder for instance ?

I think I can still configure the map from a C# script and use relative paths there, but I would prefer to have everything configured with the map component if it's possible.

 

Thankful for any help !

0 Kudos
3 Replies
ws4945894
New Contributor

Hi,

once I had a similar problem and got it resolved like that...

1) Create folder StreamingAssets (spelling matters!) on the same level as Scenes, Scripts and the like...

2) Use the following code snippet to access any files in folder StreamingAssets

string somePackageSlpkPath = Path.Combine(Application.streamingAssetsPath, "some_package.slpk");


ArcGIS3DObjectSceneLayer someLayer = new ArcGIS3DObjectSceneLayer(somePackageSlpkPath,
"SomeLayer", 1.0f, true, "");

The trick is to use Application.streamingAssetsPath which tells Unity to look into the StreamingAssets folder. This takes care of packaging any files in there into the build...

Hope this helps...

Best regards

Winfried

0 Kudos
anzago
by
New Contributor

Hi,

Your solution is working great for my layers !

Thanks a lot !

0 Kudos
ws4945894
New Contributor

Glad to hear that, have fun!

0 Kudos