@@ -110,6 +110,7 @@ internal sealed class DevConsoleMono : MonoBehaviour
110110 private const string PrefStats = "DevConsole.stats" ;
111111 private const string PrefHiddenStats = "DevConsole.hiddenStats" ;
112112 private const string PrefStatsFontSize = "DevConsole.statsFontSize" ;
113+ private const string PrefPersistStats = "DevConsole.persistStats" ;
113114
114115 #endregion
115116
@@ -408,9 +409,10 @@ internal sealed class DevConsoleMono : MonoBehaviour
408409
409410 private bool _isDisplayingStats ;
410411 private GUIStyle _statStyle ;
411- private Dictionary < string , StatBase > _stats = new Dictionary < string , StatBase > ( ) ;
412+ private readonly Dictionary < string , StatBase > _stats = new Dictionary < string , StatBase > ( ) ;
412413 private HashSet < string > _hiddenStats = new HashSet < string > ( ) ;
413- private Dictionary < string , object > _cachedStats = new Dictionary < string , object > ( ) ;
414+ private readonly Dictionary < string , object > _cachedStats = new Dictionary < string , object > ( ) ;
415+ private List < string > _persistStats = new List < string > ( ) ;
414416 private float _statUpdateTime ;
415417 private int _statFontSize = StatDefaultFontSize ;
416418 private int _oldStatFontSize = StatDefaultFontSize ;
@@ -1166,6 +1168,7 @@ private void Awake()
11661168 InitBuiltInParsers ( ) ;
11671169 InitAttributes ( ) ;
11681170 InitMonoEvaluator ( ) ;
1171+ _persistStats . Clear ( ) ;
11691172
11701173 // Enable the console by default if in editor or a development build
11711174 if ( Debug . isDebugBuild )
@@ -2925,7 +2928,7 @@ private void InitAttributes()
29252928
29262929 string name = attribute . Name ?? field . Name ;
29272930 _stats [ name ] = new ReflectedStat ( field ) ;
2928- if ( ! attribute . StartEnabled )
2931+ if ( ! attribute . StartEnabled && ! _persistStats . Contains ( name ) )
29292932 {
29302933 _hiddenStats . Add ( name ) ;
29312934 }
@@ -2941,7 +2944,7 @@ private void InitAttributes()
29412944
29422945 string name = attribute . Name ?? property . Name ;
29432946 _stats [ name ] = new ReflectedStat ( property ) ;
2944- if ( ! attribute . StartEnabled )
2947+ if ( ! attribute . StartEnabled && ! _persistStats . Contains ( name ) )
29452948 {
29462949 _hiddenStats . Add ( name ) ;
29472950 }
@@ -3501,6 +3504,7 @@ private void SavePreferences()
35013504 DevConsoleData . SetObject ( PrefStats , _stats . Where ( x => x . Value is EvaluatedStat ) . ToDictionary ( x => x . Key , x => ( ( EvaluatedStat ) x . Value ) . Expression ) ) ;
35023505 DevConsoleData . SetObject ( PrefHiddenStats , new HashSet < string > ( _hiddenStats . Where ( x => _stats . Keys . Contains ( x ) ) ) ) ;
35033506 DevConsoleData . SetObject ( PrefStatsFontSize , _statFontSize ) ;
3507+ DevConsoleData . SetObject ( PrefPersistStats , _stats . Where ( x => ! ( x . Value is EvaluatedStat ) && ! _hiddenStats . Contains ( x . Key ) ) . Select ( x => x . Key ) . ToList ( ) ) ;
35043508
35053509 DevConsoleData . Save ( ) ;
35063510 }
@@ -3531,6 +3535,7 @@ private void LoadPreferences()
35313535 }
35323536 _hiddenStats = DevConsoleData . GetObject ( PrefHiddenStats , new HashSet < string > ( ) ) ;
35333537 _statFontSize = _oldStatFontSize = DevConsoleData . GetObject ( PrefStatsFontSize , StatDefaultFontSize ) ;
3538+ _persistStats = DevConsoleData . GetObject ( PrefPersistStats , new List < string > ( ) ) ;
35343539
35353540 DevConsoleData . Clear ( ) ;
35363541 }
0 commit comments