File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ private void InitUserName()
3737 // デフォルトのユーザ名をセット
3838 PlayerPrefs . SetString ( ClientUserNameKey , DefaultUserName ) ;
3939 PlayerPrefs . Save ( ) ;
40+ _nameField . text = DefaultUserName ;
41+ }
42+ else
43+ {
44+ _nameField . text = PlayerPrefs . GetString ( ClientUserNameKey ) ;
4045 }
4146 }
4247 }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public class RankingManager : MonoBehaviour
1919 private void Start ( )
2020 {
2121 SetUniqueId ( ) ;
22+ InitUserName ( ) ;
2223 }
2324
2425 /// <summary>
@@ -35,6 +36,16 @@ public void SetUniqueId()
3536 PlayerPrefs . Save ( ) ;
3637 }
3738 }
39+
40+ private void InitUserName ( )
41+ {
42+ if ( ! PlayerPrefs . HasKey ( ClientUserNameKey ) )
43+ {
44+ // デフォルトのユーザ名をセット
45+ PlayerPrefs . SetString ( ClientUserNameKey , DefaultUserName ) ;
46+ PlayerPrefs . Save ( ) ;
47+ }
48+ }
3849
3950 /// <summary>
4051 /// 名前に変更があった場合データベースの名前も変更
@@ -68,7 +79,8 @@ public void SendRanking(int score)
6879 // 一意IDに紐づいたデータを検索
6980 NCMBQuery < NCMBObject > query = new NCMBQuery < NCMBObject > ( NCMBStorageKey ) ;
7081 string uniqueId = PlayerPrefs . GetString ( UniqueUserIdKey ) ;
71- query . WhereEqualTo ( UniqueUserIdKey , uniqueId ) ;
82+ string userName = PlayerPrefs . GetString ( ClientUserNameKey ) ;
83+ query . WhereEqualTo ( ClientUserNameKey , uniqueId ) ;
7284 query . FindAsync ( ( List < NCMBObject > objList , NCMBException e ) =>
7385 {
7486 // 取得に成功
@@ -79,6 +91,7 @@ public void SendRanking(int score)
7991 {
8092 NCMBObject obj = new NCMBObject ( NCMBStorageKey ) ;
8193 obj [ UniqueUserIdKey ] = uniqueId ;
94+ obj [ UserNameKey ] = userName ;
8295 obj [ HighScoreKey ] = score ;
8396 obj . SaveAsync ( ) ;
8497 }
You can’t perform that action at this time.
0 commit comments