Pārlūkot izejas kodu

Update login logic

alex_gs 3 gadi atpakaļ
vecāks
revīzija
7b2c9d149c

+ 4 - 4
Unity3/Assets/SocialNetworking/Scripts/FaceBook/SocialManager.cs

@@ -67,10 +67,10 @@ public class SocialManager : MonoBehaviour
 	private Action<bool, string> _onLoginCompleted;
 	
 	public string userID;
-	private string _name;
-	private string _surname;
-	private string _username;
-	private string _usermail;
+	public string _name;
+	public string _surname;
+	public string _username;
+	public string _usermail;
 	private string _gender;
 	private string _ageRange;
 

+ 2 - 1
Unity3/Assets/SocialNetworking/Scripts/WrapperFB.cs

@@ -33,7 +33,7 @@ public class WrapperFB : MonoBehaviour
         SocialManager.Instance.userID = ID;
         if (PlayerPrefs.GetInt("Login") == 1)
         {
-            LogoutGo.SetActive(true);
+            LogoutGo.SetActive(false);
             LoginGo.SetActive(false);
         }
         else
@@ -42,6 +42,7 @@ public class WrapperFB : MonoBehaviour
             LoginGo.SetActive(true);
         }
         Go = gameObject;
+        Debug.Log("ID " + ID);
          Name = PlayerPrefs.GetString("FB_USER_NAME", "");
 #if UNITY_EDITOR
        

+ 5 - 0
Unity3/Assets/UI/Screens/ChangeLoginPopup.cs

@@ -22,4 +22,9 @@ public class ChangeLoginPopup : ScreenBase
         PlayerPrefs.Save();
     }
 
+    void OnDestroy()
+    {
+        PlayerPrefs.SetInt("GUEST", 0);
+        PlayerPrefs.Save();
+    }
 }

+ 9 - 1
Unity3/Assets/Unity Technologies/SignInWithApple/Samples/Scripts/SignInWithAppleTest_Callbacks.cs

@@ -43,8 +43,16 @@ public class SignInWithAppleTest_Callbacks : MonoBehaviour
         var allName = userInfo.displayName.Split(' ');
         var _name = allName[0];
         var _surname = allName[1];
-       
+
         // Print out information about the user who logged in.
+        SocialManager.Instance.userID = userInfo.userId;
+        SocialManager.Instance._name = _name;
+        SocialManager.Instance._surname = _surname;
+        SocialManager.Instance._usermail= userInfo.email;
+        SocialManager.Instance._username = userInfo.userId;
+        PlayerPrefs.SetString("UserID", userInfo.userId);
+        PlayerPrefs.SetInt("Login", 1);
+        PlayerPrefs.Save();
         GameDatabaseManager.Instance.RegisterUser(userInfo.userId, _name, _surname, userInfo.displayName, userInfo.email, OnLoginCompleted);
         Debug.Log(
             string.Format("Display Name: {0}\nEmail: {1}\nUser ID: {2}\nID Token: {3}", userInfo.displayName ?? "",