Skip to content

Commit

Permalink
feat: add support for TextMeshPro, including <font> and <sprite>
Browse files Browse the repository at this point in the history
…tags
  • Loading branch information
mob-sakai committed Nov 11, 2024
1 parent 1306e19 commit a4f85cb
Show file tree
Hide file tree
Showing 22 changed files with 8,195 additions and 0 deletions.
2,797 changes: 2,797 additions & 0 deletions Assets/Demos/TextMeshPro Support/CarterOne-Regular SDF.asset

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/Demos/TextMeshPro Support/CarterOne-Regular.ttf.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Demos/TextMeshPro Support/Floor Cement.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions Assets/Demos/TextMeshPro Support/Floor Cement.jpg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions Assets/Demos/TextMeshPro Support/Fruit Jelly (B&W).jpg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions Assets/Demos/TextMeshPro Support/ImportSample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#if UNITY_EDITOR
using System.Diagnostics;
using System.Text;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;

internal static class ImportSample
{
[MenuItem("Development/Import TMP Support V1", false, 2001)]
private static void ImportTMPSupportV1()
{
Run("TextMeshPro Support");
}

[MenuItem("Development/Import TMP Support V2", false, 2002)]
private static void ImportTMPSupportV2()
{
Run("TextMeshPro Support (Unity 6)");
}

[InitializeOnLoadMethod]
private static void ImportSampleOnLoad()
{
#if UNITY_2023_2_OR_NEWER
ImportTMPSupportV2();
#else
ImportTMPSupportV1();
#endif
}

private static void Run(string sample)
{
var p = new Process()
{
StartInfo = new ProcessStartInfo()
{
Arguments = $"import-tmp-support.sh '{sample}'",
CreateNoWindow = true,
#if UNITY_EDITOR_WIN
FileName = @"C:\Program Files (x86)\Git\bin\bash.exe",
#else
FileName = "/bin/bash",
#endif
RedirectStandardError = true,
RedirectStandardOutput = true,
WorkingDirectory = $"{Application.dataPath}/..",
UseShellExecute = false
},
EnableRaisingEvents = true
};

p.Exited += (_, __) =>
{
var result = new StringBuilder();
var stdout = p.StandardOutput.ReadToEnd();
result.Append("stdout: ");
result.Append(stdout);
result.AppendLine();
result.Append("stderr: ");
result.Append(p.StandardError.ReadToEnd());
Debug.Log(result);

if (p.ExitCode == 0 && stdout.StartsWith("Imported: "))
{
var path = stdout.Replace("Imported: ", "").Trim();
AssetDatabase.ImportAsset(path, ImportAssetOptions.ImportRecursive);
}
};

p.Start();
}
}
#endif
11 changes: 11 additions & 0 deletions Assets/Demos/TextMeshPro Support/ImportSample.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a4f85cb

Please sign in to comment.