All Docs Documentation Version: Base (Free) Influence System Ultimate
Simple Attribute Forge Ultimate

Demo Scene Guide

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.

What the Demo System Provides:

Quick Setup Guide

1 Create Demo GameObject
2 Setup UI Canvas
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
3 Configure Demo Manager
4 Test the Setup

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:

=== CHARACTER ATTRIBUTES === VITALS Health: 85/120 (+20 formula) Mana: 45/60 (+10 formula) Stamina: 100/100 BASIC STATS Strength: 25 → 45 (+20 formula) Intelligence: 18 → 27 (+9 formula) Dexterity: 15 → 15 Constitution: 20 → 35 (+15 formula) RESOURCES Level: 12 Experience: 8500/10000 Gold: 1250 DERIVED STATS Damage: 50 (formula result) SpellPower: 13 (formula result) CritChance: 8.5% (formula result)

Formulas Display

Shows active formulas with calculation breakdown:

=== 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

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

Force Recalculation

[ContextMenu("Force Recalculate")] • Manually triggers orchestrator recalculation • Useful for testing Manual update mode • Shows recalculation timing

Dump Attribute Values

[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

1 Verify Base Calculations
2 Test Value Changes
3 Breakpoint Activation Testing

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

Debug Information Display

Console Output

// Example debug output from demo manager: === ATTRIBUTE VALUES DEBUG === Health: base=100, formula=20, modifier=0, total=120, current=85 Mana: base=50, formula=10, modifier=0, total=60, current=45 Strength: base=25, formula=0, modifier=5, total=30 Damage: base=0, formula=50, modifier=0, total=50 === FORMULA CALCULATIONS DEBUG === StrengthDamage: STR(25) × 2.0 = 50 → Damage LevelHealth: Level(12) × 1.5 + Base(2) = 20 → Health IntelligenceMana: INT(18) × 0.5 + Breakpoint(1) = 10 → Mana === PERFORMANCE DEBUG === Total formulas: 3 Recalculation time: 0.15ms Update frequency: 2.0 FPS (every 0.5s)

Error Detection

The demo system automatically detects and displays common issues:

Missing References

MISSING: Formula references "MagicPower" but attribute not found NULL: Orchestrator reference is null INVALID: Attribute "Strenght" (typo in name)

Circular Dependencies

CIRCULAR: A→B→A dependency detected CONVERGED: Loop resolved after 3 iterations MAX_ITER: Iteration limit reached, values may be unstable

Performance Warnings

SLOW: Recalculation took 5.2ms (may impact performance) FREQUENT: 15 recalculations this second COMPLEX: 8 breakpoints in single formula

Customizing the Demo System

Custom Display Formatting

// Override display methods for custom formatting: public class CustomDemoManager : SimpleInfluenceDemoManager { protected override string FormatAttributeDisplay(SimpleRuntimeAttribute attr) { // Custom formatting logic if (attr.behaviorType == SimpleBehaviorType.Vital) { // Show health bars for vitals return $"{attr.name}: {GetHealthBar(attr)} ({attr.currentValue:F0}/{attr.totalValue:F0})"; } // Custom color coding var color = attr.formulaBonus > 0 ? "green" : "white"; return $"{attr.name}: {attr.totalValue:F1}"; } string GetHealthBar(SimpleRuntimeAttribute attr) { float percentage = attr.currentValue / attr.totalValue; int bars = Mathf.RoundToInt(percentage * 10); return $"[{'█'.Repeat(bars)}{'░'.Repeat(10-bars)}]"; } }

Adding Test Scenarios

// Add predefined test scenarios: [ContextMenu("Test: Low Level Character")] void TestLowLevel() { SetAttribute("Level", 5); SetAttribute("Strength", 12); SetAttribute("Intelligence", 10); RecalculateAndLog("Low Level Test"); } [ContextMenu("Test: Boss Fight Simulation")] void TestBossFight() { SetAttribute("Health", GetAttribute("Health").totalValue * 0.2f); // Low health SetAttribute("Strength", GetAttribute("Strength").baseValue + 10); // Combat boost RecalculateAndLog("Boss Fight Simulation"); } void RecalculateAndLog(string scenario) { orchestrator.RecalculateAll(); Debug.Log($"=== {scenario} Results ==="); LogAllAttributeValues(); }

Integration with Game Systems

Mobile and Touch Testing

Touch-Friendly Testing

// Add UI buttons for mobile testing: public class MobileDemoUI : MonoBehaviour { public Button increaseStrengthButton; public Button decreaseStrengthButton; public Button testScenarioButton; public Slider attributeSlider; void Start() { increaseStrengthButton.onClick.AddListener(() => ModifyTestAttribute(+1)); decreaseStrengthButton.onClick.AddListener(() => ModifyTestAttribute(-1)); testScenarioButton.onClick.AddListener(RunTestScenario); attributeSlider.onValueChanged.AddListener(OnSliderChanged); } void OnSliderChanged(float value) { demoManager.SetTestAttributeValue(value); } }

Performance Considerations

Demo System Best Practices

Development Workflow:

Performance Guidelines

Update Interval Recommendations: • Development: 0.1-0.2 seconds (responsive) • Testing: 0.5 seconds (balanced) • Performance testing: 1.0+ seconds (minimal overhead) • Mobile: 1.0-2.0 seconds (battery friendly) Formula Count Considerations: • < 10 formulas: Any update rate acceptable • 10-25 formulas: 0.5+ second intervals recommended • 25+ formulas: Manual mode or 1.0+ second intervals • 50+ formulas: Requires performance optimization
Production Considerations:

Team Workflow

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