TMPro_TexturePostProcessor.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. namespace TMPro.EditorUtilities
  5. {
  6. public class TMPro_TexturePostProcessor : AssetPostprocessor
  7. {
  8. void OnPostprocessTexture(Texture2D texture)
  9. {
  10. //var importer = assetImporter as TextureImporter;
  11. Texture2D tex = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)) as Texture2D;
  12. // Send Event Sub Objects
  13. if (tex != null)
  14. TMPro_EventManager.ON_SPRITE_ASSET_PROPERTY_CHANGED(true, tex);
  15. }
  16. }
  17. //public class TMPro_PackageImportPostProcessor : AssetPostprocessor
  18. //{
  19. // static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
  20. // {
  21. // for (int i = 0; i < importedAssets.Length; i++)
  22. // {
  23. // if (importedAssets[i].Contains("TextMesh Pro/Resources/TMP Settings.asset"))
  24. // {
  25. // Debug.Log("New TMP Settings file was just imported.");
  26. // // TMP Settings file was just re-imported.
  27. // // Check if project already contains
  28. // }
  29. // if (importedAssets[i].Contains("com.unity.TextMeshPro/Examples"))
  30. // {
  31. // //Debug.Log("New TMP Examples folder was just imported.");
  32. // }
  33. // //Debug.Log("[" + importedAssets[i] + "] was just imported.");
  34. // }
  35. // //for (int i = 0; i < deletedAssets.Length; i++)
  36. // //{
  37. // // if (deletedAssets[i] == "Assets/TextMesh Pro")
  38. // // {
  39. // // //Debug.Log("Asset [" + deletedAssets[i] + "] has been deleted.");
  40. // // string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
  41. // // //Check for and inject TMP_PRESENT
  42. // // if (currentBuildSettings.Contains("TMP_PRESENT;"))
  43. // // {
  44. // // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT;", "");
  45. // // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
  46. // // }
  47. // // else if (currentBuildSettings.Contains("TMP_PRESENT"))
  48. // // {
  49. // // currentBuildSettings = currentBuildSettings.Replace("TMP_PRESENT", "");
  50. // // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings);
  51. // // }
  52. // // }
  53. // //}
  54. // }
  55. //}
  56. }