File tree Expand file tree Collapse file tree 2 files changed +50
-3
lines changed
Assets/PatchKit Patcher/Scripts Expand file tree Collapse file tree 2 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 22using UnityEngine . UI ;
33using UniRx ;
44using PatchKit . Unity . Patcher . Debug ;
5+ using PatchKit . Unity . Patcher . AppData . Local ;
56
67namespace PatchKit . Unity
78{
89 public class GameTitle : MonoBehaviour
910 {
1011 public Text Text ;
1112
13+ private bool _hasBeenSet ;
14+
1215 private void Start ( )
1316 {
1417 var patcher = Patcher . Patcher . Instance ;
1518
1619 Assert . IsNotNull ( patcher ) ;
1720 Assert . IsNotNull ( Text ) ;
1821
22+ patcher . Data
23+ . ObserveOnMainThread ( )
24+ . SkipWhile ( data => string . IsNullOrEmpty ( data . AppSecret ) )
25+ . Select ( x => x . AppSecret )
26+ . First ( )
27+ . Subscribe ( UseCachedText )
28+ . AddTo ( this ) ;
29+
1930 patcher . AppInfo
2031 . ObserveOnMainThread ( )
21- . Select ( app => app . DisplayName )
22- . Where ( s => ! string . IsNullOrEmpty ( s ) )
23- . SubscribeToText ( Text )
32+ . Where ( x => ! string . IsNullOrEmpty ( x . DisplayName ) )
33+ . Subscribe ( SetAndCacheText )
2434 . AddTo ( this ) ;
2535 }
36+
37+ private void UseCachedText ( string appSecret )
38+ {
39+ if ( _hasBeenSet )
40+ {
41+ return ;
42+ }
43+
44+ var cachedDisplayName = GetCache ( appSecret )
45+ . GetValue ( "app-display-name" , null ) ;
46+
47+ if ( string . IsNullOrEmpty ( cachedDisplayName ) )
48+ {
49+ return ;
50+ }
51+
52+ Text . text = cachedDisplayName ;
53+ }
54+
55+ private void SetAndCacheText ( PatchKit . Api . Models . Main . App app )
56+ {
57+ string displayName = app . DisplayName ;
58+
59+ GetCache ( app . Secret ) . SetValue ( "app-display-name" , displayName ) ;
60+ Text . text = displayName ;
61+
62+ _hasBeenSet = true ;
63+ }
64+
65+ private ICache GetCache ( string appSecret )
66+ {
67+ return new UnityCache ( appSecret ) ;
68+ }
2669 }
2770}
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
55and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
66
7+ ## [ 3.x.x.x]
8+ ### Added
9+ - Caching application display name so it can be displayed in offline mode (#1350 )
10+
711## [ 3.14.0.0]
812### Added
913- Automated scripting runtime changing to .NET 3.5 on Unity 2017 or newer (#1241 )
You can’t perform that action at this time.
0 commit comments