ValidateExportPath() public static method

public static ValidateExportPath ( string currentExportFilePath, string combinedPath, System.Action NullOrEmpty, System.Action DoesNotExist ) : bool
currentExportFilePath string
combinedPath string
NullOrEmpty System.Action
DoesNotExist System.Action
return bool
Esempio n. 1
0
        private void DoInspectorExporterGUI(NodeGUI node)
        {
            if (node.exportTo == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Exporter: Export given files to output directory.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Export Path:");
                var newExportPath = EditorGUILayout.TextField(
                    SystemDataUtility.GetProjectName(),
                    SystemDataUtility.GetPlatformValue(
                        node.exportTo.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    );

                var exporterrNodePath = FileUtility.GetPathWithProjectPath(newExportPath);
                if (IntegratedGUIExporter.ValidateExportPath(
                        newExportPath,
                        exporterrNodePath,
                        () => {
                    // TODO Make text field bold
                },
                        () => {
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.LabelField(exporterrNodePath + " does not exist.");
                        if (GUILayout.Button("Create directory"))
                        {
                            Directory.CreateDirectory(exporterrNodePath);
                            node.Save();
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Available Directories:");
                    string[] dirs = Directory.GetDirectories(Path.GetDirectoryName(exporterrNodePath));
                    foreach (string s in dirs)
                    {
                        EditorGUILayout.LabelField(s);
                    }
                }
                        ))
                {
                    using (new EditorGUILayout.HorizontalScope()) {
                        GUILayout.FlexibleSpace();
                                                #if UNITY_EDITOR_OSX
                        string buttonName = "Reveal in Finder";
                                                #else
                        string buttonName = "Show in Explorer";
                                                #endif
                        if (GUILayout.Button(buttonName))
                        {
                            EditorUtility.RevealInFinder(exporterrNodePath);
                        }
                    }
                }


                if (newExportPath != SystemDataUtility.GetPlatformValue(
                        node.exportTo.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    )
                {
                    node.BeforeSave();
                    node.exportTo.Add(SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newExportPath);
                    node.Save();
                }
            }

            UpdateDeleteSetting(node);
        }
        private void DoInspectorExporterGUI(NodeGUI node)
        {
            if (node.Data.ExporterExportPath == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Exporter: Export given files to output directory.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            //Show target configuration tab
            DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = DrawOverrideTargetToggle(node, node.Data.ExporterExportPath.ContainsValueOf(currentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Export Settings", node, true)){
                        if (enabled)
                        {
                            node.Data.ExporterExportPath[currentEditingGroup] = node.Data.ExporterExportPath.DefaultValue;
                        }
                        else
                        {
                            node.Data.ExporterExportPath.Remove(currentEditingGroup);
                        }
                    }
                });

                using (disabledScope) {
                    EditorGUILayout.LabelField("Export Path:");
                    var newExportPath = EditorGUILayout.TextField(
                        SystemDataUtility.GetProjectName(),
                        node.Data.ExporterExportPath[currentEditingGroup]
                        );

                    var exporterrNodePath = FileUtility.GetPathWithProjectPath(newExportPath);
                    if (IntegratedGUIExporter.ValidateExportPath(
                            newExportPath,
                            exporterrNodePath,
                            () => {
                        // TODO Make text field bold
                    },
                            () => {
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField(exporterrNodePath + " does not exist.");
                            if (GUILayout.Button("Create directory"))
                            {
                                using (new SaveScope(node)) {
                                    Directory.CreateDirectory(exporterrNodePath);
                                }
                            }
                        }
                        EditorGUILayout.Space();

                        EditorGUILayout.LabelField("Available Directories:");
                        string[] dirs = Directory.GetDirectories(Path.GetDirectoryName(exporterrNodePath));
                        foreach (string s in dirs)
                        {
                            EditorGUILayout.LabelField(s);
                        }
                    }
                            ))
                    {
                        using (new EditorGUILayout.HorizontalScope()) {
                            GUILayout.FlexibleSpace();
                                                        #if UNITY_EDITOR_OSX
                            string buttonName = "Reveal in Finder";
                                                        #else
                            string buttonName = "Show in Explorer";
                                                        #endif
                            if (GUILayout.Button(buttonName))
                            {
                                EditorUtility.RevealInFinder(exporterrNodePath);
                            }
                        }
                    }

                    if (newExportPath != node.Data.ExporterExportPath[currentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Export Path", node, true)){
                            node.Data.ExporterExportPath[currentEditingGroup] = newExportPath;
                        }
                    }
                }
            }
        }