Skip to content

Commit

Permalink
登录优化
Browse files Browse the repository at this point in the history
  • Loading branch information
purofle committed Feb 5, 2023
1 parent 0db3040 commit faeb527
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 44 deletions.
20 changes: 14 additions & 6 deletions Assets/Scripts/ElectronicFish/WelcomeManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using ElectronicFish.utils;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;

namespace ElectronicFish
{
Expand All @@ -13,6 +12,8 @@ public class WelcomeManager : MonoBehaviour
[SerializeField] private Button startGameButton;
[SerializeField] private Button leaderboardButton;

private bool _tryAgain = true;

private void Awake()
{
Application.targetFrameRate = 114514;
Expand All @@ -39,13 +40,20 @@ private static void StartGame()
SceneManager.LoadScene("Scenes/MainScene");
}

// ReSharper disable Unity.PerformanceAnalysis
private static void ProcessAuthentication(bool status)
private void ProcessAuthentication(bool status)
{
if (!status)
if (status)
{
Social.localUser.Authenticate(ProcessAuthentication);
AndroidUtils.ShowAndroidToastMessage("登录成功");
}
AndroidUtils.ShowAndroidToastMessage("登录失败");
if (!_tryAgain)
{
leaderboardButton.enabled = false;
leaderboardButton.GetComponentInChildren<Text>().text = "排行榜 (无法使用)";
};
Social.localUser.Authenticate(ProcessAuthentication);
_tryAgain = false;
}

private static void ShowLeaderboard()
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/ElectronicFish/utils.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Assets/Scripts/ElectronicFish/utils/Android.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine;

namespace ElectronicFish.utils
{
internal static class AndroidUtils
{
public static void ShowAndroidToastMessage(string message)
{
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var unityActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

if (unityActivity == null) return;
var toastClass = new AndroidJavaClass("android.widget.Toast");
unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
{
var toastObject = toastClass.CallStatic<AndroidJavaObject>("makeText", unityActivity, message, 0);
toastObject.Call("show");
}));
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/ElectronicFish/utils/Android.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/StreamingAssets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Keys":["com.unity.services.core.cloud-environment","com.unity.services.core.version"],"Values":[{"m_Value":"production","m_IsReadOnly":true},{"m_Value":"1.4.2","m_IsReadOnly":true}]}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 38 additions & 38 deletions UserSettings/Layouts/default-2021.dwlt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
width: 1920
height: 984
m_ShowMode: 4
m_Title: "\u5C42\u7EA7"
m_Title: "\u9879\u76EE"
m_RootView: {fileID: 2}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
Expand Down Expand Up @@ -100,7 +100,7 @@ MonoBehaviour:
m_MinSize: {x: 400, y: 200}
m_MaxSize: {x: 32384, y: 16192}
vertical: 0
controlID: 76
controlID: 26
--- !u!114 &5
MonoBehaviour:
m_ObjectHideFlags: 52
Expand Down Expand Up @@ -141,12 +141,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1104
width: 1103
height: 934
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 96
controlID: 71
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
Expand All @@ -162,7 +162,7 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 1104
x: 1103
y: 0
width: 207
height: 934
Expand All @@ -188,9 +188,9 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 1311
x: 1310
y: 0
width: 338
width: 339
height: 934
m_MinSize: {x: 232, y: 271}
m_MaxSize: {x: 10002, y: 10021}
Expand Down Expand Up @@ -218,8 +218,8 @@ MonoBehaviour:
y: 0
width: 271
height: 934
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 14}
m_Panes:
- {fileID: 14}
Expand All @@ -242,7 +242,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1104
width: 1103
height: 479
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
Expand All @@ -269,7 +269,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 479
width: 1104
width: 1103
height: 455
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
Expand Down Expand Up @@ -326,7 +326,7 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1104
x: 1103
y: 126
width: 205
height: 913
Expand All @@ -337,9 +337,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 10820000
m_LastClickedID: 33296
m_ExpandedIDs: eccfffffc2f2ffff22f4ffff1afbffffd4790000e4790000ee7900001c7a0000687a00008a7a0000947a0000447c0000947c0000c07c0000727e0000b47e000010820000528200009e820000
m_SelectedIDs: d4060000
m_LastClickedID: 0
m_ExpandedIDs: 1afbffff1cfbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -424,9 +424,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1311
x: 1310
y: 126
width: 336
width: 337
height: 913
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
Expand All @@ -445,36 +445,36 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Scripts/ElectronicFish/mine
- Assets/Scripts/ElectronicFish
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets/Scripts/ElectronicFish/mine
- Assets/Scripts/ElectronicFish
m_LastFoldersGridSize: -1
m_LastProjectPath: /home/purofle/projects/electronic-wooden-fish
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 207d0000
m_LastClickedID: 32032
m_ExpandedIDs: 0000000086610000886100008a6100003e6200004262000000ca9a3b
m_SelectedIDs: 2a620000
m_LastClickedID: 25130
m_ExpandedIDs: 000000006c6100006e610000706100007261000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: Scenes
m_OriginalName: Scenes
m_Name:
m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 25152
m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 8}
m_SearchString:
Expand All @@ -488,7 +488,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000086610000886100008a610000
m_ExpandedIDs: 000000006c6100006e6100007061000072610000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
Expand Down Expand Up @@ -566,7 +566,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 126
width: 1103
width: 1102
height: 458
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
Expand Down Expand Up @@ -791,9 +791,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 190.28685, y: 2133.988, z: 0.29774702}
m_Target: {x: 540, y: 1080, z: 0}
speed: 2
m_Value: {x: 192.97588, y: 2133.5547, z: 0.2439659}
m_Value: {x: 539.99976, y: 1080, z: 0.0000007682226}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
Expand Down Expand Up @@ -844,9 +844,9 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 114.13437
m_Target: 1207.4767
speed: 2
m_Value: 119.51243
m_Value: 1207.4762
m_Ortho:
m_Target: 1
speed: 2
Expand Down Expand Up @@ -893,7 +893,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 605
width: 1103
width: 1102
height: 434
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
Expand Down Expand Up @@ -943,23 +943,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 1103
width: 1102
height: 413
m_Scale: {x: 0.1912037, y: 0.1912037}
m_Translation: {x: 551.5, y: 206.5}
m_Translation: {x: 551, y: 206.5}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -2884.3584
x: -2881.7434
y: -1080
width: 5768.717
width: 5763.487
height: 2160
m_MinimalGUI: 1
m_defaultScale: 0.1912037
m_LastWindowPixelSize: {x: 1103, y: 434}
m_LastWindowPixelSize: {x: 1102, y: 434}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000001000000000000
Expand Down

0 comments on commit faeb527

Please sign in to comment.