Text rendering job system
parent
04a213a65d
commit
b1044527b9
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:0c965b683c33c4150cdb3381bcfe81a0fff643ba3e5e3207ea704b90e8885c1e
|
oid sha256:7f42421e78ddbe2af88112fa7fa254f870bda45f07a3436af64832a9646ebdef
|
||||||
size 76800
|
size 80896
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ConformalDecals.Text {
|
namespace ConformalDecals.Text {
|
||||||
public class RenderedText : ScriptableObject {
|
public class RenderedText {
|
||||||
public Texture2D Texture { get; private set; }
|
public Texture2D Texture { get; private set; }
|
||||||
|
|
||||||
public Rect Window { 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