/// <summary> /// Function to pre-load the TMP Resources /// </summary> public static void LoadTextMeshProResources() { TMP_Settings.LoadDefaultSettings(); TMP_StyleSheet.LoadDefaultStyleSheet(); }
public static void CreateTextMeshProObjectPerform() { // Get the path to the selected texture. string filePath = AssetDatabase.GetAssetPath(Selection.activeObject); string filePathWithName = AssetDatabase.GenerateUniqueAssetPath(filePath + "/TMP Settings.asset"); // Create new Sprite Asset using this texture TMP_Settings settings = ScriptableObject.CreateInstance <TMP_Settings>(); AssetDatabase.CreateAsset(settings, filePathWithName); EditorUtility.SetDirty(settings); AssetDatabase.SaveAssets(); }
public void ShowTMProWarning(Shader shader, Shader mobileShader, Shader spriteShader, System.Action <Material> onCreatedMaterial) { #if UNITY_EDITOR && TMP_PRESENT if (!textMeshPro || !textMeshPro.fontSharedMaterial) { return; } // Is the material preset for dissolve? Material m = textMeshPro.fontSharedMaterial; if (m.shader != shader && m.shader != mobileShader) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox(string.Format("{0} requires '{1}' or '{2}' as a shader for material preset.", GetType().Name, shader.name, mobileShader.name), MessageType.Warning); if (GUILayout.Button("Fix")) { var correctShader = m.shader.name.Contains("Mobile") ? mobileShader : shader; textMeshPro.fontSharedMaterial = ModifyTMProMaterialPreset(m, correctShader, onCreatedMaterial); } EditorGUILayout.EndHorizontal(); return; } // Is the sprite asset for dissolve? TMP_SpriteAsset spriteAsset = textMeshPro.spriteAsset ?? TMP_Settings.GetSpriteAsset(); // Sprite asset might not exist at all if (spriteAsset == null) { return; } m = spriteAsset.material; if (m && m.shader != spriteShader && textMeshPro.richText && textMeshPro.text.Contains("<sprite=")) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox(string.Format("{0} requires '{1}' as a shader for sprite asset.", GetType().Name, spriteShader.name), MessageType.Warning); if (GUILayout.Button("Fix")) { GetComponentsInChildren <TMP_SubMesh> ().Select(x => x.gameObject).ToList().ForEach(DestroyImmediate); GetComponentsInChildren <TMP_SubMeshUI> ().Select(x => x.gameObject).ToList().ForEach(DestroyImmediate); textMeshPro.spriteAsset = ModifyTMProSpriteAsset(m, spriteShader, onCreatedMaterial); } EditorGUILayout.EndHorizontal(); return; } }