概要
using System;
using System.Text;
using TMPro;
using UnityEditor;
internal static class Example
{
[MenuItem( "hoge/hoge" )]
private static void Hoge()
{
const string path = "hoge.asset";
const string text = "あ";
var bytes = Encoding.Unicode.GetBytes( text );
var unicode = BitConverter.ToUInt16( bytes, 0 );
var fontAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>( path );
var character = fontAsset.characterTable.Find( x => x.unicode == unicode );
var glyph = character.glyph;
var metrics = glyph.metrics;
metrics.horizontalBearingY = 32;
glyph.metrics = metrics;
EditorUtility.SetDirty( fontAsset );
AssetDatabase.SaveAssetIfDirty( fontAsset );
}
}