Clean up text update function

hotfix
Andrew Cassidy 2 years ago
parent ba6676b625
commit 95b99d1d42

@ -153,7 +153,7 @@ namespace ConformalDecals {
this.vertical = newVertical; this.vertical = newVertical;
this.lineSpacing = newLineSpacing; this.lineSpacing = newLineSpacing;
this.charSpacing = newCharSpacing; this.charSpacing = newCharSpacing;
UpdateTextRecursive(); UpdateText(true);
} }
public void OnFillColorUpdate(Color rgb, Util.ColorHSV hsv) { public void OnFillColorUpdate(Color rgb, Util.ColorHSV hsv) {
@ -240,39 +240,37 @@ namespace ConformalDecals {
base.OnDetach(); base.OnDetach();
} }
private void UpdateTextRecursive() {
UpdateText();
foreach (var counterpart in part.symmetryCounterparts) {
var decal = counterpart.GetComponent<ModuleConformalText>();
decal.text = text;
decal.font = font;
decal.style = style;
decal.vertical = vertical;
decal.charSpacing = charSpacing;
decal.lineSpacing = lineSpacing;
decal.UpdateText();
}
}
private IEnumerator UpdateTextLate() { private IEnumerator UpdateTextLate() {
yield return null; yield return null;
UpdateText(); UpdateText();
} }
private void UpdateText() { private void UpdateText(bool recursive = false) {
// Render text // Render text
var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing); var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing);
var output = TextRenderer.UpdateText(_currentText, newText); var output = TextRenderer.UpdateText(_currentText, newText);
// update the _currentText state variable
// this is the ONLY place this variable should be set! otherwise the current state is lost
_currentText = newText; _currentText = newText;
// Update the texture with the new rendered output
UpdateTexture(output); UpdateTexture(output);
// TODO: ASYNC RENDERING // If recursive, copy parameters to other parts and perform the same operation
// var newText = new DecalText(text, _font, _style); if (recursive) {
// _currentJob = TextRenderer.UpdateText(_currentText, newText, UpdateTexture); foreach (var counterpart in part.symmetryCounterparts) {
// _currentText = newText; var decal = counterpart.GetComponent<ModuleConformalText>();
decal.text = text;
decal.font = font;
decal.style = style;
decal.vertical = vertical;
decal.charSpacing = charSpacing;
decal.lineSpacing = lineSpacing;
decal.UpdateText();
}
}
} }
public void UpdateTexture(TextRenderOutput output) { public void UpdateTexture(TextRenderOutput output) {

Loading…
Cancel
Save