Reference CultCache from the Studio at compile time; add drawers
Cut 6. CultCache Studio 1.0.0 -> 1.1.0. Deleted: the CultCacheBridge string-reflection bridge (type lookups by name, GetMethod/GetProperty invocation, PullOnOpen, FlushAsync(bool)), its DescriptorInfo/CatalogMemberInfo/RecordInfo shadows, and the disabled-text-field fallback in DrawValue. The window calls CultCacheMessagePack.Create, UpsertAsync(Type, object, key), Remove, FlushAsync, IsDirty, Registry.AllDescriptors, AllStoredDocuments and BackingStores directly through GameCult.CultLib. Window: single-file and directory stores, optional read-only open with edits disabled and the reason shown, document types from the registry, records by [CultName] with key fallback including subclasses, Add, Duplicate (MessagePack round trip), Delete, immediate upsert on edit, Save = flush, Dirty indicator. An absent [CultGlobal] shows as absent with an explicit Create; nothing is invented. Opening and closing never writes. Drawers (new CultCacheStudioDrawers.cs): dictionaries with recursive keys and values, abstract/interface members through their MessagePack [Union] declarations only, CultRecordRef<T> record picker plus raw key, CultMath float2/3/4, double2/3, int2, bool2, quaternion, rect, Color32, enums including flags, lists and arrays with add/remove, nested keyed types, a red error row for unclaimed types, and the [CultInspectorDrawer(typeof(T))] extension point discovered through TypeCache (ICultInspectorDrawer). Existing inspector attributes keep working. package.json depends on org.gamecult.cultlib 1.0.57 (Cut 7) and org.gamecult.cultmath 0.1.2. No Unity.Mathematics reference. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
47c7111897
commit
8be174b82c
8 changed files with 766 additions and 734 deletions
|
|
@ -1,35 +1,77 @@
|
|||
# GameCult CultCache Unity Tools
|
||||
|
||||
`org.gamecult.caching.unity` provides Unity editor tooling for opening,
|
||||
inspecting, editing, and saving CultCache `.cc` stores.
|
||||
`org.gamecult.caching.unity` is the Unity editor surface over CultCache: open a
|
||||
store, browse its documents, edit them, save.
|
||||
|
||||
The package is intentionally a Unity editor surface over `GameCult.Caching`.
|
||||
CultCache owns document identity, schema descriptors, persistence, dirty state,
|
||||
and flush behavior. The editor window owns selection, presentation, and edit
|
||||
commands.
|
||||
CultCache owns document identity, schema descriptors, persistence, dirty state
|
||||
and flush. The Studio window owns selection, presentation and edit commands. It
|
||||
references `GameCult.Caching` and `GameCult.Caching.MessagePack` at compile time
|
||||
through the `org.gamecult.cultlib` package (assembly `GameCult.CultLib`) and
|
||||
`CultMath` through `org.gamecult.cultmath`.
|
||||
|
||||
## Use
|
||||
|
||||
1. Reference `GameCult.Caching`, `GameCult.Caching.MessagePack`, and this UPM
|
||||
package from the Unity project that declares your `[CultDocument]` classes.
|
||||
2. Open Unity's `GameCult/CultCache Studio` menu.
|
||||
3. Open or create a `.cc` file.
|
||||
4. Select a document type, select a record, edit fields, then save explicitly.
|
||||
1. Add this package; it depends on `org.gamecult.cultlib` and
|
||||
`org.gamecult.cultmath`.
|
||||
2. Open `GameCult/CultCache Studio`.
|
||||
3. `Open` a `.cc` store or make one with `New`. `Directory` opens or creates a
|
||||
directory store (a manifest beside its `.records` folder; an existing one is
|
||||
detected without the toggle). `Read Only` opens the store read-only.
|
||||
4. Pick a document type, then a record. Edits upsert into the cache as you make
|
||||
them; the toolbar shows `Dirty` until `Save` flushes the store.
|
||||
|
||||
The editor discovers registered CultCache document descriptors from the same
|
||||
registry used by runtime code. It does not require document classes to inherit
|
||||
from Unity types or storage base classes.
|
||||
Document types come from the cache's `CultDocumentRegistry`. A type lists its
|
||||
own records and those of its subclasses, by `[CultName]` with the key as
|
||||
fallback. `Add`, `Duplicate` and `Delete` act on the selected type and record.
|
||||
A `[CultGlobal]` type with no record shows as absent with a `Create` action; the
|
||||
Studio never creates one on its own.
|
||||
|
||||
Opening a store never writes it. Closing or reloading scripts drops unsaved
|
||||
edits.
|
||||
|
||||
## Drawers
|
||||
|
||||
Built in: strings, integers, floats, bools, enums (flags included), the CultMath
|
||||
values (`float2/3/4`, `double2/3`, `int2`, `bool2`, `quaternion`, `rect`,
|
||||
`Color32`), `Vector2/3`, `Color`, Unity object
|
||||
references, lists and arrays, dictionaries (keys and values drawn recursively),
|
||||
`CultRecordRef<T>` (a picker of records assignable to `T`, plus the raw key),
|
||||
abstract and interface members (a subtype picker limited to the member type's
|
||||
MessagePack `[Union]` declarations), and nested `[MessagePackObject]` types by
|
||||
their `[Key]` members. A member no drawer claims shows a red error row.
|
||||
|
||||
A project adds or overrides a drawer with an editor class:
|
||||
|
||||
```csharp
|
||||
using System.Reflection;
|
||||
using GameCult.Unity.Caching;
|
||||
using GameCult.Unity.Caching.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CultInspectorDrawer(typeof(CultMath.float3))]
|
||||
public sealed class Float3ColorDrawer : ICultInspectorDrawer
|
||||
{
|
||||
public object Draw(string label, object value, MemberInfo member)
|
||||
{
|
||||
var v = (CultMath.float3)value;
|
||||
var c = EditorGUILayout.ColorField(label, new Color(v.x, v.y, v.z));
|
||||
return new CultMath.float3(c.r, c.g, c.b);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`MemberType` may be an open generic definition to claim every closed form. A
|
||||
project drawer wins over the built-in one for its type.
|
||||
|
||||
## Inspector Annotations
|
||||
|
||||
Domain classes can opt into nicer Unity editor rendering with attributes from
|
||||
`GameCult.Unity.Caching`:
|
||||
|
||||
```csharp
|
||||
using GameCult.Caching;
|
||||
using GameCult.Unity.Caching;
|
||||
using MessagePack;
|
||||
|
||||
[MessagePackObject]
|
||||
[CultDocument("game.item", "game.item.v1")]
|
||||
public sealed class ItemData
|
||||
{
|
||||
|
|
@ -52,8 +94,6 @@ public sealed class ItemData
|
|||
}
|
||||
```
|
||||
|
||||
Available annotations:
|
||||
|
||||
- `CultInspectorLabel`
|
||||
- `CultInspectorHidden`
|
||||
- `CultInspectorReadOnly`
|
||||
|
|
@ -61,13 +101,7 @@ Available annotations:
|
|||
- `CultInspectorTextArea`
|
||||
- `CultInspectorRange`
|
||||
- `CultInspectorAssetPath`
|
||||
|
||||
## Current Scope
|
||||
|
||||
The first studio pass supports local `.cc` files, explicit save/reload, adding
|
||||
records with parameterless constructors, deleting records, primitive fields,
|
||||
enums, strings, lists/arrays, nested objects, Unity object references, asset
|
||||
path pickers, and `CultRecordRef<T>` key editing.
|
||||
- `CultInspectorDrawer` (on drawer classes)
|
||||
|
||||
CultMesh collaboration should feed the same CultCache mutation surface rather
|
||||
than becoming a second owner for document state.
|
||||
|
|
|
|||
Loading…
Reference in a new issue