Esempio n. 1
0
        public static string GetCurrentDirectoryAbsolutePathFromSelection()
        {
            var folderPath = ZenUnityEditorUtil.TryGetSelectedFolderPathInProjectsTab();

            if (folderPath != null)
            {
                return(folderPath);
            }

            var filePath = ZenUnityEditorUtil.TryGetSelectedFilePathInProjectsTab();

            if (filePath != null)
            {
                return(Path.GetDirectoryName(filePath));
            }

            return(Application.dataPath);
        }
        public static void CreateProjectContext()
        {
            var absoluteDir = ZenUnityEditorUtil.TryGetSelectedFolderPathInProjectsTab();

            if (absoluteDir == null)
            {
                EditorUtility.DisplayDialog("Error",
                                            "Could not find directory to place the '{0}.prefab' asset.  Please try again by right clicking in the desired folder within the projects pane."
                                            .Fmt(ProjectContext.ProjectContextResourcePath), "Ok");
                return;
            }

            var parentFolderName = Path.GetFileName(absoluteDir);

            if (parentFolderName != "Resources")
            {
                EditorUtility.DisplayDialog("Error",
                                            "'{0}.prefab' must be placed inside a directory named 'Resources'.  Please try again by right clicking within the Project pane in a valid Resources folder."
                                            .Fmt(ProjectContext.ProjectContextResourcePath), "Ok");
                return;
            }

            CreateProjectContextInternal(absoluteDir);
        }