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,9 +240,25 @@ namespace ConformalDecals {
base.OnDetach(); base.OnDetach();
} }
private void UpdateTextRecursive() { private IEnumerator UpdateTextLate() {
yield return null;
UpdateText(); UpdateText();
}
private void UpdateText(bool recursive = false) {
// Render text
var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing);
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;
// Update the texture with the new rendered output
UpdateTexture(output);
// If recursive, copy parameters to other parts and perform the same operation
if (recursive) {
foreach (var counterpart in part.symmetryCounterparts) { foreach (var counterpart in part.symmetryCounterparts) {
var decal = counterpart.GetComponent<ModuleConformalText>(); var decal = counterpart.GetComponent<ModuleConformalText>();
decal.text = text; decal.text = text;
@ -255,24 +271,6 @@ namespace ConformalDecals {
decal.UpdateText(); decal.UpdateText();
} }
} }
private IEnumerator UpdateTextLate() {
yield return null;
UpdateText();
}
private void UpdateText() {
// Render text
var newText = new DecalText(text, font, style, vertical, lineSpacing, charSpacing);
var output = TextRenderer.UpdateText(_currentText, newText);
_currentText = newText;
UpdateTexture(output);
// TODO: ASYNC RENDERING
// var newText = new DecalText(text, _font, _style);
// _currentJob = TextRenderer.UpdateText(_currentText, newText, UpdateTexture);
// _currentText = newText;
} }
public void UpdateTexture(TextRenderOutput output) { public void UpdateTexture(TextRenderOutput output) {

Loading…
Cancel
Save