[U] Sync n3
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
using System.IO;
|
||||
using UnityEditor.Android;
|
||||
|
||||
namespace tysdk.editor
|
||||
{
|
||||
|
||||
public class AndroidPostBuildProcessor : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
public int callbackOrder => 1;
|
||||
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
UnityEngine.Debug.Log($"OnPostGenerateGradleAndroidProject {path}");
|
||||
var projectPath = Directory.GetParent(path).ToString();
|
||||
var googleServicesJsonPath = "Packages/tysdk/Files/google-services.json";
|
||||
var googleServicesTargetPath = Path.Combine(projectPath, "launcher/google-services.json");
|
||||
File.Copy(googleServicesJsonPath, googleServicesTargetPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.IO;
|
||||
using UnityEditor.Android;
|
||||
|
||||
namespace tysdk.editor
|
||||
{
|
||||
|
||||
public class AndroidPostBuildProcessor : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
public int callbackOrder => 1;
|
||||
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
UnityEngine.Debug.Log($"OnPostGenerateGradleAndroidProject {path}");
|
||||
var projectPath = Directory.GetParent(path).ToString();
|
||||
var googleServicesJsonPath = "Packages/tysdk/Files/google-services.json";
|
||||
var googleServicesTargetPath = Path.Combine(projectPath, "launcher/google-services.json");
|
||||
File.Copy(googleServicesJsonPath, googleServicesTargetPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2476ed86dea148a3b7327293f8372cd
|
||||
guid: 56f87573a715b418e8502b3402d41a44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -55,6 +55,14 @@ namespace tysdk.editor
|
||||
File.WriteAllText(mainAppPath, newContent);
|
||||
}
|
||||
|
||||
private static void ProceeFirebasePlist(string target, PBXProject proj, string root)
|
||||
{
|
||||
var plistPath = Path.Combine("Packages/tysdk/Files", "GoogleService-Info.plist");
|
||||
File.Copy(plistPath, $"{root}/GoogleService-Info.plist", true);
|
||||
var plistGuid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist", PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(target, plistGuid);
|
||||
}
|
||||
|
||||
private static void XCodeSetSigingAndCapbilities(string target, PBXProject proj, string root)
|
||||
{
|
||||
var entitlementsContent = File.ReadAllText("Packages/tysdk/Files/Unity-iPhone.entitlements");
|
||||
@@ -66,14 +74,6 @@ namespace tysdk.editor
|
||||
//proj.AddCapability(target, PBXCapabilityType.AssociatedDomains, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
}
|
||||
|
||||
private static void ProceeFirebasePlist(string target, PBXProject proj, string root)
|
||||
{
|
||||
var plistPath = Path.Combine("Packages/tysdk/Files", "GoogleService-Info.plist");
|
||||
File.Copy(plistPath, $"{root}/GoogleService-Info.plist", true);
|
||||
var plistGuid = proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist", PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(target, plistGuid);
|
||||
}
|
||||
|
||||
private static void ProcessBuildSettings(PBXProject proj)
|
||||
{
|
||||
string target = proj.TargetGuidByName("GameAssembly");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de52d9ff9949f4d54b71776fb23da414
|
||||
guid: fe43ff94ee6dd4dc980ffa685191687c
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
||||
@@ -72,13 +72,8 @@ public class SDKManager {
|
||||
if (i == 0) {
|
||||
JSONObject serverResponse = new JSONObject(s);
|
||||
JSONObject userInfo = serverResponse.getJSONObject("result");
|
||||
JSONObject userInfoReorganization = new JSONObject();
|
||||
userInfoReorganization.put("userId", userInfo.optString("userId"));
|
||||
userInfoReorganization.put("token", userInfo.optString("token"));
|
||||
userInfoReorganization.put("jwttoken", userInfo.optString("jwttoken"));
|
||||
userInfoReorganization.put("loginChannelTypeC", userInfo.optString("loginChannelTypeC"));
|
||||
JSONObject userInfoResult = new JSONObject();
|
||||
userInfoResult.put("result", userInfoReorganization);
|
||||
userInfoResult.put("result", userInfo);
|
||||
result.put("respObj", userInfoResult);
|
||||
} else {
|
||||
result.put("errStr", s);
|
||||
|
||||
Binary file not shown.
@@ -1,87 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f09db8f4c73f97540a96ebe183df5fd1
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AndroidSharedLibraryType: Executable
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bacddd479751940f38f3f6cbe40aed5c
|
||||
guid: 07220c05f1f0b4944b33ce5b6d053876
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -14,35 +14,14 @@ namespace tysdk
|
||||
{
|
||||
public class AccountInfo
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{EAccoutType.hwGoogle.ToString(), EAccoutType.hwGoogle},
|
||||
{EAccoutType.hwFacebook.ToString(), EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest}
|
||||
};
|
||||
#else
|
||||
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
};
|
||||
#endif
|
||||
|
||||
public int userId;
|
||||
public string token;
|
||||
public string jwtToken;
|
||||
public string strUserId => userId.ToString();
|
||||
public string channelstr {
|
||||
set{
|
||||
channel = accoutTypeMap[value];
|
||||
linkedAccout.Add(channel);
|
||||
}
|
||||
}
|
||||
public HashSet<EAccoutType> linkedAccout = new HashSet<EAccoutType>();
|
||||
public EAccoutType channel {get; private set;}
|
||||
public EAccoutType channel {get; set;}
|
||||
public string userName;
|
||||
public string avatar;
|
||||
|
||||
private const string KEY_ACCOUNT_INFO = "KEY_ACCOUNT_INFO";
|
||||
|
||||
@@ -54,23 +33,30 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLinkedAccount(string channel)
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
};
|
||||
|
||||
private static EAccoutType ConvertAccoutType(string accountType)
|
||||
{
|
||||
if(accoutTypeMap.TryGetValue(channel, out var accoutType))
|
||||
if (accoutTypeMap.ContainsKey(accountType))
|
||||
{
|
||||
if (!linkedAccout.Contains(accoutType))
|
||||
{
|
||||
linkedAccout.Add(accoutType);
|
||||
}
|
||||
return accoutTypeMap[accountType];
|
||||
}
|
||||
return (EAccoutType)Enum.Parse(typeof(EAccoutType), accountType);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
JObject jInfo = new JObject();
|
||||
jInfo["channel"] = accoutTypeMap.First(x => x.Value == channel).Key;
|
||||
jInfo["channel"] = channel.ToString();
|
||||
jInfo["token"] = token;
|
||||
jInfo["userId"] = userId;
|
||||
jInfo["userName"] = userName;
|
||||
jInfo["avatar"] = avatar;
|
||||
jInfo["jwtToken"] = jwtToken;
|
||||
jInfo["linkedAccout"] = string.Join(",", linkedAccout.Select(x => x.ToString()));
|
||||
PlayerPrefs.SetString(KEY_ACCOUNT_INFO, jInfo.ToString());
|
||||
@@ -86,14 +72,26 @@ namespace tysdk
|
||||
if (PlayerPrefs.HasKey(KEY_ACCOUNT_INFO))
|
||||
{
|
||||
var jInfo = JObject.Parse(PlayerPrefs.GetString(KEY_ACCOUNT_INFO));
|
||||
return new AccountInfo()
|
||||
var accountInfo = new AccountInfo()
|
||||
{
|
||||
userId = (int)jInfo["userId"],
|
||||
token = (string)jInfo["token"],
|
||||
channelstr = (string)jInfo["channel"],
|
||||
channel = ConvertAccoutType((string)jInfo["channel"]),
|
||||
jwtToken = (string)jInfo["jwtToken"],
|
||||
linkedAccout = jInfo["linkedAccout"].ToString().Split(',').Select(x => (EAccoutType)Enum.Parse(typeof(EAccoutType), x)).ToHashSet()
|
||||
linkedAccout = jInfo["linkedAccout"].ToString().Split(',').Select(x => ConvertAccoutType(x)).ToHashSet()
|
||||
};
|
||||
|
||||
if(jInfo.TryGetValue("userName", out var userName))
|
||||
{
|
||||
accountInfo.userName = (string) userName;
|
||||
}
|
||||
|
||||
if(jInfo.TryGetValue("avatar", out var avatar))
|
||||
{
|
||||
accountInfo.avatar = (string)avatar;
|
||||
}
|
||||
|
||||
return accountInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,10 +182,15 @@ namespace tysdk
|
||||
|
||||
UnityBridgeFunc.UnityLogin(accoutType);
|
||||
|
||||
return await taskSource.Task;
|
||||
|
||||
var loginInfo = await taskSource.Task;
|
||||
if(loginInfo.isSuccess)
|
||||
{
|
||||
_accountInfo.channel = accoutType;
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return loginInfo;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public async Task<LoginInfo> LoginByToken()
|
||||
@@ -203,7 +206,12 @@ namespace tysdk
|
||||
|
||||
UnityBridgeFunc.UnityLoginByTokenFun(accoutInfo.token);
|
||||
|
||||
return await taskSource.Task;
|
||||
var loginInfo = await taskSource.Task;
|
||||
if(loginInfo.isSuccess)
|
||||
{
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return loginInfo;
|
||||
}
|
||||
|
||||
public void LoginResult(string json)
|
||||
@@ -221,7 +229,6 @@ namespace tysdk
|
||||
var userId = (int)loginData["userId"];
|
||||
var token = (string)loginData["token"];
|
||||
var jwtToken = (string)loginData["jwttoken"];
|
||||
var channelstr = (string)loginData["loginChannelTypeC"];
|
||||
|
||||
var savedInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(savedInfo == null || savedInfo.userId != userId)
|
||||
@@ -229,19 +236,16 @@ namespace tysdk
|
||||
_accountInfo = new AccountInfo()
|
||||
{
|
||||
userId = (int)loginData["userId"],
|
||||
userName = (string)loginData["userName"],
|
||||
avatar = (string)loginData["purl"],
|
||||
token = (string)loginData["token"],
|
||||
jwtToken = (string)loginData["jwttoken"],
|
||||
channelstr = (string)loginData["loginChannelTypeC"]
|
||||
};
|
||||
|
||||
_accountInfo.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
savedInfo.token = token;
|
||||
savedInfo.jwtToken = jwtToken;
|
||||
savedInfo.AddLinkedAccount(channelstr);
|
||||
savedInfo.Save();
|
||||
_accountInfo = savedInfo;
|
||||
}
|
||||
|
||||
@@ -290,12 +294,13 @@ namespace tysdk
|
||||
var result = await taskSource.Task;
|
||||
if (result.isSuccess)
|
||||
{
|
||||
var savedInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(savedInfo != null)
|
||||
if(_accountInfo == null)
|
||||
_accountInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
|
||||
if(_accountInfo != null)
|
||||
{
|
||||
savedInfo.AddLinkedAccount(accoutType);
|
||||
savedInfo.Save();
|
||||
_accountInfo = savedInfo;
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,6 +337,17 @@ namespace tysdk
|
||||
UnityBridgeFunc.LinkAccount(accoutType);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
if (result.isSuccess)
|
||||
{
|
||||
if(_accountInfo == null)
|
||||
_accountInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
|
||||
if(_accountInfo != null)
|
||||
{
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
}
|
||||
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
{
|
||||
"name": "tysdk",
|
||||
"rootNamespace": "tysdk",
|
||||
"references": [
|
||||
"GUID:0a958a7eb80a248e1b8bc4553787c209"
|
||||
],
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
|
||||
Reference in New Issue
Block a user