Commit 5fce792b authored by nk161690's avatar nk161690

Logout

parent b47cfe97
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
...@@ -9,6 +9,7 @@ public class FacebookLogin : MonoBehaviour ...@@ -9,6 +9,7 @@ public class FacebookLogin : MonoBehaviour
private Log.LoginSession session = new Log.LoginSession(); private Log.LoginSession session = new Log.LoginSession();
public string Token; public string Token;
public string Error; public string Error;
private bool isQuitting = false;
private void Awake() private void Awake()
{ {
...@@ -52,12 +53,6 @@ public class FacebookLogin : MonoBehaviour ...@@ -52,12 +53,6 @@ public class FacebookLogin : MonoBehaviour
} }
} }
private void OnApplicationQuit()
{
session.LogoutTime = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm");
Log.LogLoginSession(session);
}
public void OnFacebookLoginButtonClicked() public void OnFacebookLoginButtonClicked()
{ {
var perms = new List<string>() { "public_profile", "email" }; var perms = new List<string>() { "public_profile", "email" };
...@@ -76,8 +71,7 @@ public class FacebookLogin : MonoBehaviour ...@@ -76,8 +71,7 @@ public class FacebookLogin : MonoBehaviour
OnFacebookLoggedIn(); OnFacebookLoggedIn();
// Log login session // Log login session
session.Username = AccessToken.CurrentAccessToken.UserId; UserSessionManager.LogIn(AccessToken.CurrentAccessToken.UserId);
session.LoginTime = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm");
} }
else else
{ {
......
using GooglePlayGames; using GooglePlayGames;
using GooglePlayGames.BasicApi; using GooglePlayGames.BasicApi;
using Photon.Pun;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -8,6 +9,7 @@ using UnityEngine; ...@@ -8,6 +9,7 @@ using UnityEngine;
public class GoogleLogin : MonoBehaviour public class GoogleLogin : MonoBehaviour
{ {
private Log.LoginSession session = new Log.LoginSession(); private Log.LoginSession session = new Log.LoginSession();
private bool isQuitting = false;
public void OnGoogleLoginButtonClicked() public void OnGoogleLoginButtonClicked()
{ {
...@@ -22,6 +24,13 @@ public class GoogleLogin : MonoBehaviour ...@@ -22,6 +24,13 @@ public class GoogleLogin : MonoBehaviour
if (success == SignInStatus.Success) if (success == SignInStatus.Success)
{ {
Debug.Log("Signed in with Google Play successfully."); Debug.Log("Signed in with Google Play successfully.");
UserSessionManager.LogIn(Social.localUser.userName);
string googlePlayGamesID = Social.localUser.id;
PhotonNetwork.NickName = googlePlayGamesID;
PhotonNetwork.ConnectUsingSettings();
} }
else if (success == SignInStatus.InternalError) else if (success == SignInStatus.InternalError)
{ {
...@@ -32,4 +41,21 @@ public class GoogleLogin : MonoBehaviour ...@@ -32,4 +41,21 @@ public class GoogleLogin : MonoBehaviour
Debug.Log("Failed to sign in with Google Play"); Debug.Log("Failed to sign in with Google Play");
} }
} }
void Update()
{
// Handle quitting on Android devices
if (Application.platform == RuntimePlatform.Android)
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (!isQuitting)
{
isQuitting = true;
session.LogoutTime = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm");
Log.LogLoginSession(session);
}
}
}
}
} }
...@@ -123,6 +123,139 @@ NavMeshSettings: ...@@ -123,6 +123,139 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &155577947
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 155577948}
- component: {fileID: 155577951}
- component: {fileID: 155577950}
- component: {fileID: 155577949}
m_Layer: 5
m_Name: Logout
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &155577948
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 155577947}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1567345924}
m_Father: {fileID: 231072928}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 350}
m_SizeDelta: {x: 300, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &155577949
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 155577947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 155577950}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 231072931}
m_TargetAssemblyTypeName: UserSessionManager, Assembly-CSharp
m_MethodName: LogOut
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &155577950
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 155577947}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &155577951
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 155577947}
m_CullTransparentMesh: 1
--- !u!1 &231072924 --- !u!1 &231072924
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -137,6 +270,7 @@ GameObject: ...@@ -137,6 +270,7 @@ GameObject:
- component: {fileID: 231072925} - component: {fileID: 231072925}
- component: {fileID: 231072929} - component: {fileID: 231072929}
- component: {fileID: 231072930} - component: {fileID: 231072930}
- component: {fileID: 231072931}
m_Layer: 5 m_Layer: 5
m_Name: Canvas m_Name: Canvas
m_TagString: Untagged m_TagString: Untagged
...@@ -222,6 +356,7 @@ RectTransform: ...@@ -222,6 +356,7 @@ RectTransform:
- {fileID: 1080356726} - {fileID: 1080356726}
- {fileID: 549949876} - {fileID: 549949876}
- {fileID: 1858032154} - {fileID: 1858032154}
- {fileID: 155577948}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
...@@ -255,6 +390,18 @@ MonoBehaviour: ...@@ -255,6 +390,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6021d8e2d7d7df545b3cae35f6c2d251, type: 3} m_Script: {fileID: 11500000, guid: 6021d8e2d7d7df545b3cae35f6c2d251, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!114 &231072931
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 231072924}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 968b2832dfc4bd546b9aee0fed2fd7da, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &519420028 --- !u!1 &519420028
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -627,6 +774,140 @@ CanvasRenderer: ...@@ -627,6 +774,140 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1080356725} m_GameObject: {fileID: 1080356725}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!1 &1567345923
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1567345924}
- component: {fileID: 1567345926}
- component: {fileID: 1567345925}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1567345924
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567345923}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 155577948}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1567345925
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567345923}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Log out
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281479730
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 72
m_fontSizeBase: 72
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &1567345926
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1567345923}
m_CullTransparentMesh: 1
--- !u!1 &1609838527 --- !u!1 &1609838527
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
using Photon.Pun;
using System;
using TMPro;
using UnityEngine;
using static Log;
public class UserSessionManager : MonoBehaviour
{
[SerializeField] TextMeshProUGUI message;
private static LoginSession currentSession;
public static void LogIn(string username)
{
// Create a new session and store the login time
currentSession = new LoginSession
{
Username = username,
LoginTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
};
}
public void LogOut()
{
if (currentSession != null)
{
// Set the logout time for the current session
currentSession.LogoutTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
LogLoginSession(currentSession);
// Reset the current session
currentSession = null;
PhotonNetwork.Disconnect();
message.text = "Logged Out! Disconnected from Photon.";
}
}
}
fileFormatVersion: 2
guid: 968b2832dfc4bd546b9aee0fed2fd7da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -370,6 +370,103 @@ PlayerSettings: ...@@ -370,6 +370,103 @@ PlayerSettings:
m_Height: 36 m_Height: 36
m_Kind: 0 m_Kind: 0
m_SubKind: m_SubKind:
- m_BuildTarget: iPhone
m_Icons:
- m_Textures: []
m_Width: 180
m_Height: 180
m_Kind: 0
m_SubKind: iPhone
- m_Textures: []
m_Width: 120
m_Height: 120
m_Kind: 0
m_SubKind: iPhone
- m_Textures: []
m_Width: 167
m_Height: 167
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 152
m_Height: 152
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 76
m_Height: 76
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 120
m_Height: 120
m_Kind: 3
m_SubKind: iPhone
- m_Textures: []
m_Width: 80
m_Height: 80
m_Kind: 3
m_SubKind: iPhone
- m_Textures: []
m_Width: 80
m_Height: 80
m_Kind: 3
m_SubKind: iPad
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 3
m_SubKind: iPad
- m_Textures: []
m_Width: 87
m_Height: 87
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 58
m_Height: 58
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 29
m_Height: 29
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 58
m_Height: 58
m_Kind: 1
m_SubKind: iPad
- m_Textures: []
m_Width: 29
m_Height: 29
m_Kind: 1
m_SubKind: iPad
- m_Textures: []
m_Width: 60
m_Height: 60
m_Kind: 2
m_SubKind: iPhone
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 2
m_SubKind: iPhone
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 2
m_SubKind: iPad
- m_Textures: []
m_Width: 20
m_Height: 20
m_Kind: 2
m_SubKind: iPad
- m_Textures: []
m_Width: 1024
m_Height: 1024
m_Kind: 4
m_SubKind: App Store
m_BuildTargetBatching: [] m_BuildTargetBatching: []
m_BuildTargetShaderSettings: [] m_BuildTargetShaderSettings: []
m_BuildTargetGraphicsJobs: m_BuildTargetGraphicsJobs:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment