Fix issues with fallback fonts

Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations.
closes #24
feature-saving
Andrew Cassidy 4 years ago
parent ac1289a46e
commit ea8c069d68

@ -6,7 +6,7 @@
{ {
"MAJOR":0, "MAJOR":0,
"MINOR":2, "MINOR":2,
"PATCH":2, "PATCH":3,
"BUILD":0 "BUILD":0
}, },
"KSP_VERSION": "KSP_VERSION":

@ -1,4 +1,4 @@
# Conformal Decals v0.2.2 # Conformal Decals v0.2.3
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png) ![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)

@ -29,7 +29,6 @@ namespace ConformalDecals.Text {
var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>(); var loadedFonts = bundle.LoadAllAssets<TMP_FontAsset>();
foreach (var font in loadedFonts) { foreach (var font in loadedFonts) {
Logging.Log($"Adding font {font.name}"); Logging.Log($"Adding font {font.name}");
font.fallbackFontAssets.Add(FallbackFont);
} }
} }

@ -89,9 +89,11 @@ namespace ConformalDecals.Text {
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) { if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) {
textRenderTextureFormat = RenderTextureFormat.ARGB32; // DirectX is dumb textRenderTextureFormat = RenderTextureFormat.ARGB32; // DirectX is dumb
} }
if (!SystemInfo.SupportsTextureFormat(textTextureFormat)) { if (!SystemInfo.SupportsTextureFormat(textTextureFormat)) {
Logging.LogError($"Text texture format {textTextureFormat} not supported on this platform."); Logging.LogError($"Text texture format {textTextureFormat} not supported on this platform.");
} }
if (!SystemInfo.SupportsRenderTextureFormat(textRenderTextureFormat)) { if (!SystemInfo.SupportsRenderTextureFormat(textRenderTextureFormat)) {
Logging.LogError($"Text texture format {textRenderTextureFormat} not supported on this platform."); Logging.LogError($"Text texture format {textRenderTextureFormat} not supported on this platform.");
} }
@ -279,9 +281,24 @@ namespace ConformalDecals.Text {
// CLEAR SUBMESHES // CLEAR SUBMESHES
for (int i = 0; i < transform.childCount; i++) { for (int i = 0; i < transform.childCount; i++) {
Destroy(transform.GetChild(i).gameObject); var child = transform.GetChild(i);
var renderer = child.GetComponent<MeshRenderer>();
var filter = child.GetComponent<MeshFilter>();
if (filter == null || renderer == null) {
Logging.Log("TMP Sub object has no filter or renderer, destroying");
Destroy(child.gameObject);
}
if (filter.mesh.vertexCount < 3) {
Logging.Log("TMP Sub object has no mesh, destroying");
Destroy(child.gameObject);
} }
renderer.enabled = false;
}
_tmp.ClearMesh(true);
return new TextRenderOutput(texture, window); return new TextRenderOutput(texture, window);
} }
} }

@ -1,3 +1,8 @@
v0.2.3
------
- Fixes:
- Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations.
v0.2.2 v0.2.2
------ ------
- Fixes: - Fixes:

Loading…
Cancel
Save