JSON backing store, I/O fixes, Networking Security

Introduced Newtonsoft.Json-backed persistence.
Improved backing-store reliability and serialization across the caching stack.
Improved networking security posture.

Key changes:
- Add new GameCult.Caching.NewtonsoftJson project with SingleFile/MultiFile backing stores and polymorphic known-type envelopes.
- Add MessagePack helper serialization (DatabaseEntrySerialization) and update MessagePack backing stores to use the shared options/resolver; add DatabaseLink formatter and generator/analyzer docs.
- Update CultLib.sln to include the new projects and new caching tests project.
- Improve CultCache persistence behavior: track pending store operations, wait for operations on PullAll, and centralize async push handling with error logging.
- Harden file I/O in multi-file/single-file stores: atomic temp-file writes, safe Replace/Move semantics, rename-safe deletes, and improved file-watcher subscription and debounce disposal.
- Add README files and documentation for several subprojects and packaging projects.

These changes add JSON persistence support, improve serialization consistency, and make on-disk operations more robust and observable.
This commit is contained in:
Meta Vens 2026-04-18 13:01:24 +01:00
commit 0bfc85a4f2
50 changed files with 3957 additions and 325 deletions

View file

@ -144,14 +144,14 @@ Light:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 11
serializedVersion: 13
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_CookieSize2D: {x: 10, y: 10}
m_Shadows:
m_Type: 2
m_Resolution: -1
@ -196,7 +196,7 @@ Light:
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ForceVisible: 0
m_ShadowRadius: 0
m_ShapeRadius: 0
m_ShadowAngle: 0
m_LightUnit: 1
m_LuxAtDistance: 1
@ -1087,6 +1087,7 @@ Canvas:
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 1
m_UseReflectionProbes: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
@ -1169,6 +1170,7 @@ MonoBehaviour:
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: -10
m_lineSpacingMax: 0

View file

@ -6,16 +6,6 @@ public class InspectableAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]
public abstract class PreferredInspectorAttribute : InspectableAttribute { }
public class InspectableEnumValuesAttribute : PreferredInspectorAttribute
{
public Type EnumType;
public InspectableEnumValuesAttribute(Type enumType)
{
EnumType = enumType;
}
}
public class InspectableRangedFloatAttribute : PreferredInspectorAttribute
{
public readonly float Min, Max;
@ -36,4 +26,4 @@ public class InspectableRangedIntAttribute : PreferredInspectorAttribute
Min = min;
Max = max;
}
}
}

View file

@ -6,40 +6,61 @@ namespace GameCult.Unity.UI
public class InspectableAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public abstract class PreferredInspectorAttribute : InspectableAttribute { }
public abstract class PreferredInspectorAttribute : InspectableAttribute
{
public bool ReadOnly { get; }
protected PreferredInspectorAttribute(bool readOnly = false)
{
ReadOnly = readOnly;
}
public abstract PreferredInspectorAttribute AsReadOnly();
}
public class InspectableReadOnlyLabelAttribute : PreferredInspectorAttribute { }
public class InspectableReadOnlyLabelAttribute : PreferredInspectorAttribute
{
public InspectableReadOnlyLabelAttribute() : base(true) { }
public override PreferredInspectorAttribute AsReadOnly() => this;
}
public class InspectableRangedFloatAttribute : PreferredInspectorAttribute
{
public readonly float Min, Max;
public InspectableRangedFloatAttribute(float min, float max)
public InspectableRangedFloatAttribute(float min, float max, bool readOnly = false) : base(readOnly)
{
Min = min;
Max = max;
}
public override PreferredInspectorAttribute AsReadOnly() => new InspectableRangedFloatAttribute(Min, Max, true);
}
public class InspectableRangedIntAttribute : PreferredInspectorAttribute
{
public readonly int Min, Max;
public InspectableRangedIntAttribute(int min, int max)
public InspectableRangedIntAttribute(int min, int max, bool readOnly = false) : base(readOnly)
{
Min = min;
Max = max;
}
public override PreferredInspectorAttribute AsReadOnly() => new InspectableRangedIntAttribute(Min, Max, true);
}
public class InspectableIncrementIntAttribute : PreferredInspectorAttribute
{
public readonly int Min, Max;
public InspectableIncrementIntAttribute(int min, int max)
public InspectableIncrementIntAttribute(int min, int max, bool readOnly = false) : base(readOnly)
{
Min = min;
Max = max;
}
public override PreferredInspectorAttribute AsReadOnly() => new InspectableIncrementIntAttribute(Min, Max, true);
}
}
}

View file

@ -154,7 +154,7 @@ namespace GameCult.Unity.UI.Components
context.Refresh += () =>
{
var val = read();
if (float.TryParse(inputField.text, out var existing) && Mathf.Abs(existing-val) < .001)
if (!float.TryParse(inputField.text, out var existing) || Mathf.Abs(existing - val) > .001f)
inputField.text = val.ToString("0.###");
};
@ -215,4 +215,4 @@ namespace GameCult.Unity.UI.Components
string? prefabName = null) =>
context.Resolver.Resolve<InputField>(prefabName)?.Configure(context, read, write);
}
}
}

View file

@ -0,0 +1,150 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace GameCult.Unity.UI.Components
{
public class ProgressField : LayoutComponent, IFieldHandler
{
[SerializeField] private Slider? slider;
public int Priority => 100;
public bool CanHandle(Type type, PreferredInspectorAttribute? attr) =>
(type == typeof(float) && attr is InspectableRangedFloatAttribute { ReadOnly: true }) ||
(type == typeof(int) && attr is InspectableRangedIntAttribute { ReadOnly: true });
public void ConfigureForMember(IUIContext context, object target, System.Reflection.MemberInfo member, DisplayOptions? displayOptions = null)
{
if (member is System.Reflection.FieldInfo field)
{
if (field.FieldType == typeof(float))
{
var range = field.GetCustomAttributes(typeof(InspectableRangedFloatAttribute), false);
if (range.Length > 0)
{
var attr = (InspectableRangedFloatAttribute)range[0];
Configure(context, () => (float)field.GetValue(target), attr.Min, attr.Max, displayOptions);
}
}
else if (field.FieldType == typeof(int))
{
var range = field.GetCustomAttributes(typeof(InspectableRangedIntAttribute), false);
if (range.Length > 0)
{
var attr = (InspectableRangedIntAttribute)range[0];
Configure(context, () => (int)field.GetValue(target), attr.Min, attr.Max, displayOptions);
}
}
}
else if (member is System.Reflection.PropertyInfo property)
{
if (property.PropertyType == typeof(float))
{
var range = property.GetCustomAttributes(typeof(InspectableRangedFloatAttribute), false);
if (range.Length > 0)
{
var attr = (InspectableRangedFloatAttribute)range[0];
Configure(context, () => (float)property.GetValue(target), attr.Min, attr.Max, displayOptions);
}
}
else if (property.PropertyType == typeof(int))
{
var range = property.GetCustomAttributes(typeof(InspectableRangedIntAttribute), false);
if (range.Length > 0)
{
var attr = (InspectableRangedIntAttribute)range[0];
Configure(context, () => (int)property.GetValue(target), attr.Min, attr.Max, displayOptions);
}
}
}
}
public ProgressField Configure(IUIContext context,
Func<float> read,
float min = 0,
float max = 1,
DisplayOptions? displayOptions = null)
{
if (displayOptions is not { PlaceInContext: true })
transform.SetParent(context.ContentRoot, false);
context.Register(gameObject);
if (slider is null) return this;
slider.wholeNumbers = false;
slider.minValue = min;
slider.maxValue = max;
slider.interactable = false;
slider.value = read();
context.Refresh += () => slider.value = read();
this.ApplyLayoutOptions(displayOptions);
return this;
}
public ProgressField Configure(IUIContext context,
Func<int> read,
int min = 0,
int max = 1,
DisplayOptions? displayOptions = null)
{
if (displayOptions is not { PlaceInContext: true })
transform.SetParent(context.ContentRoot, false);
context.Register(gameObject);
if (slider is null) return this;
slider.wholeNumbers = true;
slider.minValue = min;
slider.maxValue = max;
slider.interactable = false;
slider.value = read();
context.Refresh += () => slider.value = read();
this.ApplyLayoutOptions(displayOptions);
return this;
}
}
public static class ProgressFieldGeneratorExtensions
{
public static void AddProgressInspector(this IUIContext context,
string label,
Func<float> read,
float min = 0,
float max = 1,
DisplayOptions? displayOptions = null,
string? prefabName = "Progress") =>
context.Resolver.Resolve<HorizontalGroup>()?.Configure(context,
context.Resolver.Resolve<Label>()?.Configure(context, label),
context.Resolver.Resolve<ProgressField>(prefabName)?.Configure(context, read, min, max, displayOptions));
public static void AddProgressInspector(this IUIContext context,
string label,
Func<int> read,
int min = 0,
int max = 1,
DisplayOptions? displayOptions = null,
string? prefabName = "Progress") =>
context.Resolver.Resolve<HorizontalGroup>()?.Configure(context,
context.Resolver.Resolve<Label>()?.Configure(context, label),
context.Resolver.Resolve<ProgressField>(prefabName)?.Configure(context, read, min, max, displayOptions));
public static void AddProgressField(this IUIContext context,
Func<float> read,
float min = 0,
float max = 1,
DisplayOptions? displayOptions = null,
string? prefabName = "Progress") =>
context.Resolver.Resolve<ProgressField>(prefabName)?.Configure(context, read, min, max, displayOptions);
public static void AddProgressField(this IUIContext context,
Func<int> read,
int min = 0,
int max = 1,
DisplayOptions? displayOptions = null,
string? prefabName = "Progress") =>
context.Resolver.Resolve<ProgressField>(prefabName)?.Configure(context, read, min, max, displayOptions);
}
}

View file

@ -17,8 +17,8 @@ namespace GameCult.Unity.UI.Components
public int Priority => 100;
public bool CanHandle(Type type, PreferredInspectorAttribute? attr) =>
(type == typeof(float) && attr is InspectableRangedFloatAttribute) ||
(type == typeof(int) && attr is InspectableRangedIntAttribute);
(type == typeof(float) && attr is InspectableRangedFloatAttribute { ReadOnly: false }) ||
(type == typeof(int) && attr is InspectableRangedIntAttribute { ReadOnly: false });
public void ConfigureForMember(IUIContext context, object target, MemberInfo member, DisplayOptions? displayOptions = null)
{
@ -93,7 +93,6 @@ namespace GameCult.Unity.UI.Components
return this;
}
public SliderField Configure(IUIContext context, Func<int> read, Action<int> write, int min, int max, DisplayOptions? displayOptions = null)
{
if(displayOptions is not { PlaceInContext: true })
@ -155,5 +154,6 @@ namespace GameCult.Unity.UI.Components
DisplayOptions? displayOptions = null,
string? prefabName = null) =>
context.Resolver.Resolve<SliderField>(prefabName)?.Configure(context, read, write, min, max, displayOptions);
}
}
}

View file

@ -30,3 +30,5 @@ MonoBehaviour:
- {fileID: 250733312254258763, guid: 60d88f7843b61904fb9a4fff0186d674, type: 3}
- {fileID: 6714342674142997196, guid: 7d1e00d21aea76841b3315773e2d3628, type: 3}
- {fileID: 8778816924239424740, guid: 9ac2b6d69983d2045baa2ed4e35582f4, type: 3}
- {fileID: 3811655469822244809, guid: f2fc90ef4c27407ba2445cc1f07def90, type: 3}

View file

@ -30,7 +30,7 @@ namespace GameCult.Unity.UI
public Canvas Canvas => GetComponentInParent<Canvas>();
public RectTransform CanvasRoot => (RectTransform)Canvas.transform;
public void Inspect(object obj, bool inspectableOnly = false, bool recursive = true)
public void Inspect(object obj, bool inspectableOnly = false, bool recursive = true, bool readOnly = false)
{
var members = obj.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance);
foreach (var member in members)
@ -43,13 +43,14 @@ namespace GameCult.Unity.UI
case FieldInfo field:
{
var type = field.FieldType;
var handler = Resolver.ResolveField(type, preferred);
var usedAttr = GetEffectivePreferredAttribute(preferred, type, readOnly);
var handler = Resolver.ResolveField(type, usedAttr);
// If there's a handler for this field and attribute type, use that
if (handler != null)
{
var group = Resolver.Resolve<HorizontalGroup>()?.Configure(this);
if (group == null) continue;
Resolver.Resolve<Label>()?.Configure(group, member.Name);
Resolver.Resolve<Label>()?.Configure(group, member.Name.SplitCamelCase());
handler.ConfigureForMember(group, obj, field);
}
else
@ -63,12 +64,12 @@ namespace GameCult.Unity.UI
var foldout = Resolver.Resolve<GeneratorFoldout>();
if (foldout != null)
{
foldout.Title = member.Name;
foldout.Inspect(field.GetValue(obj), inspectableOnly, recursive);
foldout.Title = member.Name.SplitCamelCase();
foldout.Inspect(field.GetValue(obj), inspectableOnly, recursive, readOnly);
}
}
// If all else fails, just display the ToString
else this.AddLabelInspector(member.Name, () => field.GetValue(obj)?.ToString() ?? "Null");
else this.AddLabelInspector(member.Name.SplitCamelCase(), () => FormatValue(field.GetValue(obj), type));
}
continue;
}
@ -76,18 +77,13 @@ namespace GameCult.Unity.UI
{
var type = property.PropertyType;
var isReadOnly = !property.CanWrite;
PreferredInspectorAttribute? usedAttr = preferred;
if (isReadOnly && preferred == null && IsDisplayablePrimitive(type))
{
usedAttr = new InspectableReadOnlyLabelAttribute();
}
var usedAttr = GetEffectivePreferredAttribute(preferred, type, readOnly || isReadOnly);
var handler = Resolver.ResolveField(type, usedAttr);
if (handler != null)
{
var group = Resolver.Resolve<HorizontalGroup>()?.Configure(this);
if (group == null) continue;
Resolver.Resolve<Label>()?.Configure(group, member.Name);
Resolver.Resolve<Label>()?.Configure(group, member.Name.SplitCamelCase());
handler.ConfigureForMember(group, obj, property);
}
else
@ -98,11 +94,11 @@ namespace GameCult.Unity.UI
var foldout = Resolver.Resolve<GeneratorFoldout>();
if (foldout != null)
{
foldout.Title = member.Name;
foldout.Inspect(property.GetValue(obj), inspectableOnly, recursive);
foldout.Title = member.Name.SplitCamelCase();
foldout.Inspect(property.GetValue(obj), inspectableOnly, recursive, readOnly || isReadOnly);
}
}
else this.AddLabelInspector(member.Name, () => property.GetValue(obj)?.ToString() ?? "Null");
else this.AddLabelInspector(member.Name.SplitCamelCase(), () => FormatValue(property.GetValue(obj), type));
}
continue;
}
@ -110,6 +106,28 @@ namespace GameCult.Unity.UI
}
}
private static PreferredInspectorAttribute? GetEffectivePreferredAttribute(PreferredInspectorAttribute? preferred, Type type, bool readOnly)
{
if (readOnly)
{
if (preferred != null) return preferred.AsReadOnly();
if (IsDisplayablePrimitive(type)) return new InspectableReadOnlyLabelAttribute();
return null;
}
return preferred;
}
private static string FormatValue(object? value, Type type)
{
if (value == null) return "Null";
if (type == typeof(float)) return ((float)value).ToString("0.###");
if (type == typeof(double)) return ((double)value).ToString("0.###");
if (type == typeof(decimal)) return ((decimal)value).ToString("0.###");
if (type.IsEnum) return value.ToString()?.SplitCamelCase() ?? "Null";
return value.ToString() ?? "Null";
}
private static bool IsDisplayablePrimitive(Type type)
{
return type.IsPrimitive || type == typeof(string) || type == typeof(decimal);
@ -138,4 +156,4 @@ namespace GameCult.Unity.UI
Elements.Clear();
}
}
}
}

View file

@ -138,6 +138,7 @@ namespace GameCult.Unity.UI
_nextMenu.panel.AddEnumInspector("Enum", () => testEnum, e => testEnum = e);
var testFlags = AnimalTraits.HasFur;
_nextMenu.panel.AddFlagsEnumInspector("Flags", () => testFlags, f => testFlags = f);
_nextMenu.panel.AddProgressInspector("Progress", () => Mathf.PingPong(Time.time * 0.2f, 1f));
_nextMenu.panel.AddTextButton("Back",
() =>
{
@ -248,4 +249,4 @@ namespace GameCult.Unity.UI
});
}
}
}
}

View file

@ -0,0 +1,512 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &702164251974396902
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4445717086663197202}
m_Layer: 5
m_Name: Fill Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4445717086663197202
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 702164251974396902}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8051022211909145788}
m_Father: {fileID: 56337254898317991}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2106398138603144528
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9206263513462592621}
- component: {fileID: 4179748305306203749}
- component: {fileID: 6506401992227284411}
m_Layer: 5
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &9206263513462592621
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2106398138603144528}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 56337254898317991}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4179748305306203749
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2106398138603144528}
m_CullTransparentMesh: 0
--- !u!114 &6506401992227284411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2106398138603144528}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7ed12bf887e951949bd02894a21fb3ff, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2988999502710108009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 545409677249738502}
m_Layer: 5
m_Name: Handle Slide Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &545409677249738502
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2988999502710108009}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 142043936000400587}
m_Father: {fileID: 56337254898317991}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -10, y: 16}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &4001191192590482813
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8051022211909145788}
- component: {fileID: 2640905336499490197}
- component: {fileID: 7723267998676520126}
m_Layer: 5
m_Name: Fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8051022211909145788
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4001191192590482813}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4445717086663197202}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2640905336499490197
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4001191192590482813}
m_CullTransparentMesh: 0
--- !u!114 &7723267998676520126
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4001191192590482813}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0.44583336, b: 0.050000012, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7ed12bf887e951949bd02894a21fb3ff, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &4968680124705292911
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 142043936000400587}
- component: {fileID: 7907894582991311579}
- component: {fileID: 8102839323297657006}
- component: {fileID: 1114879522420959802}
m_Layer: 5
m_Name: Handle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &142043936000400587
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4968680124705292911}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.75, y: 0.75, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 545409677249738502}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 16, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7907894582991311579
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4968680124705292911}
m_CullTransparentMesh: 0
--- !u!114 &8102839323297657006
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4968680124705292911}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0.44583336, b: 0.050000012, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 84d126f984de5fd42ac66361c00f830c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &1114879522420959802
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4968680124705292911}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 86710e43de46f6f4bac7c8e50813a599, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AspectMode: 2
m_AspectRatio: 1
--- !u!1001 &2689390688280664784
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_Pivot.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3431245070033892138, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
propertyPath: m_Name
value: Progress
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
insertIndex: -1
addedObject: {fileID: 9206263513462592621}
- targetCorrespondingSourceObject: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
insertIndex: -1
addedObject: {fileID: 4445717086663197202}
- targetCorrespondingSourceObject: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
insertIndex: -1
addedObject: {fileID: 545409677249738502}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 3431245070033892138, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
insertIndex: 1
addedObject: {fileID: 5356524847211812639}
- targetCorrespondingSourceObject: {fileID: 3431245070033892138, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
insertIndex: -1
addedObject: {fileID: 3811655469822244809}
m_SourcePrefab: {fileID: 100100000, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
--- !u!224 &56337254898317991 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 2709624342289047671, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
m_PrefabInstance: {fileID: 2689390688280664784}
m_PrefabAsset: {fileID: 0}
--- !u!1 &778165760141322746 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3431245070033892138, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
m_PrefabInstance: {fileID: 2689390688280664784}
m_PrefabAsset: {fileID: 0}
--- !u!114 &5356524847211812639
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 778165760141322746}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Highlighted
m_DisabledTrigger: Disabled
m_Interactable: 0
m_TargetGraphic: {fileID: 0}
m_FillRect: {fileID: 8051022211909145788}
m_HandleRect: {fileID: 0}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0.76
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &3811655469822244809
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 778165760141322746}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b0da3e29aa64d6eb2c728e17e7036a7, type: 3}
m_Name:
m_EditorClassIdentifier: GameCult.Unity.UI::GameCult.Unity.UI.Components.ProgressField
layoutElement: {fileID: 7427040527870426657}
slider: {fileID: 5356524847211812639}
--- !u!114 &7427040527870426657 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4773961386689766641, guid: 63bce854f3934aa49b497baebb161e50, type: 3}
m_PrefabInstance: {fileID: 2689390688280664784}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 778165760141322746}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
m_Name:
m_EditorClassIdentifier:

View file

@ -0,0 +1,137 @@
# CultUI
`CultUI` is a Unity runtime UI composition and inspector framework, packaged for UPM and developed alongside a demo project that showcases its components, layout system, and reflective inspector workflow.
This repository serves two purposes:
- the source of the `org.gamecult.ui` package
- a Unity project for developing and demonstrating the package in a real scene
## Scope
CultUI is aimed at runtime, data-driven interface generation rather than hand-authoring every screen from scratch.
It is built for cases like:
- in-game settings menus
- debug and developer panels
- runtime inspectors for game objects and data models
- tools for exposing configurable values with minimal UI boilerplate
- reusable menu flows composed from prefabs and field handlers
## Features
- reflective runtime inspector generation for fields and properties
- prefab-driven resolver system for mapping value types to UI controls
- built-in field components for common input and display patterns
- foldouts and nested inspectors for structured data
- modal and color-picker style components
- reusable layout components for composing inspector rows and panels
- runtime menu composition for demos and application flows
- UPM-style package metadata and assembly definition for integration into Unity projects
## Package Layout
The package source lives under `Assets/UI`.
Key parts of the package include:
- `package.json`: package metadata for `org.gamecult.ui`
- `GameCult.Unity.UI.asmdef`: assembly definition for the runtime package
- `Generator.cs`: reflective inspector generation entry point
- `ReflectiveResolver.cs`: runtime resolver for prefab-backed field handlers and components
- `Components/`: built-in controls such as toggles, sliders, enum selectors, text input, buttons, labels, foldouts, and modal UI
- `Prefabs/`, `Resources/`, `Shaders/`: packaged assets used by the framework
## Demo Project
This repository also contains a Unity project used to develop and preview the package.
The demo project provides:
- a sample scene under `Assets/Scenes`
- package assets wired into a working Unity editor project
- demo menu flow showing how CultUI panels can be assembled at runtime
- a place to iterate on prefabs, resources, and inspector behavior without needing a separate host project
## Installation
### Local Package Development
If you are working in this repository directly:
1. Open the project in Unity `6000.4.2f1`.
2. Let Unity import packages and regenerate project files.
3. Open the demo scene in `Assets/Scenes`.
### Installing As A UPM Package
To consume CultUI from another Unity project, reference the package by local path or Git URL in your project's `manifest.json`.
Example local reference:
```json
{
"dependencies": {
"org.gamecult.ui": "file:../path-to-CultUI/Assets/UI"
}
}
```
## Usage
At a high level, CultUI works by combining:
- a `ReflectiveResolver` asset that knows which prefabs handle which value types
- reusable UI component prefabs
- a `Generator` or `GeneratorPanel` that inspects an object and emits UI rows at runtime
Typical flow:
1. Create or configure a `ReflectiveResolver`.
2. Assign field and component prefabs to the resolver.
3. Place a `Generator` or `GeneratorPanel` in your canvas hierarchy.
4. Call `Inspect(...)` on a target object or use the helper methods for explicit UI composition.
5. Refresh displayed values as your runtime state changes.
CultUI can be used both reflectively and imperatively:
- reflective mode generates inspector UI from object members
- imperative mode builds menus and panels directly through helper methods and component composition
## Included Controls
The package currently includes components for patterns such as:
- labels
- text buttons
- boolean toggles
- text input
- numeric sliders
- increment/decrement fields
- enum selection
- foldouts
- modal overlays
- color selection workflows
## Requirements
- Unity `6000.4.2f1` for this repository's demo project
- `uGUI`
- TextMeshPro
The development project also includes additional Unity packages and NuGet-managed dependencies used by the demo environment.
## Repository Structure
- `Assets/UI`: package source
- `Assets/Scenes`: demo scene content
- `Assets/Prefabs`, `Assets/Resources`, `Assets/Scripts`: demo-project support assets and scripts
- `Packages`, `ProjectSettings`: Unity project configuration for package development and demonstration
## Development Notes
- the Unity project is the development host for the package
- generated `.csproj` and solution files are editor artifacts
- package-facing code should remain centered in `Assets/UI`
- demo-only code should stay separate from reusable package code