Testing and visualizing your influence formulas in real-time
Demo System Overview
The Simple Attribute Forge Ultimate includes a comprehensive demo and testing system that provides real-time visualization of attribute values, formula calculations, and system behavior. This is essential for developing, testing, and debugging your influence systems.
Required UI Elements:
1. Create UI Canvas (if not present)
2. Add TextMeshPro - Text (UI) element for attributes
3. Add TextMeshPro - Text (UI) element for formulas
4. Position elements for visibility during testing
3Configure Demo Manager
Target Object: GameObject with your attributes + orchestrator
Attributes Display: First TextMeshPro element
Formulas Display: Second TextMeshPro element
4Test the Setup
Enter Play Mode
Verify displays show current attribute values
Check that formula calculations are visible
Use context menu testing features
Demo Manager Configuration
Inspector Fields
Target References
Required Fields:
• Target Object: GameObject with attribute system and orchestrator
• Attributes Display: TextMeshPro component for attribute values
• Formulas Display: TextMeshPro component for formula breakdown
Optional Overrides:
• Attribute Source Override: Manually specify attribute component
• Orchestrator Override: Manually specify orchestrator component
Display Settings
Update Interval: How often to refresh displays (default: 0.5 seconds)
Group By Type: Organize attributes by behavior type (Vital, Basic, etc.)
Show Formula Bonuses: Include formula contributions in attribute display
Show Breakpoints: Highlight active breakpoints in formula display
Decimal Places: Precision for displayed numbers (default: 1)
Testing Configuration
Test Attribute: Name of attribute to modify (e.g., "Strength")
Test Value: Amount to change the test attribute by
Debug Mode: Enable detailed console logging
Auto-Find Components: Automatically locate attribute and orchestrator components
Display Formats
Attributes Display
Shows all attributes organized by type with real-time values:
=== ACTIVE FORMULAS ===
[ORDER 0] StrengthDamage → Damage
Result: +50
Pipeline: STR(25) × 2.0 = 50
Status: Active
[ORDER 0] LevelHealth → Health
Result: +20
Pipeline: Level(12) × 1.5 + BaseBonus(2) = 20
Status: Active
[ORDER 1] IntelligenceMana → Mana
Result: +10
Pipeline: INT(18) × 0.5 + LevelBonus(1) = 10
Breakpoint: Level ≥ 10 (+1 bonus) Active
Status: Active
Display Features
Color Coding: Health values change color based on percentage
Formula Indicators: Shows which attributes have formula bonuses
Breakpoint Status: Displays active breakpoints with checkmarks
Real-time Updates: Values update automatically as they change
Error Indicators: Shows for formula errors or missing references
Interactive Testing Features
Context Menu Commands
Right-click the SimpleInfluenceDemoManager component in Inspector to access testing tools:
Modify Test Attribute
[ContextMenu("Set Test Attribute")]
• Changes the specified test attribute to test value
• Triggers automatic recalculation
• Logs the change to console
[ContextMenu("Log All Values")]
• Prints detailed attribute breakdown to console
• Shows base, formula, modifier, and total values
• Useful for debugging and verification
Toggle Update Mode
[ContextMenu("Toggle Auto Mode")]
• Switches between Auto and Manual recalculation
• Tests different performance scenarios
• Shows current mode in console
Runtime Value Modification
// The demo manager provides methods for runtime testing:
public void ModifyAttribute(string attributeName, float newValue)
{
var attr = attributeSource.GetAttribute(attributeName);
if (attr != null)
{
attr.baseValue = newValue;
Debug.Log($"Set {attributeName} to {newValue}");
}
}
public void TestScenario(string scenarioName)
{
switch (scenarioName)
{
case "LowLevel":
SetupLowLevelCharacter();
break;
case "HighLevel":
SetupHighLevelCharacter();
break;
case "MaxStats":
SetupMaxStatsCharacter();
break;
}
orchestrator.RecalculateAll();
}
Common Testing Scenarios
Basic Formula Testing
1Verify Base Calculations
Set test attribute to known value (e.g., Strength = 20)
Check that formula result matches expected calculation
Verify display shows both base and formula bonus
2Test Value Changes
Modify attribute values using Inspector or context menu
Watch formula results update in real-time
Confirm that dependent attributes recalculate correctly
3Breakpoint Activation Testing
Set attribute values around breakpoint thresholds
Verify breakpoints activate at correct values
Check that breakpoint effects appear in formula display
Advanced Testing Scenarios
Testing Checklist:
□ Basic formula math is correct
□ Breakpoints activate at right thresholds
□ Multiple breakpoints work together
□ Execution order affects results properly
□ Circular dependencies are handled
□ Performance is acceptable with all formulas
□ UI updates reflect formula changes
□ Save/load preserves baseValue correctly
Performance Testing
Update Frequency: Test different update intervals
Formula Count: Add many formulas to test performance
Breakpoint Complexity: Test with complex breakpoint conditions
Mobile devices may struggle with frequent UI updates
Team Workflow
Designers: Use demo system to test and balance formulas
Programmers: Verify integration and performance
QA: Use predefined scenarios for regression testing
Artists: Test with realistic visual scenarios
Advanced Demo Features
Automated Testing
// Automated test suite example:
public class FormulaTestSuite : MonoBehaviour
{
[ContextMenu("Run All Tests")]
public void RunAllTests()
{
StartCoroutine(ExecuteTestSuite());
}
IEnumerator ExecuteTestSuite()
{
var testResults = new List();
// Test 1: Basic math verification
yield return StartCoroutine(TestBasicMath(testResults));
// Test 2: Breakpoint activation
yield return StartCoroutine(TestBreakpoints(testResults));
// Test 3: Performance testing
yield return StartCoroutine(TestPerformance(testResults));
// Report results
LogTestResults(testResults);
}
IEnumerator TestBasicMath(List results)
{
SetAttribute("Strength", 20);
yield return new WaitForSeconds(0.1f);
float expectedDamage = 40; // STR 20 × 2.0
float actualDamage = GetAttribute("Damage").totalValue;
bool passed = Mathf.Approximately(expectedDamage, actualDamage);
results.Add($"Basic Math Test: {(passed ? "PASS" : "FAIL")} " +
$"(Expected: {expectedDamage}, Actual: {actualDamage})");
}
}
Visual Debugging
// Visual debugging features:
public class VisualDebugger : MonoBehaviour
{
public LineRenderer dependencyLine;
public Transform[] attributeNodes;
void Update()
{
if (showDependencies)
{
DrawFormulaDependencies();
}
}
void DrawFormulaDependencies()
{
// Draw lines between attributes that have formula relationships
foreach (var formula in orchestrator.GetFormulas())
{
var sourceNode = GetNodeForAttribute(formula.sourceAttribute);
var targetNode = GetNodeForAttribute(formula.targetAttribute);
if (sourceNode && targetNode)
{
DrawLine(sourceNode.position, targetNode.position, Color.green);
}
}
}
}
Data Export
// Export test results for analysis:
[ContextMenu("Export Test Data")]
void ExportTestData()
{
var csvData = new StringBuilder();
csvData.AppendLine("Attribute,BaseValue,FormulaBonus,ModifierBonus,TotalValue");
foreach (var attr in attributeSource.GetAllAttributes())
{
csvData.AppendLine($"{attr.name},{attr.baseValue},{attr.formulaBonus}," +
$"{attr.modifierBonus},{attr.totalValue}");
}
string filePath = Path.Combine(Application.persistentDataPath,
$"AttributeData_{DateTime.Now:yyyyMMdd_HHmmss}.csv");
File.WriteAllText(filePath, csvData.ToString());
Debug.Log($"Test data exported to: {filePath}");
}
Demo System Troubleshooting
Common Issues
Display Not Updating
Check Target Object assignment
Verify TextMeshPro components are assigned
Ensure Update Interval is reasonable
Check for console errors
Values Show as Zero
Verify orchestrator is assigned and working
Check that formulas are enabled
Ensure RecalculateAll() has been called
Test with manual recalculation
Performance Issues
Increase update interval
Simplify display formatting
Reduce number of active formulas
Check for excessive debug logging
Validation Checklist
Demo System Health Check:
□ Target Object has both attributes and orchestrator
□ TextMeshPro components are assigned and active
□ Update Interval is between 0.1 and 2.0 seconds
□ No console errors or warnings
□ Formulas show expected results in display
□ Test scenarios modify values correctly
□ Performance is acceptable for your target platform