Exemple #1
0
        internal static void ShowUsage(string path, string[] gameObjectPath)
        {
            path = FileUtility.MakeRelativeToProjectPath(path);
            if (path == null)
            {
                return;
            }

            path = FileUtility.NormalizeWindowsToUnix(path);
            var extension = Path.GetExtension(path).ToLower();

            EditorUtility.FocusProjectWindow();

            switch (extension)
            {
            case ".unity":
                ShowSceneUsage(path, gameObjectPath);
                break;

            default:
                var asset = AssetDatabase.LoadMainAssetAtPath(path);
                Selection.activeObject = asset;
                EditorGUIUtility.PingObject(asset);
                break;
            }
        }
        public ProjectGeneration(string tempDirectory, IAssemblyNameProvider assemblyNameProvider, IFileIO fileIoProvider, IGUIDGenerator guidGenerator)
        {
            ProjectDirectory       = FileUtility.NormalizeWindowsToUnix(tempDirectory);
            m_ProjectName          = Path.GetFileName(ProjectDirectory);
            m_AssemblyNameProvider = assemblyNameProvider;
            m_FileIOProvider       = fileIoProvider;
            m_GUIDGenerator        = guidGenerator;

            SetupProjectSupportedExtensions();
        }
Exemple #3
0
        private bool IsProjectGeneratedFor(string path, out ProjectGenerationFlag missingFlag)
        {
            missingFlag = ProjectGenerationFlag.None;

            // No need to check when opening the whole solution
            if (string.IsNullOrEmpty(path))
            {
                return(true);
            }

            // We only want to check for cs scripts
            if (ProjectGeneration.ScriptingLanguageForFile(path) != ScriptingLanguage.CSharp)
            {
                return(true);
            }

            // Even on windows, the package manager requires relative path + unix style separators for queries
            var basePath     = _generator.ProjectDirectory;
            var relativePath = FileUtility
                               .NormalizeWindowsToUnix(path)
                               .Replace(basePath, string.Empty)
                               .Trim(FileUtility.UnixSeparator);

            var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(relativePath);

            if (packageInfo == null)
            {
                return(true);
            }

            var source = packageInfo.source;

            if (!Enum.TryParse <ProjectGenerationFlag>(source.ToString(), out var flag))
            {
                return(true);
            }

            if (_generator.AssemblyNameProvider.ProjectGenerationFlag.HasFlag(flag))
            {
                return(true);
            }

            // Return false if we found a source not flagged for generation
            missingFlag = flag;
            return(false);
        }