Select to view content in your preferred language

Unable to load a SLPK file from disk

312
0
09-24-2024 10:02 PM
ChrisAnderson7
Emerging Contributor

I have a SLPK file in my persistant data folder and I want to load it as a layer at runtime. I get the following error message. I get the same error when trying add it via the Inspector.

InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <606c2e0a56af495988c860a4ac613e74>:0)
System.Collections.Generic.Stack`1[T].Pop () (at <606c2e0a56af495988c860a4ac613e74>:0)
UnityEditor.EditorGUI.EndProperty () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorGUI.cs:6848)
UnityEditor.EditorGUI+PropertyScope.CloseScope () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorGUI.cs:6717)
UnityEngine.GUI+Scope.Dispose (System.Boolean disposing) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUI.cs:1975)
UnityEngine.GUI+Scope.Dispose () (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUI.cs:1988)
Esri.ArcGISMapsSDK.Editor.Components.ArcGISLayerInstanceDataEditor.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@c75e1c36614c/Editor/Components/ArcGISLayerInstanceDataEditor.cs:61)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:27)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:182)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:142)
UnityEditorInternal.ReorderableList+Defaults.DrawElement (UnityEngine.Rect rect, UnityEditor.SerializedProperty element, System.Object listItem, System.Boolean selected, System.Boolean focused, System.Boolean draggable, System.Boolean editable) (at /Users/bokken/build/output/unity/unity/Editor/Mono/GUI/ReorderableList.cs:397)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at /Users/bokken/build/output/unity/unity/Editor/Mono/GUI/ReorderableList.cs:986)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at /Users/bokken/build/output/unity/unity/Editor/Mono/GUI/ReorderableList.cs:774)
UnityEditorInternal.ReorderableListWrapper.DrawChildren (UnityEngine.Rect listRect, UnityEngine.Rect headerRect, UnityEngine.Rect sizeRect, UnityEngine.Rect visibleRect, UnityEngine.EventType previousEvent) (at /Users/bokken/build/output/unity/unity/Editor/Mono/Inspector/ReorderableListWrapper.cs:243)
UnityEditorInternal.ReorderableListWrapper.Draw (UnityEngine.GUIContent label, UnityEngine.Rect r, UnityEngine.Rect visibleArea, System.String tooltip, System.Boolean includeChildren) (at /Users/bokken/build/output/unity/unity/Editor/Mono/Inspector/ReorderableListWrapper.cs:196)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:224)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:142)
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/bokken/build/output/unity/unity/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:301)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorGUILayout.cs:2072)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUILayoutOption[] options) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorGUILayout.cs:2056)
Esri.ArcGISMapsSDK.Editor.Components.ArcGISMapComponentEditor.OnInspectorGUI () (at ./Library/PackageCache/com.esri.arcgis-maps-sdk@c75e1c36614c/Editor/Components/ArcGISMapComponentEditor.cs:225)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass76_0.<CreateInspectorElementUsingIMGUI>b__0 () (at /Users/bokken/build/output/unity/unity/Editor/Mono/UIElements/Inspector/InspectorElement.cs:717)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:203)

 

 

 

using System;
using System.Collections;
using System.Collections.Generic;
using Esri.ArcGISMapsSDK.Components;
using Esri.ArcGISMapsSDK.Samples.Components;
using Esri.GameEngine.Layers;
using Esri.Unity;
using UnityEngine;

[RequireComponent(typeof(ArcGISTabletopControllerComponent))]
public class LoadMap : MonoBehaviour
{
    IEnumerator Start()
    {
        ArcGISMapComponent arcGISMap = GetComponent<ArcGISTabletopControllerComponent>().MapComponent;
        yield return new WaitUntil(() => arcGISMap.Map != null);
        var mapLayers = arcGISMap.Map.Layers;
        string source = Application.persistentDataPath + "/threeDSceneLayer.slpk";
        mapLayers.Add(new ArcGIS3DObjectSceneLayer(source, "", 1, true, ""));
        arcGISMap.View.Map.Layers = mapLayers;
    }
}

 

0 Kudos
0 Replies