Text rendering job system
parent
1c776c0969
commit
42e6b18845
Binary file not shown.
@ -1,11 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Text {
|
||||
public class RenderedText : ScriptableObject {
|
||||
public class RenderedText {
|
||||
public Texture2D Texture { get; private set; }
|
||||
|
||||
public Rect Window { get; private set; }
|
||||
|
||||
public int UserCount { get; private set; }
|
||||
public int UserCount { get; set; }
|
||||
|
||||
public RenderedText(Texture2D texture, Rect window) {
|
||||
Texture = texture;
|
||||
Window = window;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace ConformalDecals.Text {
|
||||
public class TextRenderJob {
|
||||
public DecalText OldText { get; }
|
||||
public DecalText NewText { get; }
|
||||
public bool Needed { get; private set; }
|
||||
public bool IsStarted { get; private set; }
|
||||
public bool IsDone { get; private set; }
|
||||
|
||||
public readonly TextRenderer.TextRenderEvent onRenderFinished = new TextRenderer.TextRenderEvent();
|
||||
|
||||
public TextRenderJob(DecalText oldText, DecalText newText, UnityAction<RenderedText> renderFinishedCallback) {
|
||||
OldText = oldText ?? throw new ArgumentNullException(nameof(oldText));
|
||||
NewText = newText ?? throw new ArgumentNullException(nameof(newText));
|
||||
Needed = true;
|
||||
|
||||
if (renderFinishedCallback != null) onRenderFinished.AddListener(renderFinishedCallback);
|
||||
}
|
||||
|
||||
public TextRenderJob( DecalText newText, UnityAction<RenderedText> renderFinishedCallback) {
|
||||
NewText = newText ?? throw new ArgumentNullException(nameof(newText));
|
||||
Needed = true;
|
||||
|
||||
if (renderFinishedCallback != null) onRenderFinished.AddListener(renderFinishedCallback);
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
Needed = false;
|
||||
}
|
||||
|
||||
public void Start() {
|
||||
IsStarted = true;
|
||||
}
|
||||
|
||||
public void Finish(RenderedText output) {
|
||||
IsDone = true;
|
||||
onRenderFinished.Invoke(output);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue