From 1a0af9d725158077dc5152da5340faa1bb192df4 Mon Sep 17 00:00:00 2001 From: tech Date: Fri, 16 Aug 2024 00:56:24 +0800 Subject: [PATCH] [M] all functional --- sdk-intergration/Assets/Editor/BuildTool.cs | 58 ++ .../Assets/Scenes/SampleScene.unity | 808 ++++++++++++++++++ sdk-intergration/Assets/Scripts/SDKTest.cs | 64 +- .../tysdk/Plugins/Android/ConfigManager.java | 1 + .../tysdk/Plugins/Android/SDKManager.java | 57 +- .../tysdk/Plugins/iOS/TYSDKInterface.mm | 84 +- .../Packages/tysdk/Runtime/TYSdkFacade.cs | 134 ++- .../Packages/tysdk/Runtime/TYSdkFacade_AD.cs | 61 -- .../tysdk/Runtime/TYSdkFacade_AD.cs.meta | 3 - .../Packages/tysdk/Runtime/TYSdkFacade_Pay.cs | 18 +- .../Packages/tysdk/Runtime/TYSdkModel.cs | 55 +- .../Packages/tysdk/Runtime/UnityBridgeFunc.cs | 100 ++- .../AndroidResolverDependencies.xml | 2 +- .../ProjectSettings/GvhProjectSettings.xml | 4 + 14 files changed, 1278 insertions(+), 171 deletions(-) delete mode 100644 sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs delete mode 100644 sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs.meta diff --git a/sdk-intergration/Assets/Editor/BuildTool.cs b/sdk-intergration/Assets/Editor/BuildTool.cs index c85287b..da98cf4 100644 --- a/sdk-intergration/Assets/Editor/BuildTool.cs +++ b/sdk-intergration/Assets/Editor/BuildTool.cs @@ -55,6 +55,64 @@ public class BuildTool BuildiOS(bparams); } + [MenuItem("Tools/Build Android")] + public static void BuildAndroid() + { + + BuildParams bparams = new BuildParams() + { + outPath = "../Bin/tysdkTest.apk" + }; + + BuildiOS(bparams); + } + + public static void CIBuildAndroid() + { + List args = new List(Environment.GetCommandLineArgs()); + + BuildParams bparams = new BuildParams() + { + outPath = args[args.IndexOf(Param_Out_Path) + 1], + //version = args[args.IndexOf(Param_Version) + 1], + defineSymbol = args.IndexOf(Param_Define_Symbol) == -1 ? string.Empty : args[args.IndexOf(Param_Define_Symbol) + 1], + buildType = args.IndexOf(Param_Build_Type) == -1 ? "New" : args[args.IndexOf(Param_Build_Type) + 1], + //bundlesVersion = int.Parse(args[args.IndexOf(Param_Bundle_Version_Code) + 1]), + isPatch = args.Contains(Param_Patch), + split = args.Contains(Param_Split), + aab = args.Contains(Param_Aab), + bundleType = Enum.Parse(args[args.IndexOf(Param_Bundle_Type) + 1]) + }; + + BuildAndroid(bparams); + } + + private static void BuildAndroid(BuildParams buildParams) + { + + var buildPlayerOptions = new BuildPlayerOptions + { + scenes = EditorBuildSettings.scenes.Select(x => x.path).ToArray(), + locationPathName = buildParams.outPath, + + target = BuildTarget.Android, + options = BuildOptions.None, + }; + + var build_report = BuildPipeline.BuildPlayer(buildPlayerOptions); + + if (build_report?.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) + { + UnityEngine.Debug.Log($"[Build Player Success] {System.IO.Path.GetFullPath(buildParams.outPath)}"); + AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); + } + else + { + UnityEngine.Debug.LogError($"Build Player Failed: {build_report?.summary}"); + } + } + + [MenuItem("Tools/Build iOS")] public static void BuildiOS() { diff --git a/sdk-intergration/Assets/Scenes/SampleScene.unity b/sdk-intergration/Assets/Scenes/SampleScene.unity index cd2d0ad..12b2234 100644 --- a/sdk-intergration/Assets/Scenes/SampleScene.unity +++ b/sdk-intergration/Assets/Scenes/SampleScene.unity @@ -512,6 +512,85 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &231808344 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 231808345} + - component: {fileID: 231808347} + - component: {fileID: 231808346} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &231808345 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 231808344} + 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: 1094138236} + 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 &231808346 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 231808344} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 33 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: L_google +--- !u!222 &231808347 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 231808344} + m_CullTransparentMesh: 1 --- !u!1 &276006784 GameObject: m_ObjectHideFlags: 0 @@ -807,6 +886,285 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 340278280} m_CullTransparentMesh: 1 +--- !u!1 &354913240 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 354913241} + - component: {fileID: 354913243} + - component: {fileID: 354913242} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &354913241 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 354913240} + 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: 1033467961} + 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 &354913242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 354913240} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 33 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: C_FB +--- !u!222 &354913243 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 354913240} + m_CullTransparentMesh: 1 +--- !u!1 &407966797 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 407966798} + - component: {fileID: 407966800} + - component: {fileID: 407966799} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &407966798 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 407966797} + 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: 698899140} + 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 &407966799 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 407966797} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 33 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: C_google +--- !u!222 &407966800 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 407966797} + m_CullTransparentMesh: 1 +--- !u!1 &698899139 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 698899140} + - component: {fileID: 698899142} + - component: {fileID: 698899141} + - component: {fileID: 698899143} + m_Layer: 5 + m_Name: CGoogle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &698899140 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 698899139} + 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: 407966798} + m_Father: {fileID: 1044920373} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &698899141 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 698899139} + 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 &698899142 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 698899139} + m_CullTransparentMesh: 1 +--- !u!114 &698899143 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 698899139} + 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: 698899141} + m_OnClick: + m_PersistentCalls: + m_Calls: [] --- !u!1 &816060983 GameObject: m_ObjectHideFlags: 0 @@ -1165,6 +1523,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 942378168} m_CullTransparentMesh: 1 +--- !u!1 &948068708 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 948068709} + - component: {fileID: 948068711} + - component: {fileID: 948068710} + - component: {fileID: 948068712} + m_Layer: 5 + m_Name: L_FB + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &948068709 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 948068708} + 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: 1562838095} + m_Father: {fileID: 1044920373} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &948068710 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 948068708} + 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 &948068711 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 948068708} + m_CullTransparentMesh: 1 +--- !u!114 &948068712 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 948068708} + 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: 948068710} + m_OnClick: + m_PersistentCalls: + m_Calls: [] --- !u!1 &1033367769 GameObject: m_ObjectHideFlags: 0 @@ -1244,6 +1723,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1033367769} m_CullTransparentMesh: 1 +--- !u!1 &1033467960 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1033467961} + - component: {fileID: 1033467963} + - component: {fileID: 1033467962} + - component: {fileID: 1033467964} + m_Layer: 5 + m_Name: C_FB + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1033467961 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1033467960} + 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: 354913241} + m_Father: {fileID: 1044920373} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &1033467962 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1033467960} + 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 &1033467963 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1033467960} + m_CullTransparentMesh: 1 +--- !u!114 &1033467964 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1033467960} + 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: 1033467962} + m_OnClick: + m_PersistentCalls: + m_Calls: [] --- !u!1 &1044920372 GameObject: m_ObjectHideFlags: 0 @@ -1278,6 +1878,10 @@ RectTransform: - {fileID: 1188788676} - {fileID: 1627053315} - {fileID: 834002869} + - {fileID: 1094138236} + - {fileID: 698899140} + - {fileID: 948068709} + - {fileID: 1033467961} - {fileID: 1304993149} - {fileID: 29523099} - {fileID: 1110300853} @@ -1515,6 +2119,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1071692829} m_CullTransparentMesh: 1 +--- !u!1 &1094138235 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1094138236} + - component: {fileID: 1094138238} + - component: {fileID: 1094138237} + - component: {fileID: 1094138239} + m_Layer: 5 + m_Name: LGoogle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1094138236 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1094138235} + 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: 231808345} + m_Father: {fileID: 1044920373} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &1094138237 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1094138235} + 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 &1094138238 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1094138235} + m_CullTransparentMesh: 1 +--- !u!114 &1094138239 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1094138235} + 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: 1094138237} + m_OnClick: + m_PersistentCalls: + m_Calls: [] --- !u!1 &1110300852 GameObject: m_ObjectHideFlags: 0 @@ -2060,6 +2785,85 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &1562838094 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1562838095} + - component: {fileID: 1562838097} + - component: {fileID: 1562838096} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1562838095 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1562838094} + 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: 948068709} + 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 &1562838096 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1562838094} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 33 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: L_FB +--- !u!222 &1562838097 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1562838094} + m_CullTransparentMesh: 1 --- !u!1 &1574191669 GameObject: m_ObjectHideFlags: 0 @@ -2415,6 +3219,10 @@ MonoBehaviour: _loginGoogleBtn: {fileID: 1188788679} _loginFbBtn: {fileID: 1627053318} _loginTokenBtn: {fileID: 834002870} + _linkGoogleBtn: {fileID: 1094138239} + _checkGoogleBtn: {fileID: 698899143} + _linkFacbookBtn: {fileID: 948068712} + _checkFacbookBtn: {fileID: 1033467964} _logOutBtn: {fileID: 1304993150} _payTestBtn: {fileID: 120435831} _payListBtn: {fileID: 1110300854} diff --git a/sdk-intergration/Assets/Scripts/SDKTest.cs b/sdk-intergration/Assets/Scripts/SDKTest.cs index b958c04..b6ba70b 100644 --- a/sdk-intergration/Assets/Scripts/SDKTest.cs +++ b/sdk-intergration/Assets/Scripts/SDKTest.cs @@ -19,6 +19,14 @@ public class SDKTest : MonoBehaviour [SerializeField] private Button _loginTokenBtn; [SerializeField] + private Button _linkGoogleBtn; + [SerializeField] + private Button _checkGoogleBtn; + [SerializeField] + private Button _linkFacbookBtn; + [SerializeField] + private Button _checkFacbookBtn; + [SerializeField] private Button _logOutBtn; [SerializeField] private Button _payTestBtn; @@ -47,6 +55,10 @@ public class SDKTest : MonoBehaviour _loginFbBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwFacebook)); _loginTokenBtn.onClick.AddListener(OnLoginByToken); _logOutBtn.onClick.AddListener(OnLogout); + _linkGoogleBtn.onClick.AddListener(OnLinkGoogle); + _checkGoogleBtn.onClick.AddListener(OncheckGoogle); + _linkFacbookBtn.onClick.AddListener(OnLinkFacebook); + _checkFacbookBtn.onClick.AddListener(OncheckFacebook); _payTestBtn.onClick.AddListener(OnPayTestBtn); _payListBtn.onClick.AddListener(OnPayListBtn); _gaTestBtn.onClick.AddListener(OnGaBtn); @@ -101,7 +113,7 @@ public class SDKTest : MonoBehaviour if (info.isSuccess) { _messageTxt.text += $"\n{info.msg}"; - _messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}"; + _messageTxt.text += $"\n{TYSdkFacade.TYAccountInfo.token}"; } } @@ -114,7 +126,7 @@ public class SDKTest : MonoBehaviour if (info.isSuccess) { _messageTxt.text += $"\n{info.msg}"; - _messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}"; + _messageTxt.text += $"\n{TYSdkFacade.TYAccountInfo.token}"; } } @@ -130,24 +142,7 @@ public class SDKTest : MonoBehaviour _messageTxt.text = "no product"; return; } - string prodId = sku.productId; - string pType = string.Empty; -#if UNITY_ANDROID - pType = sku.type; -#endif - string prodPrice = sku.price; - -#if UNITY_EDITOR - string prodName = string.Empty; -#elif UNITY_ANDROID - string prodName = sku.title; -#elif UNITY_IOS - string prodName = sku.localizedTitle; -#endif - int count = 1; - - Debug.LogError($"[AggSdk::Pay] prodId : {prodId} prodPrice : {prodPrice} prodName : {prodName} "); - PaymentInfo payResult = await TYSdkFacade.Instance.Pay(prodId, prodPrice, prodName, count, pType); + PaymentInfo payResult = await TYSdkFacade.Instance.Pay(sku, 1); _messageTxt.text = "\n" + $"Success : {payResult.isSuccess}"; _messageTxt.text += "\n" + $"message : {payResult.msg}"; } @@ -265,6 +260,35 @@ public class SDKTest : MonoBehaviour Debug.Log(msg); } + + private async void OnLinkGoogle() + { + _messageTxt.text = string.Empty; + var isSuccess = await TYSdkFacade.Instance.LinkAccount(EAccoutType.hwGoogle); + _messageTxt.text = $"\n link google account : {isSuccess}"; + } + + private async void OnLinkFacebook() + { + _messageTxt.text = string.Empty; + var isSuccess = await TYSdkFacade.Instance.LinkAccount(EAccoutType.hwFacebook); + _messageTxt.text = $"\n link facebook account : {isSuccess}"; + } + + private async void OncheckGoogle() + { + _messageTxt.text = string.Empty; + var isSuccess = await TYSdkFacade.Instance.LinkCheck(EAccoutType.hwGoogle); + _messageTxt.text = $"\n google account linked : {isSuccess}"; + } + + private async void OncheckFacebook() + { + _messageTxt.text = string.Empty; + var isSuccess = await TYSdkFacade.Instance.LinkCheck(EAccoutType.hwFacebook); + _messageTxt.text = $"\n facebook account linked : {isSuccess}"; + } + /* public void OnTaBtn() { diff --git a/sdk-intergration/Packages/tysdk/Plugins/Android/ConfigManager.java b/sdk-intergration/Packages/tysdk/Plugins/Android/ConfigManager.java index a1e7010..454d336 100644 --- a/sdk-intergration/Packages/tysdk/Plugins/Android/ConfigManager.java +++ b/sdk-intergration/Packages/tysdk/Plugins/Android/ConfigManager.java @@ -21,6 +21,7 @@ public class ConfigManager { public static final String UNITY_FACADE_NAME = "TYSdkFacade"; public static final String LOGIN_CALLBACK_FUNCTION_NAME = "LoginResult"; + public static final String CHECKLINK_CALLBACK_FUNCTION_NAME = "CheckLinkResult"; public static final String PAY_CALLBACK_FUNCTION_NAME = "PayResult"; public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "SKUListResult"; public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback"; diff --git a/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java b/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java index 8debb66..963b921 100644 --- a/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java +++ b/sdk-intergration/Packages/tysdk/Plugins/Android/SDKManager.java @@ -65,7 +65,6 @@ public class SDKManager { public static void parseLoginInfo(int i, String s) { - Log.e(TAG,"parseLoginInfo!!" ); try { JSONObject result = new JSONObject(); result.put("code", i); @@ -74,19 +73,15 @@ public class SDKManager { JSONObject userInfo = serverResponse.getJSONObject("result"); JSONObject userInfoReorganization = new JSONObject(); userInfoReorganization.put("userId", userInfo.optString("userId")); - userInfoReorganization.put("authorCode", userInfo.optString("authorCode")); 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); result.put("respObj", userInfoResult); - - Log.e(TAG,"userId:::::" + userInfo.optString("userId")); - Log.e(TAG,"token:::::" + userInfo.optString("token")); } else { Log.e(TAG,"errStr:::::" +s); result.put("errStr", s); - Log.e(TAG,"errStrInfo:::::" +result.toString()); } UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LOGIN_CALLBACK_FUNCTION_NAME, result.toString()); @@ -163,13 +158,59 @@ public class SDKManager { }); } - public static void UnityLogOutByChannel(string type) { + public static void UnityLogOutByChannel(String type) { // Log.e(TAG,"UnityLoginOut!!!"); SDKLog.i("UnityLoginOut : "); handler.post(() -> SDKAPI.getIns().logout(type)); } - public static void UnityKnow(String userId, String productId, String productPrice, String productName, String productCount, String prodorderId, String appInfo) { + public static void LinkAccount(String type, String userId) + { + SDKAPI.getIns().getSnsInfo(type, (code, snsInfo, msg) -> { + if(code == SDKCallBack.CODE_SUCCESS && snsInfo != null){ + SDKAPI.getIns().bindBySnsId(snsInfo, userId, mLogin); + }else { + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LOGIN_CALLBACK_FUNCTION_NAME, "{\"code\":1}}"); + } + }); + } + + public static void LinkCheck(String type) + { + SDKAPI.getIns().getSnsInfo(type, (code, snsInfo, msg) -> { + if(code == SDKCallBack.CODE_SUCCESS && snsInfo != null){ + SDKAPI.getIns().checkSnsInfo(snsInfo, (code1, msg1) -> { + if(code1 == SDKCallBack.CODE_SUCCESS && !TextUtils.isEmpty(msg1)){ + try { + JSONObject jsonObject = new JSONObject(msg1).optJSONObject("result"); + //返回信息中code为0时表示服务端查询成功,exit为1表示此渠道用户信息已产生过途游账号,可直接进行登录,exit为0表示此渠道用户信息未产生过途游账号,可以进行绑定 + if(jsonObject.optString("code").equals("0") + && jsonObject.optString("exist").equals("0")){ + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHECKLINK_CALLBACK_FUNCTION_NAME, "0"); + } + else + { + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHECKLINK_CALLBACK_FUNCTION_NAME, "1"); + } + } catch (JSONException e) { + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHECKLINK_CALLBACK_FUNCTION_NAME, "-1"); + e.printStackTrace(); + } + } + else + { + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHECKLINK_CALLBACK_FUNCTION_NAME, "-1"); + } + }); + } + else + { + UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHECKLINK_CALLBACK_FUNCTION_NAME, "-1"); + } + }); + } + + public static void UnityKnow(String productId, String productName, String productCount, String prodorderId, String appInfo) { SDKLog.i("UnityKnow : " + productId); HashMap extraInfo = new HashMap(); extraInfo.put("appInfo", appInfo); diff --git a/sdk-intergration/Packages/tysdk/Plugins/iOS/TYSDKInterface.mm b/sdk-intergration/Packages/tysdk/Plugins/iOS/TYSDKInterface.mm index d9495b0..f5c738f 100644 --- a/sdk-intergration/Packages/tysdk/Plugins/iOS/TYSDKInterface.mm +++ b/sdk-intergration/Packages/tysdk/Plugins/iOS/TYSDKInterface.mm @@ -218,24 +218,80 @@ extern "C" { } - //广告相关 - void UnitySetAdBoxUserInfo(char* userId) + void LinkGoogle(const int userId) { - - } - - void UnityInitADSConfig() - { - - } - - void UnityLoadRvADS() - { - + NSLog(@"TYSdkInterface LinkGoogle"); + NSDictionary * userDic = [XYApi XYGetCurrentUserDict]; + XYBindReq *bindReq = [XYBindReq initBindWithPlatform:XYBindGoodle UserId: [ [userDic objectForKey:@"userId"] unsignedIntegerValue]]; + [XYApi XYBindByBindReq:bindReq isUnbindGuest:@"false" completionHandler:^(XYResp * _Nonnull resp) { + if(resp.errCode == XYSuccess) + { + NSLog(@"TYSdkInterface LinkGoogle Success"); + UnitySendMessage("TYSdkFacade","LinkAccoutResult", "1"); + } + else + { + NSLog(@"TYSdkInterface LinkGoogle Faild"); + UnityLogoutGoogle(); + UnitySendMessage("TYSdkFacade","LinkAccoutResult", "0"); + } + }]; } - void UnityShowRVAD() + void IsLinkedGoogle() { + [XYApi CheckUserExist:XYBindGoodle completion:^(XYResp * _Nonnull resp) { + if (resp.errCode == XYSNSExist) { + UnitySendMessage("TYSdkFacade","CheckLinkResult", "1"); + }else if (resp.errCode == XYSNSNotExist){ + UnitySendMessage("TYSdkFacade","CheckLinkResult", "0"); + } else { + UnitySendMessage("TYSdkFacade","CheckLinkResult", "-1"); + } + }]; + } + void UnlinkGoogle() + { + + } + + void LinkFacebook(const int userId) + { + NSLog(@"TYSdkInterface LinkFacebook"); + NSDictionary * userDic = [XYApi XYGetCurrentUserDict]; + XYBindReq *bindReq = [XYBindReq initBindWithPlatform:XYBindFB UserId: [ [userDic objectForKey:@"userId"] unsignedIntegerValue]]; + [XYApi XYBindByBindReq:bindReq isUnbindGuest:@"false" completionHandler:^(XYResp * _Nonnull resp) { + if(resp.errCode == XYSuccess) + { + NSLog(@"TYSdkInterface LinkFacebook Success"); + UnitySendMessage("TYSdkFacade","LinkAccoutResult", "1"); + } + else + { + NSLog(@"TYSdkInterface LinkFacebook Faild"); + UnityLogoutFacebook(); + UnitySendMessage("TYSdkFacade","LinkAccoutResult", "0"); + + } + }]; + } + + void IsLinkedFacebook() + { + [XYApi CheckUserExist:XYBindFB completion:^(XYResp * _Nonnull resp) { + if (resp.errCode == XYSNSExist) { + UnitySendMessage("TYSdkFacade","CheckLinkResult", "1"); + }else if (resp.errCode == XYSNSNotExist){ + UnitySendMessage("TYSdkFacade","CheckLinkResult", "0"); + } else { + UnitySendMessage("TYSdkFacade","CheckLinkResult", "-1"); + } + }]; + } + + void UnlinkFacebook() + { + } } diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade.cs b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade.cs index 31e0704..b951f28 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using asap.core; using Newtonsoft.Json.Linq; @@ -21,18 +22,44 @@ namespace tysdk public string token; public string jwtToken; public string strUserId => userId.ToString(); - public string channelstr; - public EAccoutType channel => accoutTypeMap[channelstr]; + public string channelstr { + set{ + channel = accoutTypeMap[value]; + linkedAccout.Add(channel); + } + } + public HashSet linkedAccout = new HashSet(); + public EAccoutType channel {get; private set;} private const string KEY_ACCOUNT_INFO = "KEY_ACCOUNT_INFO"; + public void AddLinkedAccount(EAccoutType accoutType) + { + if (!linkedAccout.Contains(accoutType)) + { + linkedAccout.Add(accoutType); + } + } + + public void AddLinkedAccount(string channel) + { + if(accoutTypeMap.TryGetValue(channel, out var accoutType)) + { + if (!linkedAccout.Contains(accoutType)) + { + linkedAccout.Add(accoutType); + } + } + } + public void Save() { JObject jInfo = new JObject(); - jInfo["channel"] = channelstr; + jInfo["channel"] = accoutTypeMap.First(x => x.Value == channel).Key; jInfo["token"] = token; jInfo["userId"] = userId; jInfo["jwtToken"] = jwtToken; + jInfo["linkedAccout"] = string.Join(",", linkedAccout.Select(x => x.ToString())); PlayerPrefs.SetString(KEY_ACCOUNT_INFO, jInfo.ToString()); } @@ -52,6 +79,7 @@ namespace tysdk token = (string)jInfo["token"], channelstr = (string)jInfo["channel"], jwtToken = (string)jInfo["jwtToken"], + linkedAccout = jInfo["linkedAccout"].ToString().Split(',').Select(x => (EAccoutType)Enum.Parse(typeof(EAccoutType), x)).ToHashSet() }; } else @@ -62,7 +90,7 @@ namespace tysdk } private static AccountInfo _accountInfo; - public AccountInfo TYAccountInfo => _accountInfo; + public static AccountInfo TYAccountInfo => _accountInfo; private static IDictionary> callbacks = new Dictionary>(); @@ -177,16 +205,32 @@ namespace tysdk { var loginData = data["respObj"]["result"]; - _accountInfo = new AccountInfo() + 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) { - userId = (int)loginData["userId"], - token = (string)loginData["token"], - jwtToken = (string)loginData["jwttoken"], - channelstr = (string)loginData["loginChannelTypeC"] - }; - - _accountInfo.Save(); + _accountInfo = new AccountInfo() + { + userId = (int)loginData["userId"], + 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; + } result.isSuccess = true; result.userId = _accountInfo.userId; @@ -207,5 +251,71 @@ namespace tysdk UnityBridgeFunc.SetGaUserInfo(strUserId); } + + public async Task LinkAccount(EAccoutType accoutType) + { + if (_accountInfo == null) return false; + if( _accountInfo.linkedAccout.Contains(accoutType)) return true; + + var taskSource = new TaskCompletionSource(); + callbacks.Add("LoginResult", (ITYSdkCallback callback) => + { + taskSource.SetResult((LoginInfo)callback); + }); + + UnityBridgeFunc.LinkAccount(accoutType); + + var result = await taskSource.Task; + + return result.isSuccess; + } + + /// + /// 检查是否已经绑定 + /// + /// 1 已经绑定 + /// 0 未绑定 + /// -1 失败 + /// + /// + public async Task LinkCheck(EAccoutType accoutType) + { + if (_accountInfo == null) return false; + if( _accountInfo.linkedAccout.Contains(accoutType)) return true; + + var taskSource = new TaskCompletionSource(); + callbacks.Add("CheckLinkResult", (ITYSdkCallback callback) => + { + taskSource.SetResult((LinkCheckInfo)callback); + }); + + UnityBridgeFunc.LinkCheck(accoutType); + + var code = (await taskSource.Task).code; + + if (code == 1 && !_accountInfo.linkedAccout.Contains(accoutType)) + { + _accountInfo.linkedAccout.Add(accoutType); + _accountInfo.Save(); + } + + if(code == -1) + { + Debug.LogError("[TYSdkFacade] CheckLinkResult error"); + } + + return code == 1; + } + + public void CheckLinkResult(string codestr) + { + if (callbacks.TryGetValue("CheckLinkResult", out var action)) + { + var result = new LinkCheckInfo(); + result.code = int.Parse(codestr); + action.Invoke(result); + callbacks.Remove("CheckLinkResult"); + } + } } } diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs deleted file mode 100644 index 3522690..0000000 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using asap.core; -using Newtonsoft.Json.Linq; -using UnityEngine; - -namespace tysdk -{ - public partial class TYSdkFacade : MonoBehaviour - { - /*================================================ - - _ ____ - / \ | _ \ - / _ \ | | | | - / ___ \| |_| | - /_/ \_\____/ - - =================================================*/ - - public void InitAdCallback(string jstr) - { - try{ - var jobj = JObject.Parse(jstr); - if(jobj["code"].ToString() == "0") - UnityEngine.Debug.Log($"[TYSdkFacade] InitAdCallback Success"); - else - UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback Failed "); - } - catch(Exception e) - { - UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback error: {e.Message}"); - } - } - - public void LoadAdCallback(string jstr) - { - try - { - var adLoadinfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jstr); - GContext.Publish(adLoadinfo); - } - catch (Exception e) - { - UnityEngine.Debug.LogError($"[TYSdkFacade] LoadAdCallback error: {e.Message}"); - } - } - - public void ShowAdCallback(string jstr) - { - try - { - var adShowInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(jstr); - GContext.Publish(adShowInfo); - } - catch (Exception e) - { - UnityEngine.Debug.LogError($"[TYSdkFacade] ShowAdCallback error: {e.Message}"); - } - } - } -} \ No newline at end of file diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs.meta b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs.meta deleted file mode 100644 index d853aef..0000000 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_AD.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 179ddafea9354cadbfabca342e552139 -timeCreated: 1722855804 \ No newline at end of file diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_Pay.cs b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_Pay.cs index 6f5cf59..224c74f 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_Pay.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/TYSdkFacade_Pay.cs @@ -18,18 +18,26 @@ namespace tysdk |___/ =================================================*/ - public async Task Pay(string prodId, string prodPrice, string prodName, int count, string pType) + //public async Task Pay(string prodId, string prodPrice, string prodName, int count, string pType, string price_amount_micros =null) + public async Task Pay(SKUDetail prod, int count) { if (!IsLoggedIn) return new PaymentInfo() { code = "-1", msg = "未登录" }; var orderId = System.Guid.NewGuid().ToString(); - var extraDic = new Dictionary() { + + Dictionary extraDic = new Dictionary() { {"paytime" , System.DateTime.UtcNow.Ticks}, - {"sum" , float.Parse(prodPrice) * count}, + {"sum" , prod.ProdPrice * count}, }; + + string extraInfo = Newtonsoft.Json.JsonConvert.SerializeObject(extraDic); //to base64 extraInfo = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(extraInfo)); + var prodId = prod.ProdID; + var prodPrice = prod.price; + var prodName = prod.title; + var pType = "googleiab.global.app"; #if UNITY_EDITOR @@ -44,6 +52,7 @@ namespace tysdk price = prodPrice }; + return result; #elif UNITY_ANDROID @@ -52,7 +61,10 @@ namespace tysdk { taskSource.SetResult((PaymentInfo)callback); }); + + //UnityBridgeFunc.UnityKnow(prodId, prodName, count.ToString(), orderId, extraInfo); UnityBridgeFunc.UnityKnowNew(prodId, prodPrice, prodName, count.ToString(), orderId, extraInfo,pType); + var result = await taskSource.Task; result.count = count; result.orderId = orderId; diff --git a/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs b/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs index 909d2b0..ea1ed88 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs @@ -23,6 +23,11 @@ namespace tysdk public int code; } + public class LinkCheckInfo : ITYSdkCallback + { + public int code; + } + public class PaymentInfo : ITYSdkCallback { public bool isSuccess => code == "0"; @@ -56,7 +61,7 @@ namespace tysdk LocaleCurrencyCode = x["LocaleCurrencyCode"].ToString(), localeCurrencySymbol = x["localeCurrencySymbol"].ToString(), localizedDescription = x["localizedDescription"].ToString(), - localizedTitle = x["localizedTitle"].ToString() + title = x["localizedTitle"].ToString() }; }).ToList(); products = prodList; @@ -81,6 +86,10 @@ namespace tysdk { return Newtonsoft.Json.JsonConvert.SerializeObject(this); } + + public string ProdPriceStr => price; + public float ProdPrice => float.Parse(price_amount_micros) / 1000000; + public string ProdID => ourProductId; } #elif UNITY_IOS public class SKUDetail @@ -90,7 +99,12 @@ namespace tysdk public string LocaleCurrencyCode; public string localeCurrencySymbol; public string localizedDescription; - public string localizedTitle; + public string title; + public string type; + + public string ProdPriceStr => price; + public float ProdPrice => float.Parse(price); + public string ProdID => productId; public override string ToString() { @@ -104,41 +118,4 @@ namespace tysdk { public bool isAccepted; } - - public class ADLoadInfo - { - public bool isSuccess => code == "0"; - public string code; - public string errStr; - - public override string ToString() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - } - - public enum EShowAdState : byte - { - StartShow = 1, - Reward = 2, - Loading = 3, - LoadFaild = 4, - ShowFaild = 5, - Closed = 6, - Finished = 7, - TimeOut = 8 - } - - public class ShowADInfo - { - public string code; - public string message; - public string reward; - public EShowAdState state => (EShowAdState)int.Parse(code); - - public override string ToString() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - } } diff --git a/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs b/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs index bd0f0f5..1b6a050 100644 --- a/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs +++ b/sdk-intergration/Packages/tysdk/Runtime/UnityBridgeFunc.cs @@ -18,6 +18,9 @@ namespace tysdk //登录 public static void UnityLoginByTokenFun(string token){} public static void UnityLogin(EAccoutType accoutType){} + public static void LinkAccount(EAccoutType accoutType){} + public static void UnlinkAccount(EAccoutType accoutType){} + public static void LinkCheck(EAccoutType accoutType){} public static void UnityGetIdentityFun(string type){} @@ -27,8 +30,9 @@ namespace tysdk string productCount, string prodorderId, string appInfo, string pType) { } //支付 - public static void UnityKnow(string userId, string productId, string productPrice, string productName, - string productCount, string prodorderId, string appInfo){} + + public static void UnityKnow(String productId, String productName, String productCount, + String prodorderId, String appInfo) {} //获取商品列表 public static void GetSKUList() { } @@ -81,11 +85,9 @@ namespace tysdk public static void UnityLogin(EAccoutType accoutType) { - var typeName = GetLoginTypeName(accoutType); - Debug.LogError("typeName:::" + typeName); using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) { - sdkManager.CallStatic("UnityLogin", typeName); + sdkManager.CallStatic("UnityLogin", accoutType.ToString()); } } @@ -99,7 +101,36 @@ namespace tysdk public static void UnityLogOutByChannel(EAccoutType accoutType) { - sdkManager.CallStatic("UnityLogOutByChannel", accoutType.ToString()); + + using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) + { + sdkManager.CallStatic("UnityLogOutByChannel", accoutType.ToString()); + } + } + + public static void LinkAccount(EAccoutType accoutType) + { + using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) + { + string userId = TYSdkFacade.TYAccountInfo.strUserId; + sdkManager.CallStatic("LinkAccount", accoutType.ToString(), userId); + } + } + + public static void UnlinkAccount(EAccoutType accoutType) + { + using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) + { + sdkManager.CallStatic("UnlinkAccount", accoutType.ToString()); + } + } + + public static void LinkCheck(EAccoutType accoutType) + { + using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) + { + sdkManager.CallStatic("LinkCheck", accoutType.ToString()); + } } //支付new @@ -113,20 +144,21 @@ namespace tysdk productCount, prodorderId, appInfo,pType); } } + //支付 - public static void UnityKnow(string userId, string productId, string productPrice, string productName, - string productCount, string prodorderId, string appInfo) + + public static void UnityKnow(String productId, String productName, String productCount, String prodorderId, String appInfo) { using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) { - sdkManager.CallStatic("UnityKnow",userId, productId, productPrice, productName, - productCount, prodorderId, appInfo); + sdkManager.CallStatic("UnityKnow", productId, productName, productCount, prodorderId, appInfo); } } //获取商品列表 public static void GetSKUList() { + UnityEngine.Debug.Log("UnityBridgeFunc.GetSKUList()"); using(var sdkManager = new AndroidJavaClass(SDK_CLASS)) { sdkManager.CallStatic("thirdExtend"); @@ -231,6 +263,54 @@ namespace tysdk [DllImport("__Internal")] private static extern void UnityLogoutGuest(); + public static void LinkAccount(EAccoutType accoutType) + { + switch (accoutType) + { + case EAccoutType.hwGoogle: + LinkGoogle(); + break; + case EAccoutType.hwFacebook: + LinkFacebook(); + break; + } + } + + public static void UnlinkAccount(EAccoutType accoutType) + { + switch (accoutType) + { + case EAccoutType.hwGoogle: + UnlinkGoogle(); + break; + case EAccoutType.hwFacebook: + UnlinkFacebook(); + break; + } + } + + [DllImport("__Internal")] private static extern void LinkGoogle(); + [DllImport("__Internal")] private static extern void UnlinkGoogle(); + [DllImport("__Internal")] private static extern void LinkFacebook(); + [DllImport("__Internal")] private static extern void UnlinkFacebook(); + + public static void LinkCheck(EAccoutType accoutType) + { + switch (accoutType) + { + case EAccoutType.hwGoogle: + IsLinkedGoogle(); + break; + case EAccoutType.hwFacebook: + IsLinkedFacebook(); + break; + } + } + + [DllImport("__Internal")] private static extern void IsLinkedGoogle(); + [DllImport("__Internal")] private static extern void IsLinkedFacebook(); + + //支付 [DllImport("__Internal")] public static extern void UnityKnow(string userId, string productId, string productPrice, string productName, diff --git a/sdk-intergration/ProjectSettings/AndroidResolverDependencies.xml b/sdk-intergration/ProjectSettings/AndroidResolverDependencies.xml index 9816f96..cddc869 100644 --- a/sdk-intergration/ProjectSettings/AndroidResolverDependencies.xml +++ b/sdk-intergration/ProjectSettings/AndroidResolverDependencies.xml @@ -20,7 +20,7 @@ - + diff --git a/sdk-intergration/ProjectSettings/GvhProjectSettings.xml b/sdk-intergration/ProjectSettings/GvhProjectSettings.xml index d13f312..42602f6 100644 --- a/sdk-intergration/ProjectSettings/GvhProjectSettings.xml +++ b/sdk-intergration/ProjectSettings/GvhProjectSettings.xml @@ -1,4 +1,8 @@ + + + + \ No newline at end of file