Mismatch Detection & Custom Handler
Wiener automatically detects inconsistencies between Static Game Data and source definitions, and lets you control the response with custom handlers.
Detection Scope in Unity Asset Version 1.0.0
This page describes structural mismatch detection between generated binary data and C# source definitions in the currently sold Unity Asset version 1.0.0. The Standalone version and UE5 output are Coming Soon and are outside the current feature scope described here.
The hash comparison in LoadBasicPackFromHash and checksums used by related features detect differences from expected generated artifacts, file corruption, or unintended changes.
Security Boundary
A hash or checksum alone does not establish cryptographic authenticity. It is not a digital signature and does not guarantee prevention of attacker-controlled modification. If an attacker can change both the data and its verification value, they may be able to make modified data pass validation.
Do not load an untrusted file solely because its checksum passes. When a distribution channel requires authenticity, design digital signatures, authenticated encryption, and secure key management in the consuming project.
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 | Returns an error | 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
- Lightweight Obfuscation & Change Detection — checksum purpose and security boundaries
- Version Management — excluding dev data from production
- C# API Reference