Skip to content

Commit 034b92d

Browse files
committed
added urdf export button
1 parent 3ee2911 commit 034b92d

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

Editor/CustomEditors/ZODocumentRootEditor.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,53 @@
77

88
namespace ZO.Editor {
99

10+
11+
/// <summary>
12+
/// Saving and loading ZOSimDocumentRoot.
13+
/// </summary>
1014
[CustomEditor(typeof(ZOSimDocumentRoot))]
1115
public class ZOSimDocumentRootEditor : UnityEditor.Editor {
1216

17+
private string _URDFExportDirectory = "";
18+
1319
public override void OnInspectorGUI() {
1420

1521
DrawDefaultInspector();
1622

17-
ZOSimDocumentRoot zoSimBaseComponent = (ZOSimDocumentRoot)target;
23+
ZOSimDocumentRoot documentRoot = (ZOSimDocumentRoot)target;
1824

25+
/* TODO: no longer supporting ZOSim files. Remove this.
1926
if (GUILayout.Button("Save ZOSim")) {
20-
Debug.Log("INFO: ZOSimBaseComponent Save ZOSim");
21-
if (EditorUtility.DisplayDialog("Override File:", "Override File: " + zoSimBaseComponent.ZOSimDocumentFilePath, "OK", "Cancel")) {
22-
zoSimBaseComponent.SaveToZOSimFile(zoSimBaseComponent.ZOSimDocumentFilePath);
27+
Debug.Log("INFO: ZOSimDocumentRoot Save ZOSim");
28+
if (EditorUtility.DisplayDialog("Override File:", "Override File: " + documentRoot.ZOSimDocumentFilePath, "OK", "Cancel")) {
29+
documentRoot.SaveToZOSimFile(documentRoot.ZOSimDocumentFilePath);
2330
}
2431
2532
}
2633
2734
if (GUILayout.Button("Load ZOSim")) {
28-
Debug.Log("INFO: ZOSimBaseComponent Load ZOSim");
29-
if (EditorUtility.DisplayDialog("Override Object:", "Override Object with file: " + zoSimBaseComponent.ZOSimDocumentFilePath, "OK", "Cancel")) {
35+
Debug.Log("INFO: ZOSimDocumentRoot Load ZOSim");
36+
if (EditorUtility.DisplayDialog("Override Object:", "Override Object with file: " + documentRoot.ZOSimDocumentFilePath, "OK", "Cancel")) {
3037
31-
zoSimBaseComponent.LoadFromZOSimFile(zoSimBaseComponent.ZOSimDocumentFilePath);
38+
documentRoot.LoadFromZOSimFile(documentRoot.ZOSimDocumentFilePath);
3239
}
3340
}
41+
*/
42+
if (GUILayout.Button("Export URDF...")) {
43+
Debug.Log("INFO: ZOSimDocumentRoot Save URDF");
44+
_URDFExportDirectory = EditorUtility.OpenFolderPanel("Select URDF export directory", _URDFExportDirectory, "");
45+
46+
if (_URDFExportDirectory.Length == 0) {
47+
return;
48+
} else if (!System.IO.Directory.Exists(_URDFExportDirectory)) {
49+
EditorUtility.DisplayDialog("URDF Export Error", "Export root folder must be defined and folder must exist.", "Ok");
50+
} else {
51+
documentRoot.ExportURDF(_URDFExportDirectory);
52+
}
53+
54+
55+
}
56+
3457

3558
}
3659
}

0 commit comments

Comments
 (0)