iOS build fails to display TextMeshPro sprites/emojis due to unpacked sprite warnings in clean CI build #3
-
DescriptionDuring a clean CI build (without
Result: TextMeshPro sprites and emojis do not render on iOS devices. Steps to Reproduce
Expected Behavior
Actual Behavior
Environment
Additional Context
Related Configuration
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, public static void PreBuildMethod() {
var paths = Directory.EnumerateFiles("Assets/", "*.tmpspriteatlas", SearchOption.AllDirectories);
foreach (var tmpAtlasPath in paths) {
var text = File.ReadAllText(tmpAtlasPath);
var atlasGuid = JsonUtility.FromJson<TextMeshProSupportAssetData>(text).atlasGuid;
var iconAtlasPath = AssetDatabase.GUIDToAssetPath(atlasGuid);
AssetDatabase.ImportAsset(iconAtlasPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
AssetDatabase.ImportAsset(tmpAtlasPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
}
}
[Serializable]
public class TextMeshProSupportAssetData {
public string atlasGuid;
} |
Beta Was this translation helpful? Give feedback.
-
Thank you for your fast response! Here's the slightly modified version I'm using (with additional build preprocessing): #if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
/// <summary>
/// Ensures TMP sprite assets are properly updated before build
/// </summary>
public class TmpPreBuild : IPreprocessBuildWithReport
{
public int callbackOrder => -1000;
static bool IsHeadlessMode => SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null;
public void OnPreprocessBuild(BuildReport report)
{
var logLabel = $":: {nameof(TmpPreBuild)}.{nameof(OnPreprocessBuild)}";
if (IsHeadlessMode) {
Debug.Log(logLabel);
} else {
Debug.Log($"{logLabel} - skipped");
return;
}
var paths = Directory.EnumerateFiles("Assets/", "*.tmpspriteatlas", SearchOption.AllDirectories);
foreach (var tmpAtlasPath in paths) {
var text = File.ReadAllText(tmpAtlasPath);
var atlasGuid = JsonUtility.FromJson<TMPro.TmpSpriteAssetData>(text).atlasGuid;
var iconAtlasPath = AssetDatabase.GUIDToAssetPath(atlasGuid);
AssetDatabase.ImportAsset(iconAtlasPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
AssetDatabase.ImportAsset(tmpAtlasPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
}
}
}
#endif |
Beta Was this translation helpful? Give feedback.
Hi,
Unfortunately, I can't test the build on CI for iOS. A possible solution is to re-import the plugin assets as a pre-build step. Can you try this?
Sample code: