diff --git a/Assets/Scripts/ElectronicFish/WelcomeManager.cs b/Assets/Scripts/ElectronicFish/WelcomeManager.cs index 8b0c291..4a44d2d 100644 --- a/Assets/Scripts/ElectronicFish/WelcomeManager.cs +++ b/Assets/Scripts/ElectronicFish/WelcomeManager.cs @@ -1,8 +1,7 @@ +using ElectronicFish.utils; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; -using GooglePlayGames; -using GooglePlayGames.BasicApi; namespace ElectronicFish { @@ -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; @@ -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 = "排行榜 (无法使用)"; + }; + Social.localUser.Authenticate(ProcessAuthentication); + _tryAgain = false; } private static void ShowLeaderboard() diff --git a/Assets/Scripts/ElectronicFish/utils.meta b/Assets/Scripts/ElectronicFish/utils.meta new file mode 100644 index 0000000..f5ffc6a --- /dev/null +++ b/Assets/Scripts/ElectronicFish/utils.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 259cb0832c2e4f36b39709d04a79bf2a +timeCreated: 1675599544 \ No newline at end of file diff --git a/Assets/Scripts/ElectronicFish/utils/Android.cs b/Assets/Scripts/ElectronicFish/utils/Android.cs new file mode 100644 index 0000000..da179ca --- /dev/null +++ b/Assets/Scripts/ElectronicFish/utils/Android.cs @@ -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("currentActivity"); + + if (unityActivity == null) return; + var toastClass = new AndroidJavaClass("android.widget.Toast"); + unityActivity.Call("runOnUiThread", new AndroidJavaRunnable(() => + { + var toastObject = toastClass.CallStatic("makeText", unityActivity, message, 0); + toastObject.Call("show"); + })); + } + } +} diff --git a/Assets/Scripts/ElectronicFish/utils/Android.cs.meta b/Assets/Scripts/ElectronicFish/utils/Android.cs.meta new file mode 100644 index 0000000..9a3c18d --- /dev/null +++ b/Assets/Scripts/ElectronicFish/utils/Android.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a9c813feb84b4027bd68596022ed4459 +timeCreated: 1675599548 \ No newline at end of file diff --git a/Assets/StreamingAssets.meta b/Assets/StreamingAssets.meta new file mode 100644 index 0000000..bacad0d --- /dev/null +++ b/Assets/StreamingAssets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94cc62726658943d095be5e7e3f60a71 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets/UnityServicesProjectConfiguration.json b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json new file mode 100644 index 0000000..1303543 --- /dev/null +++ b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json @@ -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}]} \ No newline at end of file diff --git a/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta new file mode 100644 index 0000000..4336657 --- /dev/null +++ b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 70da5f60a0a78099e8ca3721128eeb60 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 4619383..774e71e 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -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} @@ -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 @@ -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 @@ -162,7 +162,7 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 1104 + x: 1103 y: 0 width: 207 height: 934 @@ -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} @@ -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} @@ -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} @@ -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} @@ -326,7 +326,7 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1104 + x: 1103 y: 126 width: 205 height: 913 @@ -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: @@ -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: @@ -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: @@ -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: @@ -566,7 +566,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 126 - width: 1103 + width: 1102 height: 458 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -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 @@ -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 @@ -893,7 +893,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 605 - width: 1103 + width: 1102 height: 434 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -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