|
7 | 7 |
|
8 | 8 | namespace ZO.Editor { |
9 | 9 |
|
| 10 | + |
| 11 | + /// <summary> |
| 12 | + /// Saving and loading ZOSimDocumentRoot. |
| 13 | + /// </summary> |
10 | 14 | [CustomEditor(typeof(ZOSimDocumentRoot))] |
11 | 15 | public class ZOSimDocumentRootEditor : UnityEditor.Editor { |
12 | 16 |
|
| 17 | + private string _URDFExportDirectory = ""; |
| 18 | + |
13 | 19 | public override void OnInspectorGUI() { |
14 | 20 |
|
15 | 21 | DrawDefaultInspector(); |
16 | 22 |
|
17 | | - ZOSimDocumentRoot zoSimBaseComponent = (ZOSimDocumentRoot)target; |
| 23 | + ZOSimDocumentRoot documentRoot = (ZOSimDocumentRoot)target; |
18 | 24 |
|
| 25 | + /* TODO: no longer supporting ZOSim files. Remove this. |
19 | 26 | 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); |
23 | 30 | } |
24 | 31 |
|
25 | 32 | } |
26 | 33 |
|
27 | 34 | 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")) { |
30 | 37 |
|
31 | | - zoSimBaseComponent.LoadFromZOSimFile(zoSimBaseComponent.ZOSimDocumentFilePath); |
| 38 | + documentRoot.LoadFromZOSimFile(documentRoot.ZOSimDocumentFilePath); |
32 | 39 | } |
33 | 40 | } |
| 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 | + |
34 | 57 |
|
35 | 58 | } |
36 | 59 | } |
|
0 commit comments