static void OnUpdateMainWindowTitle(ApplicationTitleDescriptor descriptor)
 {
     descriptor.title = string.Format("{1}* [{2}] {0}",
                                      descriptor.title,
                                      Git("symbolic-ref --short HEAD"),
                                      Git("rev-parse --short HEAD"));
 }
Пример #2
0
        static void EditorApplicationOnUpdateMainWindowTitle(ApplicationTitleDescriptor obj)
        {
            if (s_RepoPath == null)
            {
                try
                {
                    // DataPath: C:\path\to\repo\VS\Assets
                    // => repo
                    var    repoPath          = Path.GetDirectoryName(Path.GetDirectoryName(Application.dataPath));
                    string dotRepoConfigFile = Path.Combine(repoPath, k_DotConfigFileName);
                    if (File.Exists(dotRepoConfigFile))
                    {
                        s_RepoPath = File.ReadAllText(dotRepoConfigFile);
                        if (s_RepoPath.IndexOf(k_GitBranchVariable, StringComparison.InvariantCultureIgnoreCase) != -1)
                        {
                            ProcessStartInfo startInfo = new ProcessStartInfo("git");

                            startInfo.UseShellExecute        = false;
                            startInfo.WorkingDirectory       = repoPath;
                            startInfo.RedirectStandardInput  = true;
                            startInfo.RedirectStandardOutput = true;
                            startInfo.Arguments = "rev-parse --abbrev-ref HEAD";

                            using (Process process = new Process {
                                StartInfo = startInfo
                            })
                            {
                                process.Start();
                                string gitbranch = process.StandardOutput.ReadLine();
                                s_RepoPath = new Regex(k_GitBranchVariable, RegexOptions.IgnoreCase).Replace(s_RepoPath, gitbranch);
                            }
                        }
                    }
                    else
                    {
                        s_RepoPath = Path.GetFileName(repoPath);
                    }
                }
                catch
                {
                    s_RepoPath = "???";
                }
            }

            obj.title = $"{s_RepoPath}/{obj.title}";
        }
Пример #3
0
    static void EditorApplicationOnUpdateMainWindowTitle(ApplicationTitleDescriptor obj)
    {
        if (s_RepoPath == null)
        {
            try
            {
                // DataPath: C:\path\to\repo\VS\Assets
                // => repo
                s_RepoPath = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(Application.dataPath)));
            }
            catch
            {
                s_RepoPath = "???";
            }
        }

        obj.title = $"{s_RepoPath}/{obj.title}";
    }
Пример #4
0
 internal static void OnAppMainWindowTitleUpdate(ApplicationTitleDescriptor appTitleDesc)
 {
     var titleDesc = new TitleDescriptor
     {
         title = appTitleDesc.title,
         projectName = appTitleDesc.projectName,
         unityVersion = appTitleDesc.unityVersion,
         activeSceneName = appTitleDesc.activeSceneName,
         licenseType = appTitleDesc.licenseType,
         previewPackageInUse = appTitleDesc.previewPackageInUse,
         targetName = appTitleDesc.targetName,
         codeCoverageEnabled = appTitleDesc.codeCoverageEnabled
     };
     UpdateMainWindowTitleHandler?.Invoke(titleDesc);
     if (titleDesc.title == appTitleDesc.title)
     {
         appTitleDesc.title = UnityEditor.EditorApplication.GetDefaultMainWindowTitle(new ApplicationTitleDescriptor(
             titleDesc.projectName, titleDesc.unityVersion, titleDesc.activeSceneName,
             titleDesc.licenseType, titleDesc.previewPackageInUse, titleDesc.targetName,
             titleDesc.codeCoverageEnabled));
     }
 }