Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit cdded09

Browse files
committed
Fix SLAM map saving on close feature
Leverage Assets/ to /sdcard path conversion mechanism by specifying map output path to Assets/map. Add better error handling and reporting.
1 parent 79e0704 commit cdded09

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

Assets/SolAR/Demos/Scenes/NoviceVersion.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ GameObject:
403403
m_Icon: {fileID: 0}
404404
m_NavMeshLayer: 0
405405
m_StaticEditorFlags: 0
406-
m_IsActive: 1
406+
m_IsActive: 0
407407
--- !u!4 &262081224
408408
Transform:
409409
m_ObjectHideFlags: 0
@@ -9084,7 +9084,7 @@ PrefabInstance:
90849084
- target: {fileID: 8997161845923243914, guid: 37f082361edc9064ba18b144c5e661ce,
90859085
type: 3}
90869086
propertyPath: isUnityWebcam
9087-
value: 0
9087+
value: 1
90889088
objectReference: {fileID: 0}
90899089
- target: {fileID: 8997161845923243914, guid: 37f082361edc9064ba18b144c5e661ce,
90909090
type: 3}

Assets/SolAR/Demos/Scripts/SolARMenu.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,13 @@ void Close()
101101
solarPipeline.m_configurationPath = solarPipeline.m_pipelinesPath[solarPipeline.m_selectedPipeline];
102102
//solarPipeline.m_uuid = solarPipeline.m_pipelinesUUID[solarPipeline.m_selectedPipeline];
103103
#if UNITY_ANDROID && !UNITY_EDITOR
104-
Android.SaveConfiguration(solarPipeline.m_configurationPath);
105-
Text text = m_popup.GetComponentInChildren<Text>();
106-
if (pipelineMngrStopSuccess)
107-
{
108-
text.text = "Configuration saved";
109-
}
110-
else
104+
string message = "Configuration saved";
105+
if (!Android.SaveConfiguration(solarPipeline.m_configurationPath) || !pipelineMngrStopSuccess)
111106
{
112-
text.text = "Configuration could not be saved (see logs)";
107+
message = "Error when closing pipeline (see logs)";
113108
}
109+
Text text = m_popup.GetComponentInChildren<Text>();
110+
text.text = message;
114111
StartCoroutine(FadeOut(m_popup.GetComponent<Image>(), m_popup.GetComponentInChildren<Text>()));
115112
#endif
116113
solarPipeline.Init();

Assets/SolAR/Editor/SolARBuildProcess.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ void ReplacePluginPaths(string confFileName, BuildReport report)
127127
foreach (var element in configComp.Elements("property"))
128128
{
129129
var attriName = element.Attribute("name");
130-
if (attriName.Value.Contains("File") || attriName.Value.Contains("Path") || attriName.Value.Contains("file") || attriName.Value.Contains("path"))
130+
if (attriName.Value.Contains("File")
131+
|| attriName.Value.Contains("Path")
132+
|| attriName.Value.Contains("file")
133+
|| attriName.Value.Contains("path")
134+
|| attriName.Value.Contains("directory"))
131135
{
132136
var attribValue = element.Attribute("value");
133137
string new_value = "";

Assets/SolAR/Pipelines/PipelineSlam.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
<property name="minTrackedPoints" type="int" value="100" />
281281
</configure>
282282
<configure component="SolARMapper">
283-
<property name="directory" type="string" value="map" />
283+
<property name="directory" type="string" value="./Assets/map" />
284284
<property name="identificationFileName" type="string" value="identification.bin" />
285285
<property name="coordinateFileName" type="string" value="coordinate.bin" />
286286
<property name="pointCloudManagerFileName" type="string" value="pointcloud.bin" />

Assets/SolAR/Scripts/Utilities/Android.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,19 @@ public static void ReplacePathToApp(string filepath)
120120
* Write a cache with the path of the current pipeline used
121121
* </summary>
122122
* */
123-
public static void SaveConfiguration(string configurationPath)
123+
public static bool SaveConfiguration(string configurationPath)
124124
{
125125
string dest = Application.persistentDataPath + "/StreamingAssets/SolAR/Android/.pipeline";
126-
if (File.Exists(dest)) File.Delete(dest);
127-
File.WriteAllText(dest, configurationPath);
126+
try
127+
{
128+
if (File.Exists(dest)) File.Delete(dest);
129+
File.WriteAllText(dest, configurationPath);
130+
} catch(Exception e)
131+
{
132+
Debug.LogError("Could not save configuration '" + configurationPath + "' to '" + dest + "': " + e.Message );
133+
return false;
134+
}
135+
return true;
128136
}
129137

130138
/** <summary>

Assets/StreamingAssets/SolAR/Pipelines/PipelineSlam.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
<property name="minTrackedPoints" type="int" value="100" />
281281
</configure>
282282
<configure component="SolARMapper">
283-
<property name="directory" type="string" value="map" />
283+
<property name="directory" type="string" value="./SolARDemo_Data/map" />
284284
<property name="identificationFileName" type="string" value="identification.bin" />
285285
<property name="coordinateFileName" type="string" value="coordinate.bin" />
286286
<property name="pointCloudManagerFileName" type="string" value="pointcloud.bin" />

0 commit comments

Comments
 (0)