TMPro_TexturePostProcessor.cs
3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace TMPro.EditorUtilities
{
public class TMPro_TexturePostProcessor : AssetPostprocessor
{
void OnPostprocessTexture(Texture2D texture)
{
Texture2D tex = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D;
// Send Event Sub Objects
if (tex != null)
TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
}
}
/// <summary>
/// Asset post processor used to handle font assets getting updated outside of the Unity editor.
/// </summary>
class FontAssetPostProcessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (var asset in importedAssets)
{
if (AssetDatabase.GetMainAssetTypeAtPath(asset) == typeof(TMP_FontAsset))
{
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath(asset, typeof(TMP_FontAsset)) as TMP_FontAsset;
if (fontAsset != null)
TMP_EditorResourceManager.RegisterFontAssetForDefinitionRefresh(fontAsset);
}
}
}
}
//public class TMPro_PackageImportPostProcessor : AssetPostprocessor
//{
// static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
// {
// for (int i = 0; i < importedAssets.Length; i++)
// {
// if (importedAssets[i].Contains("TextMesh Pro/Resources/TMP Settings.asset"))
// {
// Debug.Log("New TMP Settings file was just imported.");
// // TMP Settings file was just re-imported.
// // Check if project already contains
// }
// if (importedAssets[i].Contains("com.unity.TextMeshPro/Examples"))
// {
// //Debug.Log("New TMP Examples folder was just imported.");
// }
// //Debug.Log("[" + importedAssets[i] + "] was just imported.");
// }
// //for (int i = 0; i < deletedAssets.Length; i++)
// //{
// // if (deletedAssets[i] == "Assets/TextMesh Pro")
// // {
// // //Debug.Log("Asset [" + deletedAssets[i] + "] has been deleted.");
// // string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
// // //Check for and inject TMP_PRESENT
// // if (currentBuildSettings.Contains("TMP_PRESENT;"))
// // {
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT;", "");
// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
// // }
// // else if (currentBuildSettings.Contains("TMP_PRESENT"))
// // {
// // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT", "");
// // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
// // }
// // }
// //}
// }
//}
}