Mismatch Detection & Custom Handler
Wiener automatically detects inconsistencies between Static Game Data and source definitions, and lets you control the response with custom handlers.
When Detection Occurs
1. At Load Time (second argument of LoadBasicPackFromHash)
Pass an Action<string[]> delegate as the second argument to LoadBasicPackFromHash. When a mismatch is found during loading, the delegate receives an array of class names that had inconsistencies.
WienerManager.LoadBasicPackFromHash(path, (missingTargets) => {
// missingTargets: array of class names with mismatches
foreach (var target in missingTargets)
{
Debug.LogWarning($"Mismatch: {target}");
}
});
Loading still succeeds even when mismatches are found. Fields that exist in source but not in the binary are filled with default values.
2. On Property Access (SetMissingDelegate)
Register a delegate with SetMissingDelegate to detect when a property of a class that failed to load is accessed at runtime.
Full Usage Example
var wm = new WienerManager();
wm.LoadBasicPackFromHash(path, (missingTargets) =>
{
// At load time: receives an array of class names where mismatches were found
foreach (var target in missingTargets)
{
Debug.LogWarning($"Mismatch: {target}");
}
});
wm.SetMissingDelegate((className) =>
{
// On property access: receives the class name of the master that was accessed but not properly loaded
Debug.LogError($"Access to unloaded master: {className}");
});
// If Name could not be loaded due to a mismatch, the SetMissingDelegate callback fires here
var name = wm.Item[0].Name;
Production vs. Development Mode
Production (LoadBasicPack) | Development (LoadBasicPackFromHash) | |
|---|---|---|
| On mismatch | Immediate error (safe stop) | Notifies mismatch class list via 2nd argument delegate |
| Missing fields | Load fails | Filled with default values; continues |
| Property access detection | — | Available via SetMissingDelegate |
| Use case | Release builds | Development, CI, debugging |
Usage Scenarios
| Environment | What to do |
|---|---|
| Development | Log with onMissingTargets, show Editor dialog via SetMissingDelegate |
| CI | Treat as build error if onMissingTargets array is non-empty |
| Team notification | Send onMissingTargets contents to Slack / Discord webhook |
CSV Export
WriteCSV retrieves the internally held data as header-included CSV strings.
The return value is Dictionary<string, string> (Key: file name, Value: CSV content).
var csvs = WienerManager.WriteCSV();
foreach (var csv in csvs)
{
File.WriteAllText(csv.Key, csv.Value);
}
Use cases
- Inspecting binary contents
- Aggregating data with other tools or scripts
- Taking diffs between data versions (e.g., git diff)
- Sending Static Game Data contents to Slack from an in-app debug command during development
Related
- Obfuscation — combining with tamper detection
- Version Management — excluding dev data from production
- C# API Reference