PageRenderer
A class in Root.Township, Alta.Pages.
Client: renders page glyphs into render texture materials with its own camera, caching and pooling them per PageData. A singleton; does nothing on a headless server.
- Listed in Items, inventory and logic
- Inherits or implements
MonoBehaviour - Attributes
ExecuteInEditMode
Constructors
| Member | What it is |
|---|---|
PageRenderer() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private bool btnClear | Inspector button for Clear. |
private bool btnLoad | Inspector button for LoadEditor. |
private bool btnSave | Inspector button for Save. |
private bool btnSaveAs | Inspector button for SaveAs. |
private Camera camera | Camera that renders the glyphs into page textures. |
private SerializedRenderTextureDescriptor descriptor | Render texture settings for page textures. |
private RenderTextureFormat[] fallBackFormats | Render texture formats tried in order if the set one isn't supported. |
private GlyphInstance firstGlyph | Template glyph cloned for extra glyphs. |
private List<GlyphInstance> glyphs | Glyph objects currently laid out. |
private static PageRenderer instance | The singleton. |
private bool isCalibrating | Inspector flag; not read in this file. |
private bool isFirstTexture | True until the first render, so the initial temporary target can be released. |
private Page page | Page loaded by the editor Load button. |
private Material pageMaterial | Base page material; also returned for empty pages. |
private List<Material> pool | Unused page materials ready for reuse. |
private List<PageData> poolData | Page data last rendered into each pooled material, so a match can skip re-rendering. |
private Dictionary<PageData, Material> savedPages | Materials in use, by page data. |
private Dictionary<PageData, int> useCounts | How many users each page data's material has. |
Methods
| Member | What it is |
|---|---|
void Load(PageData data) | Lays out glyph objects to match the page data, adding or hiding glyphs as needed. |
static void Release(PageData data) | Lowers the use count for page data; at zero the material goes back to the pool. |
static Material Render(PageData data) | Returns a material showing the page data, reusing a cached or pooled one, or rendering a new one. Null on headless. |
10 private and internal methods
Used in
Members of other types that take, return or hold a PageRenderer: