Class CellGridPreviewWidget
Reusable editor widget for rendering a live cell grid preview in the inspector. Uses a hybrid approach: Texture2D for background colors, IMGUI labels for characters. Caches textures per owner instance ID to avoid recreating them every frame.
Inherited Members
Namespace: Scylla.TextMode.Editor
Assembly: ScyllaTextMode.Editor.dll
Syntax
[InitializeOnLoad]
public static class CellGridPreviewWidget
Remarks
Character rendering uses one rich-text GUI.Label per row for efficiency. Because character spacing is controlled by the font's glyph metrics rather than pixel-perfect cell boundaries, slight horizontal drift may occur in wide grids. This is an accepted limitation that keeps draw call count manageable.
Methods
ClearCache(EntityId)
Clears the cached preview texture for the specified owner. Call when the editor is disabled or destroyed.
Declaration
public static void ClearCache(EntityId ownerID)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityId | ownerID | Instance ID of the owning editor. |
CreateForInspector(Func<ITextModeGridProvider>, Func<bool>, EntityId)
Creates an IMGUIContainer that renders the live cell grid preview using the existing IMGUI drawing code. Suitable for embedding in UI Toolkit inspectors.
Declaration
public static IMGUIContainer CreateForInspector(Func<ITextModeGridProvider> providerGetter, Func<bool> isInitializedGetter, EntityId ownerID)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<ITextModeGridProvider> | providerGetter | Delegate that returns the current grid provider. |
| Func<bool> | isInitializedGetter | Delegate that returns whether the view is initialized. |
| EntityId | ownerID | Instance ID of the owning editor, used to cache the preview texture. |
Returns
| Type | Description |
|---|---|
| IMGUIContainer |
Draw(ITextModeGridProvider, EntityId)
Draws a live cell grid preview for the specified grid provider.
Declaration
public static void Draw(ITextModeGridProvider provider, EntityId ownerID)
Parameters
| Type | Name | Description |
|---|---|---|
| ITextModeGridProvider | provider | The grid provider to preview. |
| EntityId | ownerID | Instance ID of the owning editor, used to cache the preview texture. |