Unity Version:2021.3.6f1
local file path: Internal storage in the root directory / GIS
local file format: tpkx and slpk
tpkx: use for basemap, basemap layer type has set imagelayer
slpk: use for 3DObjectSceneLayer
In Unity editor mode, everything works fine, but when packaged as APK, no errors are reported and the model and base map are not loaded.
Can you tell me exactly what is not done well? thank you
code:
Unity Editor:
player setting:
Solved! Go to Solution.
手动在android/data/com.xxx.xxx/file下创建文件夹,并将tpk文件和slpk文件放入后,使用Application.persistentDataPath路径后,加载成功。
原因暂不清楚
直接在arcgismapcomponent.layer图层添加slpk文件相对路径就可以了
private void CreatGSLine()
{
// Create ArcGIS layers and add them to the map
var layer_1 = new ArcGISLayerInstanceData();
layer_1.Name = "MyLayer_gs";
layer_1.Type = LayerTypes.ArcGISImageLayer;
layer_1.Source = Application.streamingAssetsPath + "/你的数据文件.tpk";
layer_1.Opacity = 1.0f;
layer_1.IsVisible = true;
//layer_1.Authentication = ;
arcgismapcomponent.Layers.Add(layer_1);
}
目标平台为安卓,谢谢,不过我也会试下直接在Inspector里面把文件路径填写上去。
再次尝试后,依旧不行
void Start()
{
ArcGISMapComponent arcGISMapComponent = FindObjectOfType<ArcGISMapComponent>();
//arcGISMapComponent.Basemap = "file:///storage/emulated/0/GIS/sh_gaode.tpkx";
//arcGISMapComponent.Basemap = "file:///storage/emulated/1/GIS/sh_gaode.tpkx";
arcGISMapComponent.Basemap = "jar:file://" + Application.dataPath + "!/assets/sh_gaode.tpkx";
arcGISMapComponent.BasemapType = BasemapTypes.ImageLayer;
ArcGISLayerInstanceData buildingLayer = new ArcGISLayerInstanceData();
buildingLayer.Name = "Building";
//buildingLayer.Source = "file:///storage/emulated/0/GIS/sh_part.slpk";
//buildingLayer.Source = "file:///storage/emulated/1/GIS/sh_part.slpk";
buildingLayer.Source = "jar:file://" + Application.dataPath + "!/assets/sh_part.slpk";
buildingLayer.Type = LayerTypes.ArcGIS3DObjectSceneLayer;
buildingLayer.Opacity = 1.0f;
buildingLayer.IsVisible = true;
arcGISMapComponent.Layers.Add(buildingLayer);
}
手动在android/data/com.xxx.xxx/file下创建文件夹,并将tpk文件和slpk文件放入后,使用Application.persistentDataPath路径后,加载成功。
原因暂不清楚
Thanks for your post! I was struggling with this issue as well. So there is apparently no way to open tpkx files on mobile device other than manually placing them on the internal storage? It must work somehow 😅. Does anyone tried to implement this solution to work properly on any device? Meaning that tpkx files would install together with the application from Google Play or from apk. I was thinking of storing the tpkx files somewhere in the Assets folder and find them using UnityWebRequest on Android platform.