移动taptapsdk到外部
parent
1789f84530
commit
d15c6f1849
|
|
@ -90,3 +90,4 @@ ProjectNLD/ServerData/
|
|||
/ProjectNLD/Assets/Editor/SkillEditor/Temp
|
||||
/ProjectNLD/Assets/Editor/SkillEditor/Temp.meta
|
||||
/ProjectNLD/.cache.meta
|
||||
ProjectNLD/Packages/packages-lock.json
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
"dependencies": {
|
||||
"com.code-philosophy.hybridclr": "http://1.14.122.170:3000/PHXH/hybridclr_unity.git",
|
||||
"com.cysharp.unitask": "http://1.14.122.170:3000/PHXH/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
|
||||
"com.taptap.tds.login":"http://1.14.122.170:3000/PHXH/TapLogin-Unity.git#3.23.0",
|
||||
"com.taptap.tds.common":"http://1.14.122.170:3000/PHXH/TapCommon-Unity.git#3.23.0",
|
||||
"com.taptap.tds.bootstrap":"http://1.14.122.170:3000/PHXH/TapBootstrap-Unity.git#3.23.0",
|
||||
"com.leancloud.realtime":"http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#realtime-1.0.2",
|
||||
"com.leancloud.storage":"http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#storage-1.0.2",
|
||||
"com.leancloud.realtime": "http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#realtime-1.0.2",
|
||||
"com.leancloud.storage": "http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#storage-1.0.2",
|
||||
"com.unity.2d.sprite": "1.0.0",
|
||||
"com.unity.2d.tilemap": "1.0.0",
|
||||
"com.unity.addressables": "1.21.18",
|
||||
|
|
|
|||
|
|
@ -1,528 +0,0 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"com.code-philosophy.hybridclr": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/hybridclr_unity.git",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "febff1c658fa9d76726f3aa25f26ec6d35c1e2e6"
|
||||
},
|
||||
"com.cysharp.unitask": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "5cc97c7f0085624b6ef57853d70b404440060cef"
|
||||
},
|
||||
"com.leancloud.realtime": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#realtime-1.0.2",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-1.0.2"
|
||||
},
|
||||
"hash": "73c70db9d89e6115776b05badb8239b655a5d212"
|
||||
},
|
||||
"com.leancloud.storage": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/csharp-sdk-upm.git#storage-1.0.2",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "beef2954fb0dbe2471952c34a32a5885a427ce9a"
|
||||
},
|
||||
"com.taptap.tds.bootstrap": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/TapBootstrap-Unity.git#3.23.0",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"com.taptap.tds.common": "https://github.com/TapTap/TapCommon-Unity.git#3.23.0",
|
||||
"com.taptap.tds.login": "https://github.com/TapTap/TapLogin-Unity.git#3.23.0",
|
||||
"com.leancloud.realtime": "https://github.com/leancloud/csharp-sdk-upm.git#realtime-0.10.14",
|
||||
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-0.10.14"
|
||||
},
|
||||
"hash": "6b25a2d15293009dc2f50db283f42b498eea38c6"
|
||||
},
|
||||
"com.taptap.tds.common": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/TapCommon-Unity.git#3.23.0",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-0.10.14"
|
||||
},
|
||||
"hash": "2d74f084c3a318d946da76e91cbc9b8255e0a864"
|
||||
},
|
||||
"com.taptap.tds.login": {
|
||||
"version": "http://1.14.122.170:3000/PHXH/TapLogin-Unity.git#3.23.0",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {
|
||||
"com.taptap.tds.common": "https://github.com/TapTap/TapCommon-Unity.git#3.23.0"
|
||||
},
|
||||
"hash": "82574596a23f20dc0ee537644c8d7b3676c14a55"
|
||||
},
|
||||
"com.unity.2d.sprite": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.2d.tilemap": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.tilemap": "1.0.0",
|
||||
"com.unity.modules.uielements": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.addressables": {
|
||||
"version": "1.21.18",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.scriptablebuildpipeline": "1.21.20",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.burst": {
|
||||
"version": "1.8.4",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.mathematics": "1.2.1"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.collections": {
|
||||
"version": "2.2.0",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.burst": "1.8.4",
|
||||
"com.unity.modules.unityanalytics": "1.0.0",
|
||||
"com.unity.nuget.mono-cecil": "1.11.4"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.editorcoroutines": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.26",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.22",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.inputsystem": {
|
||||
"version": "1.6.3",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.uielements": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.mathematics": {
|
||||
"version": "1.2.1",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.memoryprofiler": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.editorcoroutines": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.nuget.mono-cecil": {
|
||||
"version": "1.11.4",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.nuget.newtonsoft-json": {
|
||||
"version": "3.2.1",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.profiling.core": {
|
||||
"version": "1.0.2",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.render-pipelines.core": {
|
||||
"version": "14.0.8",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.render-pipelines.universal": {
|
||||
"version": "14.0.8",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.mathematics": "1.2.1",
|
||||
"com.unity.burst": "1.8.4",
|
||||
"com.unity.render-pipelines.core": "14.0.8",
|
||||
"com.unity.shadergraph": "14.0.8"
|
||||
}
|
||||
},
|
||||
"com.unity.scriptablebuildpipeline": {
|
||||
"version": "1.21.20",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.searcher": {
|
||||
"version": "4.9.2",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.shadergraph": {
|
||||
"version": "14.0.8",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.render-pipelines.core": "14.0.8",
|
||||
"com.unity.searcher": "4.9.2"
|
||||
}
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.33",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.textmeshpro": {
|
||||
"version": "3.0.6",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.7.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.director": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ai": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.androidjni": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.animation": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.assetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.audio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.cloth": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.director": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.imageconversion": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.imgui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.jsonserialize": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.particlesystem": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics2d": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.screencapture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.subsystems": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.terrain": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.terrainphysics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.tilemap": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics2d": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.uielements": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.umbra": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unityanalytics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequest": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestassetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestaudio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequesttexture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestwww": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestaudio": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vehicles": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.video": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.wind": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.xr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.subsystems": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,260 @@
|
|||
# ChangeLog
|
||||
## 3.11.1
|
||||
- TapTap.Login v3.11.1
|
||||
- TapTap.Common v3.11.1
|
||||
- LeanCloud.Realtime v0.10.11
|
||||
- LeanCloud.Storage v0.10.11
|
||||
|
||||
## 3.11.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.11.0
|
||||
- TapTap.Common v3.11.0
|
||||
- LeanCloud.Realtime v0.10.11
|
||||
- LeanCloud.Storage v0.10.11
|
||||
|
||||
## 3.10.0
|
||||
|
||||
### New Feature
|
||||
- 支持排行榜
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.10.0
|
||||
- TapTap.Common v3.10.0
|
||||
- LeanCloud.Realtime v0.10.11
|
||||
- LeanCloud.Storage v0.10.11
|
||||
|
||||
## 3.9.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.9.0
|
||||
- TapTap.Common v3.9.0
|
||||
- LeanCloud.Realtime v0.10.11
|
||||
- LeanCloud.Storage v0.10.11
|
||||
|
||||
## 3.8.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.8.0
|
||||
- TapTap.Common v3.8.0
|
||||
- LeanCloud.Realtime v0.10.10
|
||||
- LeanCloud.Storage v0.10.10
|
||||
|
||||
## 3.7.1
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.7.1
|
||||
- TapTap.Common v3.7.1
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.7.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.7.0
|
||||
- TapTap.Common v3.7.0
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
|
||||
## 3.6.3
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.6.3
|
||||
- TapTap.Common v3.6.3
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.6.1
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.6.1
|
||||
- TapTap.Common v3.6.1
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.6.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.6.0
|
||||
- TapTap.Common v3.6.0
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.5.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.5.0
|
||||
- TapTap.Common v3.5.0
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.4.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.4.0
|
||||
- TapTap.Common v3.4.0
|
||||
- LeanCloud.Realtime v0.10.0
|
||||
- LeanCloud.Storage v0.10.0
|
||||
|
||||
## 3.3.0
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.3.0
|
||||
- TapTap.Common v3.3.0
|
||||
- LeanCloud.Realtime v0.9.11
|
||||
- LeanCloud.Storage v0.9.11
|
||||
|
||||
## 3.2.0
|
||||
|
||||
### New Feature
|
||||
|
||||
- 支持云存档
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.2.0
|
||||
- TapTap.Common v3.2.0
|
||||
- LeanCloud.Storage v0.9.5
|
||||
- LeanCloud.Realtime v0.9.5
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### New Feature
|
||||
|
||||
- `TDSUser` 新增好友系统操作
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Login v3.1.0
|
||||
- TapTap.Common v3.1.0
|
||||
- LeanCloud.Storage v0.9.2
|
||||
- LeanCloud.Realtime v0.9.2
|
||||
|
||||
## 3.0.0
|
||||
|
||||
TapSDK 3.0 开始,我们在单纯的 TapTap 登录之外,还提供了一个内建账户系统供游戏使用:开发者可以直接用 TapTap OAuth
|
||||
授权的结果生成一个游戏内的账号(TDSUser),然后用该账号保存更多玩家数据。同时,我们也支持将更多第三方认证登录的结果绑定到这一账号上来(以及后续的解绑操作)。
|
||||
|
||||
### New Feature
|
||||
|
||||
- 新增 `TDSUser` 用于内建账户系统操作
|
||||
|
||||
### BreakingChange
|
||||
|
||||
- `TapBootstrap` 接口仅保留 `TapBootstrap.Init(tapConfig)` 接口
|
||||
|
||||
### Dependencies
|
||||
|
||||
- LeanCloud.Storage v0.8.2
|
||||
- TapTap.Login v3.0.0
|
||||
- TapTap.Common v3.0.0
|
||||
|
||||
## 2.1.7
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.7
|
||||
|
||||
## 2.1.6
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.6
|
||||
|
||||
## 2.1.5
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.5
|
||||
|
||||
## 2.1.4
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 优化多语言相关
|
||||
|
||||
### Dependencies
|
||||
|
||||
- TapTap.Common v2.1.4
|
||||
|
||||
## 2.1.3
|
||||
|
||||
### Feature
|
||||
|
||||
* 新增繁中、日文、韩文、泰文和印尼语多语言配置
|
||||
|
||||
## 2.1.2
|
||||
|
||||
### BreakingChange
|
||||
|
||||
* 废弃 OpenUserCenter 接口
|
||||
|
||||
### Dependencies
|
||||
|
||||
* TapTap.Common v2.1.2
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Feature
|
||||
|
||||
* 新增篝火测试资格校验
|
||||
```
|
||||
TapBootstrap.GetTestQualification((bool, error)=>{ }):
|
||||
```
|
||||
* 通过 TapConfig 进行初始化配置
|
||||
* 新增 TapDBConfig 用于 TapDB 初始化配置
|
||||
* 新增 ClientSecret 用于 TapSDK 初始化
|
||||
```c#
|
||||
//建议使用以下 TapConfig 构造方法进行初始化
|
||||
var config = new TapConfig.Builder()
|
||||
.ClientID("client_id")
|
||||
.ClientSecret("client_secret")
|
||||
.RegionType(RegionType.CN)
|
||||
.TapDBConfig(true, "gameChannel", "gameVersion", true)
|
||||
.ConfigBuilder();
|
||||
TapBootstrap.Init(config);
|
||||
```
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* LoginType 删除 Apple、Guest 登陆方式
|
||||
* TDS-Info.plist 删除 Apple_SignIn_Enable 配置
|
||||
* 废弃 Bind 接口
|
||||
* TapConfig 构造方法参数修改
|
||||
|
||||
### Dependencies
|
||||
|
||||
* TapTap.Common v2.1.1
|
||||
|
||||
## 2.1.0
|
||||
|
||||
### Feature
|
||||
|
||||
* 支持性改动用于 TapTap.Friends
|
||||
|
||||
### Dependencies
|
||||
|
||||
* TapTap.Common v2.1.0
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Feature
|
||||
|
||||
* TapTap Bootstrap
|
||||
|
||||
### Dependencies
|
||||
|
||||
* TapTap.Common v2.0.0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7388165be5344a9682382768c5fce466
|
||||
timeCreated: 1616755935
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd03b50332353477c899419b5b455fb0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,257 @@
|
|||
# 使用 TapTap.Bootstrap
|
||||
|
||||
## 使用前提
|
||||
|
||||
使用 TapTap.Bootstrap 前提是必须依赖以下库:
|
||||
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
|
||||
* [TapTap.Login](https://github.com/TapTap/TapLogin-Unity.git)
|
||||
* [LeanCloud.Storage](https://github.com/leancloud/csharp-sdk)
|
||||
* [LeanCloud.RealTime](https://github.com/leancloud/csharp-sdk)
|
||||
|
||||
## 命名空间
|
||||
|
||||
```c#
|
||||
using TapTap.Bootstrap;
|
||||
```
|
||||
|
||||
## 接口描述
|
||||
|
||||
## 1.初始化
|
||||
|
||||
TapBootstrap 会根据 TapConfig 中的 TapDBConfig 配置来进行 TapDB 的自动初始化。
|
||||
|
||||
### 开启 TapDB
|
||||
```c#
|
||||
var config = new TapConfig.Builder()
|
||||
.ClientID("client_id")
|
||||
.ClientToken("client_token")
|
||||
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
|
||||
.RegionType(RegionType.CN)
|
||||
.TapDBConfig(true,"channel","gameVersion",true)
|
||||
.Builder();
|
||||
```
|
||||
### 关闭 TapDB
|
||||
```c#
|
||||
var config = new TapConfig.Builder()
|
||||
.ClientID("client_id")
|
||||
.ClientToken("client_token")
|
||||
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
|
||||
.RegionType(RegionType.CN)
|
||||
//# .TapDBConfig(false,null,null,false)
|
||||
.EnableTapDB(false)
|
||||
.Builder();
|
||||
```
|
||||
### 初始化
|
||||
```c#
|
||||
TapBootstrap.Init(config);
|
||||
```
|
||||
|
||||
## 2.账户系统
|
||||
|
||||
> 登陆成功之后,都会得到一个 `TDSUser` 实例
|
||||
|
||||
### 使用 TapTap OAuth 授权结果直接登陆/注册账户系统
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginWithTapTap();
|
||||
```
|
||||
|
||||
### 游客登陆
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginAnonymously();
|
||||
```
|
||||
|
||||
### 使用第三方平台授权登录/注册账户
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
|
||||
LCUserAuthDataLoginOption option = null);
|
||||
```
|
||||
|
||||
### 绑定第三方平台授权
|
||||
|
||||
```c#
|
||||
await TDSUser.AssociateAuthData(Dictionary<string, object> authData, string platform);
|
||||
```
|
||||
|
||||
### 退出登陆
|
||||
|
||||
```c#
|
||||
TDSUser.Logout();
|
||||
```
|
||||
|
||||
## 3.好友系统
|
||||
|
||||
### 申请成为好友
|
||||
|
||||
```c#
|
||||
TDSUser tom, jerry;
|
||||
await tom.ApplyFriendship(jerry);
|
||||
```
|
||||
申请成功的回调中,我们会得到一个 LCFriendshipRequest 的实例,这个实例中包含了两个用户:
|
||||
- sourceUser,指请求的发起方,上面的例子中就是 `tom`。
|
||||
- friend,指请求的目的方,上面的例子中就是 `jerry`。
|
||||
|
||||
tom 也可以在申请好友的时候,添加更多的属性,例如 tom 希望加 jerry 为好友的时候,也设定一个名为 cat 的圈子,可以这样操作:
|
||||
|
||||
```cs
|
||||
Dictionary<string, object> attrs = new Dictionary<string, object> {
|
||||
{ "group", "cat" }
|
||||
};
|
||||
await tom.ApplyFriendship(jerry, attrs);
|
||||
```
|
||||
|
||||
### 获取好友申请列表
|
||||
好友申请有三种状态:
|
||||
|
||||
- `pending`,对方没有回应,还处于等待中。
|
||||
- `accepted`,对方已经接受,现在双方成为好友。
|
||||
- `declined`,对方已经拒绝。
|
||||
|
||||
好友请求创建之后默认是 `pending` 状态。
|
||||
|
||||
jerry 这里可以通过 `friendshipRequestQuery` 来查找不同状态的请求。例如 jerry 想看看新的好友请求,可以这样操作:
|
||||
|
||||
```cs
|
||||
LCQuery<LCFriendshipRequest> query = jerry.GetFriendshipRequestQuery(LCFriendshipRequest.STATUS_PENDING, false, true);
|
||||
ReadOnlyCollection<LCFriendshipRequest> reqs = await query.Find();
|
||||
foreach (LCFriendshipRequest req in reqs) {
|
||||
Console.WriteLine(req);
|
||||
}
|
||||
```
|
||||
|
||||
### 处理好友申请
|
||||
|
||||
jerry 对于新的好友请求,可以同意或者拒绝,也可以什么都不做,无视这些请求,甚至直接删除。这些操作我们都是支持的,请看下面的示例:
|
||||
|
||||
```cs
|
||||
LCFriendshipRequest tomRequest, tuffyRequest, otherRequest;
|
||||
await jerry.AcceptFriendshipRequest(tomRequest);
|
||||
await jerry.DeclineFriendshipRequest(tuffyRequest);
|
||||
await jerry.DeleteFriendshipRequest(otherRequest);
|
||||
```
|
||||
|
||||
注意:
|
||||
* 在 jerry 拒绝了 tom 的好友请求之后,如果 tom 再次请求成为 jerry 的好友,tom 在执行 applyFriendshipInBackground 时会直接得到错误的应答,表明 jerry 不想和 ta 成为好友。
|
||||
* jerry 同意了 tuffy 的好友请求之后,它们就成为了好友,之后两个人中任何一人再次调用 applyFriendshipInBackground 申请横位好友时,也会直接得到错误的应答,表明它们已经是好友无需再次申请。
|
||||
* jerry 删除陌生人的好友请求后,对方还可以再次发起请求。
|
||||
|
||||
### 响应好友变化通知
|
||||
|
||||
TDS 好友模块支持客户端监听好友状态变化,在游戏中实时给玩家提示。好友状态变化的接口包括
|
||||
|
||||
```cs
|
||||
public class FriendshipNotification {
|
||||
public Action<LCFriendshipRequest> OnNewRequestComing { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestAccepted { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestDeclined { get; set; }
|
||||
}
|
||||
```
|
||||
|
||||
其中:
|
||||
- onNewRequestComing 表示有其他人申请成为当前用户的好友,通过调用 `LCFriendshipRequest#getSourceUser()` 方法可以获得发起方用户信息。
|
||||
- onRequestAccepted 表示当前用户的好友申请被对方通过,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
|
||||
- onRequestDeclined 表示当前用户的好友申请被对方拒绝,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
|
||||
|
||||
开发者可以通过 `TDSUser#registerFriendshipNotification` 来注册通知接收器,通过调用 `TDSUser#unregisterFriendshipNotification` 来取消通知接收器。
|
||||
|
||||
### 获取好友列表
|
||||
|
||||
调用 `TDSUser#friendshipQuery()` 可以得到查询好友的 `LCQuery` 实例,之后调用 `LCQuery#findInBackground()` 方法就可以得到好友列表。示例如下:
|
||||
|
||||
```cs
|
||||
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
|
||||
```
|
||||
|
||||
LCFriendship 里面会包含两个用户:
|
||||
|
||||
- `LCFriendship#getLCUser(LCFriendship.ATTR_USER)` 得到的是 jerry 自己;
|
||||
- `LCFriendship#getLCUser(LCFriendship.ATTR_FOLLOWEE)` 得到的就是另一方的用户信息。
|
||||
|
||||
### 删除好友
|
||||
|
||||
成为好友关系的两个用户,之后也可以单方面删除好友。例如 jerry 不想再和 tom 成为好友,那只需要在自己的好友列表中删除包含 tom 的那条 LCFriendship 记录即可:
|
||||
|
||||
```cs
|
||||
await friendship.Delete();
|
||||
```
|
||||
|
||||
### 查询好友关系
|
||||
|
||||
我们使用 LCQuery 可以单独查询两个用户是否为好友关系。
|
||||
|
||||
```cs
|
||||
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
|
||||
query.whereEqualTo("followee", tom);
|
||||
int count = await query.Count();
|
||||
if (count > 0) {
|
||||
// tom is a friend of jerry.
|
||||
} else {
|
||||
// tom isn't a friend of jerry.
|
||||
}
|
||||
```
|
||||
|
||||
这一查询是通过网络发送到服务端执行的,一般情况下,我们推荐开发者在游戏启动时拉取一次当前登录用户的好友列表,然后缓存在本地,以后需要检查另外玩家是否为当前用户的好友时,直接从缓存中查询即可。如果担心好友数据变化,缓存没有得到及时更新,可以调用前面「响应好友变化通知」的方法,对好友数据更新进行监听,这样在绝大部分时候数据同步都是可以保证的。
|
||||
|
||||
## 4.云存档
|
||||
|
||||
### 构建云存档元数据
|
||||
|
||||
```c#
|
||||
var gameSave = new TapGameSave
|
||||
{
|
||||
Name = "GameSave_Name",// 存档名称
|
||||
Summary = "GameSave_Description", // 该字段会作为展示给用户的实际存档名
|
||||
ModifiedAt = DateTime.Now.ToLocalTime(), // 原文件修改时间
|
||||
PlayedTime = 1000L, // 游戏时长,单位 ms (非必填)
|
||||
ProgressValue = 100, // 游戏进度 ,单位 int (非必填)
|
||||
CoverFilePath = pic, // 游戏封面,可以传入一个本地文件路径,SDK 限制为 png/jpeg 格式
|
||||
GameFilePath = dll // 存档源文件,可以传入一个本地文件路径
|
||||
};
|
||||
|
||||
```
|
||||
### 保存存档
|
||||
|
||||
保存存档时,会去检查当前`TDSUser`是否已经登录以及元数据。
|
||||
|
||||
同时 SDK 在上传时会去限制存档本身以及相关联的两个文件( Cover 以及 GameFile )的权限为当前用户本身。
|
||||
```c#
|
||||
await gameSave.Save();
|
||||
```
|
||||
|
||||
### 查询当前用户的所有存档
|
||||
|
||||
```c#
|
||||
var collection = await TapGameSave.GetCurrentUserGameSaves();
|
||||
|
||||
foreach(var gameSave in collection){
|
||||
// 存档概览
|
||||
var name = gameSave.Summary;
|
||||
// 原文件修改时间
|
||||
var modifiedAt = gameSave.ModifiedAt;
|
||||
// 游戏时长
|
||||
var playedTime = gameSave.PlayedTime;
|
||||
// 游戏进度
|
||||
var progressValue = gameSave.ProgressValue;
|
||||
// 游戏封面
|
||||
var coverFile = gameSave.CoverFile;
|
||||
// 存档源文件
|
||||
var gameFile = gameSave.GameFile;
|
||||
// 源文件下载地址
|
||||
var gameFileUrl = gameFile.Url;
|
||||
}
|
||||
```
|
||||
|
||||
### 查询当前用户存档
|
||||
|
||||
我们使用 `LCQuery` 来查询当前用户的云存档。
|
||||
|
||||
SDK 查询封装了一个限定方法用于查询当前`TDSUser`的云存档。
|
||||
```c#
|
||||
TDSUser user = await TDSUser.GetCurrent();
|
||||
LCQuery<TapGameSave> gameSaveQuery = TapGameSave.GetQueryWithUser(user);
|
||||
// 查询 Name 为 TDSUser_GameSave_Name 的云存档
|
||||
gameSaveQuery.WhereEqualTo("name","TDSUser_GameSave_Name");
|
||||
var collection = await gameSaveQuery.Find();
|
||||
```
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 17ed6166c017a4fcda77ff618f2703db
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92ca05cc6fb3247f79cddb7f5ef08c2a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using TapTap.Common.Editor;
|
||||
|
||||
namespace TapTap.Bootstrap.Editor {
|
||||
public class TapBootstrapProcessBuild : SDKLinkProcessBuild {
|
||||
public override int callbackOrder => 0;
|
||||
|
||||
public override string LinkPath => "TapTap/Bootstrap/link.xml";
|
||||
|
||||
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
|
||||
new LinkedAssembly { Fullname = "TapTap.Bootstrap.Runtime" },
|
||||
};
|
||||
|
||||
public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
|
||||
return BuildTargetUtils.IsSupportMobile(report.summary.platform) ||
|
||||
BuildTargetUtils.IsSupportStandalone(report.summary.platform);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 395365d4e25e54d7cb6a461aa19b50c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.Bootstrap.Editor",
|
||||
"references": [
|
||||
"GUID:616cea76def2d4f059b94440fc8cc03d"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3cfcce84a61c740fc86ea125ab9c81e0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
# [使用 TapTap.Bootstrap ](./Documentation/README.md)
|
||||
|
||||
## 使用前提
|
||||
|
||||
使用 TapTap.Bootstrap 前提是必须依赖以下库:
|
||||
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
|
||||
* [TapTap.Login](https://github.com/TapTap/TapLogin-Unity.git)
|
||||
* [LeanCloud.Storage](https://github.com/leancloud/csharp-sdk)
|
||||
* [LeanCloud.RealTime](https://github.com/leancloud/csharp-sdk)
|
||||
|
||||
## 命名空间
|
||||
|
||||
```c#
|
||||
using TapTap.Bootstrap;
|
||||
```
|
||||
|
||||
## 接口描述
|
||||
|
||||
## 1.初始化
|
||||
|
||||
TapBootstrap 会根据 TapConfig 中的 TapDBConfig 配置来进行 TapDB 的自动初始化。
|
||||
|
||||
### 开启 TapDB
|
||||
```c#
|
||||
var config = new TapConfig.Builder()
|
||||
.ClientID("client_id")
|
||||
.ClientToken("client_token")
|
||||
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
|
||||
.RegionType(RegionType.CN)
|
||||
.TapDBConfig(true,"channel","gameVersion",true)
|
||||
.Builder();
|
||||
```
|
||||
### 关闭 TapDB
|
||||
```c#
|
||||
var config = new TapConfig.Builder()
|
||||
.ClientID("client_id")
|
||||
.ClientToken("client_token")
|
||||
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
|
||||
.RegionType(RegionType.CN)
|
||||
//# .TapDBConfig(false,null,null,false)
|
||||
.EnableTapDB(false)
|
||||
.Builder();
|
||||
```
|
||||
### 初始化
|
||||
```c#
|
||||
TapBootstrap.Init(config);
|
||||
```
|
||||
|
||||
## 2.账户系统
|
||||
|
||||
> 登陆成功之后,都会得到一个 `TDSUser` 实例
|
||||
|
||||
### 使用 TapTap OAuth 授权结果直接登陆/注册账户系统
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginWithTapTap();
|
||||
```
|
||||
|
||||
### 游客登陆
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginAnonymously();
|
||||
```
|
||||
|
||||
### 使用第三方平台授权登录/注册账户
|
||||
|
||||
```c#
|
||||
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
|
||||
LCUserAuthDataLoginOption option = null);
|
||||
```
|
||||
|
||||
### 绑定第三方平台授权
|
||||
|
||||
```c#
|
||||
await TDSUser.AssociateAuthData(Dictionary<string, object> authData, string platform);
|
||||
```
|
||||
|
||||
### 退出登陆
|
||||
|
||||
```c#
|
||||
TDSUser.Logout();
|
||||
```
|
||||
|
||||
## 3.好友系统
|
||||
|
||||
### 申请成为好友
|
||||
|
||||
```c#
|
||||
TDSUser tom, jerry;
|
||||
await tom.ApplyFriendship(jerry);
|
||||
```
|
||||
申请成功的回调中,我们会得到一个 LCFriendshipRequest 的实例,这个实例中包含了两个用户:
|
||||
- sourceUser,指请求的发起方,上面的例子中就是 `tom`。
|
||||
- friend,指请求的目的方,上面的例子中就是 `jerry`。
|
||||
|
||||
tom 也可以在申请好友的时候,添加更多的属性,例如 tom 希望加 jerry 为好友的时候,也设定一个名为 cat 的圈子,可以这样操作:
|
||||
|
||||
```cs
|
||||
Dictionary<string, object> attrs = new Dictionary<string, object> {
|
||||
{ "group", "cat" }
|
||||
};
|
||||
await tom.ApplyFriendship(jerry, attrs);
|
||||
```
|
||||
|
||||
### 获取好友申请列表
|
||||
好友申请有三种状态:
|
||||
|
||||
- `pending`,对方没有回应,还处于等待中。
|
||||
- `accepted`,对方已经接受,现在双方成为好友。
|
||||
- `declined`,对方已经拒绝。
|
||||
|
||||
好友请求创建之后默认是 `pending` 状态。
|
||||
|
||||
jerry 这里可以通过 `friendshipRequestQuery` 来查找不同状态的请求。例如 jerry 想看看新的好友请求,可以这样操作:
|
||||
|
||||
```cs
|
||||
LCQuery<LCFriendshipRequest> query = jerry.GetFriendshipRequestQuery(LCFriendshipRequest.STATUS_PENDING, false, true);
|
||||
ReadOnlyCollection<LCFriendshipRequest> reqs = await query.Find();
|
||||
foreach (LCFriendshipRequest req in reqs) {
|
||||
Console.WriteLine(req);
|
||||
}
|
||||
```
|
||||
|
||||
### 处理好友申请
|
||||
|
||||
jerry 对于新的好友请求,可以同意或者拒绝,也可以什么都不做,无视这些请求,甚至直接删除。这些操作我们都是支持的,请看下面的示例:
|
||||
|
||||
```cs
|
||||
LCFriendshipRequest tomRequest, tuffyRequest, otherRequest;
|
||||
await jerry.AcceptFriendshipRequest(tomRequest);
|
||||
await jerry.DeclineFriendshipRequest(tuffyRequest);
|
||||
await jerry.DeleteFriendshipRequest(otherRequest);
|
||||
```
|
||||
|
||||
注意:
|
||||
* 在 jerry 拒绝了 tom 的好友请求之后,如果 tom 再次请求成为 jerry 的好友,tom 在执行 applyFriendshipInBackground 时会直接得到错误的应答,表明 jerry 不想和 ta 成为好友。
|
||||
* jerry 同意了 tuffy 的好友请求之后,它们就成为了好友,之后两个人中任何一人再次调用 applyFriendshipInBackground 申请横位好友时,也会直接得到错误的应答,表明它们已经是好友无需再次申请。
|
||||
* jerry 删除陌生人的好友请求后,对方还可以再次发起请求。
|
||||
|
||||
### 响应好友变化通知
|
||||
|
||||
TDS 好友模块支持客户端监听好友状态变化,在游戏中实时给玩家提示。好友状态变化的接口包括
|
||||
|
||||
```cs
|
||||
public class FriendshipNotification {
|
||||
public Action<LCFriendshipRequest> OnNewRequestComing { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestAccepted { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestDeclined { get; set; }
|
||||
}
|
||||
```
|
||||
|
||||
其中:
|
||||
- onNewRequestComing 表示有其他人申请成为当前用户的好友,通过调用 `LCFriendshipRequest#getSourceUser()` 方法可以获得发起方用户信息。
|
||||
- onRequestAccepted 表示当前用户的好友申请被对方通过,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
|
||||
- onRequestDeclined 表示当前用户的好友申请被对方拒绝,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
|
||||
|
||||
开发者可以通过 `TDSUser#registerFriendshipNotification` 来注册通知接收器,通过调用 `TDSUser#unregisterFriendshipNotification` 来取消通知接收器。
|
||||
|
||||
### 获取好友列表
|
||||
|
||||
调用 `TDSUser#friendshipQuery()` 可以得到查询好友的 `LCQuery` 实例,之后调用 `LCQuery#findInBackground()` 方法就可以得到好友列表。示例如下:
|
||||
|
||||
```cs
|
||||
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
|
||||
```
|
||||
|
||||
LCFriendship 里面会包含两个用户:
|
||||
|
||||
- `LCFriendship#getLCUser(LCFriendship.ATTR_USER)` 得到的是 jerry 自己;
|
||||
- `LCFriendship#getLCUser(LCFriendship.ATTR_FOLLOWEE)` 得到的就是另一方的用户信息。
|
||||
|
||||
### 删除好友
|
||||
|
||||
成为好友关系的两个用户,之后也可以单方面删除好友。例如 jerry 不想再和 tom 成为好友,那只需要在自己的好友列表中删除包含 tom 的那条 LCFriendship 记录即可:
|
||||
|
||||
```cs
|
||||
await friendship.Delete();
|
||||
```
|
||||
|
||||
### 查询好友关系
|
||||
|
||||
我们使用 LCQuery 可以单独查询两个用户是否为好友关系。
|
||||
|
||||
```cs
|
||||
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
|
||||
query.whereEqualTo("followee", tom);
|
||||
int count = await query.Count();
|
||||
if (count > 0) {
|
||||
// tom is a friend of jerry.
|
||||
} else {
|
||||
// tom isn't a friend of jerry.
|
||||
}
|
||||
```
|
||||
|
||||
这一查询是通过网络发送到服务端执行的,一般情况下,我们推荐开发者在游戏启动时拉取一次当前登录用户的好友列表,然后缓存在本地,以后需要检查另外玩家是否为当前用户的好友时,直接从缓存中查询即可。如果担心好友数据变化,缓存没有得到及时更新,可以调用前面「响应好友变化通知」的方法,对好友数据更新进行监听,这样在绝大部分时候数据同步都是可以保证的。
|
||||
|
||||
## 4.云存档
|
||||
|
||||
### 构建云存档元数据
|
||||
|
||||
```c#
|
||||
var gameSave = new TapGameSave
|
||||
{
|
||||
Name = "GameSave_Name",// 存档名称
|
||||
Summary = "GameSave_Description", // 该字段会作为展示给用户的实际存档名
|
||||
ModifiedAt = DateTime.Now.ToLocalTime(), // 原文件修改时间
|
||||
PlayedTime = 1000L, // 游戏时长,单位 ms (非必填)
|
||||
ProgressValue = 100, // 游戏进度 ,单位 int (非必填)
|
||||
CoverFilePath = pic, // 游戏封面,可以传入一个本地文件路径,SDK 限制为 png/jpeg 格式
|
||||
GameFilePath = dll // 存档源文件,可以传入一个本地文件路径
|
||||
};
|
||||
|
||||
```
|
||||
### 保存存档
|
||||
|
||||
保存存档时,会去检查当前`TDSUser`是否已经登录以及元数据。
|
||||
|
||||
同时 SDK 在上传时会去限制存档本身以及相关联的两个文件( Cover 以及 GameFile )的权限为当前用户本身。
|
||||
```c#
|
||||
await gameSave.Save();
|
||||
```
|
||||
|
||||
### 查询当前用户的所有存档
|
||||
|
||||
```c#
|
||||
var collection = await TapGameSave.GetCurrentUserGameSaves();
|
||||
|
||||
foreach(var gameSave in collection){
|
||||
// 存档概览
|
||||
var name = gameSave.Summary;
|
||||
// 原文件修改时间
|
||||
var modifiedAt = gameSave.ModifiedAt;
|
||||
// 游戏时长
|
||||
var playedTime = gameSave.PlayedTime;
|
||||
// 游戏进度
|
||||
var progressValue = gameSave.ProgressValue;
|
||||
// 游戏封面
|
||||
var coverFile = gameSave.CoverFile;
|
||||
// 存档源文件
|
||||
var gameFile = gameSave.GameFile;
|
||||
// 源文件下载地址
|
||||
var gameFileUrl = gameFile.Url;
|
||||
}
|
||||
```
|
||||
|
||||
### 查询云存档
|
||||
云存档只能查询当前用户的所有存档,需要查询该用户的特定存档时,可以增加相应过滤,可参考 [查询条件](https://developer.taptap.com/docs/sdk/storage/guide/objc/#%E6%9F%A5%E8%AF%A2%E6%9D%A1%E4%BB%B6)
|
||||
```c#
|
||||
TDSUser user = await TDSUser.GetCurrent();
|
||||
LCQuery<TapGameSave> gameSaveQuery = TapGameSave.GetQueryWithUser(user);
|
||||
// 查询 Name 为 TDSUser_GameSave_Name 的云存档
|
||||
gameSaveQuery.WhereEqualTo("name","TDSUser_GameSave_Name");
|
||||
var collection = await gameSaveQuery.Find();
|
||||
```
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5330aab2c6a41699a1601f1af6b27d9
|
||||
timeCreated: 1616755935
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ff7a465ff38894e5c806c4c68b81994b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11618fe14bf534d1fa85a19c9cf8d5bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5787ee3104e1a4ebd9f25f9bd5a82523
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using LeanCloud;
|
||||
using LeanCloud.Storage;
|
||||
using TapTap.Common;
|
||||
using TapTap.Common.Internal.Init;
|
||||
|
||||
namespace TapTap.Bootstrap.Internal.Init {
|
||||
public class BootstrapInitTask : IInitTask {
|
||||
public int Order => 12;
|
||||
|
||||
public void Init(TapConfig config) {
|
||||
LCApplication.Initialize(config.ClientID, config.ClientToken, config.ServerURL);
|
||||
LCObject.RegisterSubclass("_User", () => new TDSUser());
|
||||
LCObject.RegisterSubclass(TapGameSave.CLASS_NAME, () => new TapGameSave());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5ad7914a84cf410e898068636f3790f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using LeanCloud.Common;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace TapTap.Bootstrap.@internal
|
||||
{
|
||||
public class TDSLeaderBoardRankingService
|
||||
{
|
||||
public TDSLeaderBoardRankingService()
|
||||
{
|
||||
}
|
||||
|
||||
public static async Task<ReadOnlyCollection<TDSLeaderBoardRanking>> QueryList(string name,
|
||||
int from, int limit)
|
||||
{
|
||||
string api = "/friend/v2/taptap/leadboard";
|
||||
Dictionary<string, object> queryParams = new Dictionary<string, object>
|
||||
{
|
||||
{"type", name },
|
||||
{"skip", from },
|
||||
{"limit", limit }
|
||||
};
|
||||
Dictionary<string, object> response = await LCCore.HttpClient.Get<Dictionary<string, object>>(api,
|
||||
queryParams: queryParams, withAPIVersion: false);
|
||||
if (response.TryGetValue("results", out object resultObj) && resultObj is List<object> results)
|
||||
{
|
||||
return results.Cast<Dictionary<string, object>>()
|
||||
.Select(item => {
|
||||
return new TDSLeaderBoardRanking(item);
|
||||
}).ToList().AsReadOnly();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 645b957e90a0842298583193473e506f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using LeanCloud.Common;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using TapTap.Common;
|
||||
using TapTap.Login;
|
||||
|
||||
namespace TapTap.Bootstrap.@internal
|
||||
{
|
||||
public class TDSUserEventTrigger
|
||||
{
|
||||
private static bool tdsUserLogin;
|
||||
|
||||
public static void TriggerLoginInfo(TDSUser tdsUser) {
|
||||
if (!tdsUserLogin && tdsUser != null && !string.IsNullOrEmpty(tdsUser.ObjectId)) {
|
||||
TriggerLoginInfo(UnityTDSUser.TDS_CHANNEL, tdsUser.ObjectId);
|
||||
tdsUserLogin = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void TriggerLoginInfo(string platform, string userId) {
|
||||
if (string.IsNullOrEmpty(platform) || string.IsNullOrEmpty(userId)) return;
|
||||
if (platform.Equals("taptap".ToLower())) platform = UnityTDSUser.TDS_CHANNEL;
|
||||
EventManager.TriggerEvent(EventConst.OnTapLogin, new KeyValuePair<string, string>(platform, userId));
|
||||
}
|
||||
|
||||
|
||||
public static void TriggerLogoutInfo(string platform) {
|
||||
EventManager.TriggerEvent(EventConst.OnTapLogout, platform);
|
||||
tdsUserLogin = false;
|
||||
}
|
||||
|
||||
public static void TriggerBindInfo(string platform, string userId) {
|
||||
if (string.IsNullOrEmpty(platform) || string.IsNullOrEmpty(userId)) return;
|
||||
if (platform.Equals("taptap".ToLower())) platform = UnityTDSUser.TDS_CHANNEL;
|
||||
EventManager.TriggerEvent(EventConst.OnBind, new KeyValuePair<string, string>(platform, userId));
|
||||
}
|
||||
|
||||
public static void TriggerUnbindInfo(string platform) {
|
||||
if (string.IsNullOrEmpty(platform)) return;
|
||||
if (platform.Equals("taptap".ToLower())) platform = UnityTDSUser.TDS_CHANNEL;
|
||||
EventManager.TriggerEvent(EventConst.OnUnbind, platform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e9b209f0f3604d809035b0ac2ddd7a5b
|
||||
timeCreated: 1692241103
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d4d24a39c0c00462f92614f8c3eac3d0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public interface ITapBootstrap
|
||||
{
|
||||
void Init(TapConfig config);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b7e098f3b3504e6e80966d9b6be1131
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LeanCloud.Storage.Internal.Object;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using TapTap.Bootstrap.@internal;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public class TDSLeaderBoardRanking
|
||||
{
|
||||
public string StatisticName
|
||||
{
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public int StatisticValue
|
||||
{
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public int Rank
|
||||
{
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public TDSUser User
|
||||
{
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
internal TDSLeaderBoardRanking(Dictionary<string,object> data)
|
||||
{
|
||||
|
||||
StatisticName = data["statisticName"] as string;
|
||||
StatisticValue = Convert.ToInt32(data["statisticValue"]);
|
||||
Rank = Convert.ToInt32(data["rank"]);
|
||||
TDSUser tdsUser = TDSUser.Create(TDSUser.CLASS_NAME) as TDSUser;
|
||||
if (data.TryGetValue("user", out object userObj) &&
|
||||
userObj is Dictionary<string, object> userDict)
|
||||
{
|
||||
tdsUser.Merge(LCObjectData.Decode(userDict));
|
||||
}
|
||||
User = tdsUser;
|
||||
|
||||
}
|
||||
|
||||
public static async Task<ReadOnlyCollection<TDSLeaderBoardRanking>> QueryTapFriendsLeaderBoard(string name,
|
||||
int from, int limit)
|
||||
{
|
||||
return await TDSLeaderBoardRankingService.QueryList(name, from, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23d637800a62a4ecdbfff2cf39446485
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,408 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LeanCloud.Storage;
|
||||
using LeanCloud.LiveQuery;
|
||||
using TapTap.Common;
|
||||
using TapTap.Bootstrap.@internal;
|
||||
using TapTap.Login;
|
||||
using TapTap.Login.Internal;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public class TDSUser : LCUser {
|
||||
public new string Password {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public new string Email {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public new string Mobile {
|
||||
get { throw new NotImplementedException(); }
|
||||
set { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public new bool EmailVerified {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public new bool MobileVerified {
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public new Task<TDSUser> SignUp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestLoginSMSCode(string mobile) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task<TDSUser> SignUpOrLoginByMobilePhone(string mobile, string code) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task<TDSUser> Login(string username, string password) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task<TDSUser> LoginByEmail(string email, string password) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task<TDSUser> LoginByMobilePhoneNumber(string mobile, string password) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task<TDSUser> LoginBySMSCode(string mobile, string code) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestEmailVerify(string email) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestMobilePhoneVerify(string mobile) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task VerifyMobilePhone(string mobile, string code) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestPasswordReset(string email) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestPasswordResetBySmsCode(string mobile) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task ResetPasswordBySmsCode(string mobile, string code, string newPassword) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public new Task UpdatePassword(string oldPassword, string newPassword) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task RequestSMSCodeForUpdatingPhoneNumber(string mobile, int ttl = 360,
|
||||
string captchaToken = null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static new Task VerifyCodeForUpdatingPhoneNumber(string mobile, string code) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#region API
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently logged in TDSUser with a valid session, from
|
||||
/// memory or disk if necessary.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static new async Task<TDSUser> GetCurrent() {
|
||||
LCUser user = await LCUser.GetCurrent();
|
||||
var result = user as TDSUser;
|
||||
TDSUserEventTrigger.TriggerLoginInfo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signs in a user with a sessionToken.
|
||||
/// </summary>
|
||||
/// <param name="sessionToken"></param>
|
||||
/// <returns></returns>
|
||||
public static new async Task<TDSUser> BecomeWithSessionToken(string sessionToken) {
|
||||
return (await LCUser.BecomeWithSessionToken(sessionToken)) as TDSUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signs in a user with a sessionToken for XDSDK.
|
||||
/// </summary>
|
||||
/// <param name="sessionToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<TDSUser> LoginWithSessionToken(string sessionToken) {
|
||||
var result = (await LCUser.BecomeWithSessionToken(sessionToken)) as TDSUser;
|
||||
TDSUserEventTrigger.TriggerLoginInfo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signs up or signs in a user with third party authData.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
/// <param name="option"></param>
|
||||
/// <returns></returns>
|
||||
public static new async Task<TDSUser> LoginWithAuthData(Dictionary<string, object> authData, string platform,
|
||||
LCUserAuthDataLoginOption option = null) {
|
||||
var result = (await LCUser.LoginWithAuthData(authData, platform, option)) as TDSUser;
|
||||
TDSUserEventTrigger.TriggerLoginInfo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public new Task AssociateAuthData(Dictionary<string, object> authData, string platform) {
|
||||
var result = base.AssociateAuthData(authData, platform);
|
||||
TDSUserEventTrigger.TriggerBindInfo(platform, ObjectId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public new Task AssociateAuthDataAndUnionId(Dictionary<string, object> authData,
|
||||
string platform,
|
||||
string unionId,
|
||||
LCUserAuthDataLoginOption option = null) {
|
||||
var result = base.AssociateAuthDataAndUnionId(authData, platform, unionId, option);
|
||||
TDSUserEventTrigger.TriggerBindInfo(platform, ObjectId);
|
||||
return result;
|
||||
}
|
||||
|
||||
public new Task DisassociateWithAuthData(string platform) {
|
||||
var result = base.DisassociateWithAuthData(platform);
|
||||
TDSUserEventTrigger.TriggerUnbindInfo(platform);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Signs up or signs in a user with third party authData and unionId.
|
||||
/// </summary>
|
||||
/// <param name="authData"></param>
|
||||
/// <param name="platform"></param>
|
||||
/// <param name="unionId"></param>
|
||||
/// <param name="option"></param>
|
||||
/// <returns></returns>
|
||||
public static new async Task<TDSUser> LoginWithAuthDataAndUnionId(Dictionary<string, object> authData,
|
||||
string platform, string unionId,
|
||||
LCUserAuthDataLoginOption option = null) {
|
||||
var result = (await LCUser.LoginWithAuthDataAndUnionId(authData, platform, unionId, option)) as TDSUser;
|
||||
TDSUserEventTrigger.TriggerLoginInfo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an anonymous user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static new async Task<TDSUser> LoginAnonymously() {
|
||||
var result = (await LCUser.LoginAnonymously()) as TDSUser;
|
||||
TDSUserEventTrigger.TriggerLoginInfo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signs up or signs in a user with TapTap.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task<TDSUser> LoginWithTapTap(string[] permissions = null) {
|
||||
Dictionary<string, object> authData = await LoginTapTap(permissions);
|
||||
LCUser user = await LoginWithAuthData(authData, "taptap");
|
||||
TDSUserEventTrigger.TriggerLoginInfo(user as TDSUser);
|
||||
return user as TDSUser;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs out the currently logged in user session.
|
||||
/// </summary>
|
||||
public static new async Task Logout() {
|
||||
TapLogin.Logout();
|
||||
TDSUserEventTrigger.TriggerLogoutInfo(UnityTDSUser.TDS_CHANNEL);
|
||||
await LCUser.Logout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a LCQuery for TDSUser.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static new LCQuery<TDSUser> GetQuery() {
|
||||
return new LCQuery<TDSUser>(CLASS_NAME);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save this user to the cloud.
|
||||
/// </summary>
|
||||
/// <param name="fetchWhenSave"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
public new async Task<TDSUser> Save(bool fetchWhenSave = false, LCQuery<LCObject> query = null) {
|
||||
return (await base.Save(fetchWhenSave, query)) as TDSUser;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static async Task<Dictionary<string, object>> LoginTapTap(string[] permissions) {
|
||||
AccessToken token;
|
||||
if (permissions == null) {
|
||||
token = await TapLogin.Login();
|
||||
} else {
|
||||
token = await TapLogin.Login(permissions);
|
||||
}
|
||||
|
||||
var profile = await TapLogin.GetProfile();
|
||||
|
||||
var result = new Dictionary<string, object>
|
||||
{
|
||||
{"kid", token.kid},
|
||||
{"access_token", token.accessToken},
|
||||
{"token_type", token.tokenType},
|
||||
{"mac_key", token.macKey},
|
||||
{"mac_algorithm", token.macAlgorithm},
|
||||
|
||||
{"openid", profile.openid},
|
||||
{"name", profile.name},
|
||||
{"avatar", profile.avatar},
|
||||
{"unionid", profile.unionid}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
#region Friendship
|
||||
|
||||
public class FriendshipNotification {
|
||||
public Action<LCFriendshipRequest> OnNewRequestComing { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestAccepted { get; set; }
|
||||
public Action<LCFriendshipRequest> OnRequestDeclined { get; set; }
|
||||
}
|
||||
|
||||
private LCLiveQuery friendshipLivequery;
|
||||
|
||||
public Task ApplyFriendship(TDSUser user, Dictionary<string, object> attributes = null) {
|
||||
if (user == null || string.IsNullOrEmpty(user.ObjectId)) {
|
||||
throw new ArgumentNullException("User or userId is null.");
|
||||
}
|
||||
return ApplyFriendship(user.ObjectId, attributes);
|
||||
}
|
||||
|
||||
public Task ApplyFriendship(string userId, Dictionary<string, object> attributes = null) {
|
||||
if (string.IsNullOrEmpty(userId)) {
|
||||
throw new ArgumentNullException(nameof(userId));
|
||||
}
|
||||
return LCFriendship.Request(userId, attributes);
|
||||
}
|
||||
|
||||
public Task AcceptFriendshipRequest(LCFriendshipRequest request, Dictionary<string, object> attributes = null) {
|
||||
if (request == null) {
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
return LCFriendship.AcceptRequest(request, attributes);
|
||||
}
|
||||
|
||||
public Task DeclineFriendshipRequest(LCFriendshipRequest request) {
|
||||
if (request == null) {
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
return LCFriendship.DeclineRequest(request);
|
||||
}
|
||||
|
||||
public Task DeleteFriendshipRequest(LCFriendshipRequest request) {
|
||||
if (request == null) {
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
return request.Delete();
|
||||
}
|
||||
|
||||
public LCQuery<LCFriendshipRequest> GetFriendshipRequestQuery(int status, bool includeTargetUser, bool reachToCurrentUser) {
|
||||
List<string> statusList = new List<string>();
|
||||
if ((status & LCFriendshipRequest.STATUS_PENDING) == LCFriendshipRequest.STATUS_PENDING) {
|
||||
statusList.Add("pending");
|
||||
}
|
||||
if ((status & LCFriendshipRequest.STATUS_ACCEPTED) == LCFriendshipRequest.STATUS_ACCEPTED) {
|
||||
statusList.Add("accepted");
|
||||
}
|
||||
if ((status & LCFriendshipRequest.STATUS_DECLINED) == LCFriendshipRequest.STATUS_DECLINED) {
|
||||
statusList.Add("declined");
|
||||
}
|
||||
if (statusList.Count < 1) {
|
||||
throw new ArgumentException("status is invalid.");
|
||||
}
|
||||
|
||||
LCQuery<LCFriendshipRequest> query = LCFriendshipRequest.GetQuery();
|
||||
query.WhereContainedIn("status", statusList);
|
||||
if (reachToCurrentUser) {
|
||||
query.WhereEqualTo("friend", this);
|
||||
if (includeTargetUser) {
|
||||
query.Include("user");
|
||||
}
|
||||
} else {
|
||||
query.WhereEqualTo("user", this);
|
||||
if (includeTargetUser) {
|
||||
query.Include("friend");
|
||||
}
|
||||
}
|
||||
query.AddDescendingOrder("updatedAt");
|
||||
return query;
|
||||
}
|
||||
|
||||
public LCQuery<LCObject> GetFriendshipQuery() {
|
||||
return FriendshipQuery();
|
||||
}
|
||||
|
||||
|
||||
public async Task RegisterFriendshipNotification(FriendshipNotification notification) {
|
||||
if (friendshipLivequery != null) {
|
||||
// 避免重复注册
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建 LiveQuery
|
||||
LCQuery<LCFriendshipRequest> selfRequestQuery = new LCQuery<LCFriendshipRequest>(LCFriendshipRequest.CLASS_NAME)
|
||||
.WhereEqualTo("user", this);
|
||||
LCQuery<LCFriendshipRequest> otherRequestQuery = new LCQuery<LCFriendshipRequest>(LCFriendshipRequest.CLASS_NAME)
|
||||
.WhereEqualTo("friend", this);
|
||||
LCQuery<LCFriendshipRequest> allQuery = LCQuery<LCFriendshipRequest>.Or(new LCQuery<LCFriendshipRequest>[] {
|
||||
selfRequestQuery, otherRequestQuery
|
||||
});
|
||||
|
||||
friendshipLivequery = await allQuery.Subscribe();
|
||||
friendshipLivequery.OnCreate = obj => {
|
||||
if (!(obj is LCFriendshipRequest req)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LCUser friend = req.Friend;
|
||||
if (friend == null || friend.ObjectId != ObjectId) {
|
||||
return;
|
||||
}
|
||||
|
||||
notification.OnNewRequestComing(req);
|
||||
};
|
||||
friendshipLivequery.OnUpdate = (obj, keys) => {
|
||||
if (!(obj is LCFriendshipRequest req)) {
|
||||
return;
|
||||
}
|
||||
if (keys == null || !keys.Contains("status")) {
|
||||
return;
|
||||
}
|
||||
|
||||
LCUser user = req.User;
|
||||
if (user == null || user.ObjectId != ObjectId) {
|
||||
return;
|
||||
}
|
||||
|
||||
string status = req.Status;
|
||||
if (status == "accepted") {
|
||||
notification.OnRequestAccepted(req);
|
||||
} else if (status == "declined") {
|
||||
notification.OnRequestDeclined(req);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task UnregisterFriendshipNotification() {
|
||||
if (friendshipLivequery == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await friendshipLivequery.Unsubscribe();
|
||||
friendshipLivequery = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 62c37df89e7e848a0b8133d5a4e0bcc8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using TapTap.Common;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public class TapBootstrap
|
||||
{
|
||||
public static void Init(TapConfig tapConfig)
|
||||
{
|
||||
TapBootstrapImpl.GetInstance().Init(tapConfig);
|
||||
}
|
||||
|
||||
public static void SetPreferredLanguage(TapLanguage language)
|
||||
{
|
||||
TapCommon.SetLanguage(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b97116f83686249a9a4a9d6eb5400170
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using LeanCloud.Storage;
|
||||
using TapTap.Common;
|
||||
using TapTap.Common.Internal.Init;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public class TapBootstrapImpl : ITapBootstrap
|
||||
{
|
||||
private static volatile TapBootstrapImpl _sInstance;
|
||||
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
public static TapBootstrapImpl GetInstance()
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
if (_sInstance == null)
|
||||
{
|
||||
_sInstance = new TapBootstrapImpl();
|
||||
}
|
||||
}
|
||||
return _sInstance;
|
||||
}
|
||||
|
||||
public async void Init(TapConfig config)
|
||||
{
|
||||
// 初始化各个模块
|
||||
Type interfaceType = typeof(IInitTask);
|
||||
Type[] initTaskTypes = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.Where(asssembly => asssembly.GetName().FullName.StartsWith("TapTap"))
|
||||
.SelectMany(assembly => assembly.GetTypes())
|
||||
.Where(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass)
|
||||
.ToArray();
|
||||
if (initTaskTypes != null) {
|
||||
List<IInitTask> initTasks = new List<IInitTask>();
|
||||
foreach (Type initTaskType in initTaskTypes) {
|
||||
initTasks.Add(Activator.CreateInstance(initTaskType) as IInitTask);
|
||||
}
|
||||
initTasks = initTasks.OrderBy(task => task.Order).ToList();
|
||||
foreach (IInitTask task in initTasks) {
|
||||
TapLogger.Debug($"Init: {task.GetType().Name}");
|
||||
task.Init(config);
|
||||
}
|
||||
}
|
||||
|
||||
TapCommon.SetXua();
|
||||
|
||||
await TDSUser.GetCurrent();
|
||||
|
||||
TapCommon.RegisterProperties("sessionToken", new SessionTokenProperty());
|
||||
|
||||
TapCommon.RegisterProperties("objectId", new ObjectIdProperty());
|
||||
|
||||
}
|
||||
|
||||
private class SessionTokenProperty : ITapPropertiesProxy
|
||||
{
|
||||
public string GetProperties()
|
||||
{
|
||||
Debug.Log($"sessionToken User:{GetCurrentUser()}");
|
||||
var sessionToken = GetCurrentUser()?.SessionToken;
|
||||
return string.IsNullOrEmpty(sessionToken) ? "" : sessionToken;
|
||||
}
|
||||
}
|
||||
|
||||
private class ObjectIdProperty : ITapPropertiesProxy
|
||||
{
|
||||
public string GetProperties()
|
||||
{
|
||||
Debug.Log($"objectId User:{GetCurrentUser()}");
|
||||
var objectId = GetCurrentUser()?.ObjectId;
|
||||
return string.IsNullOrEmpty(objectId) ? "" : objectId;
|
||||
}
|
||||
}
|
||||
|
||||
private static LCUser GetCurrentUser()
|
||||
{
|
||||
var field = typeof(LCUser).GetField("currentUser", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
return field?.GetValue(new LCUser()) as LCUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fde65756640e24079982b9077782ed28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using LeanCloud.Storage;
|
||||
|
||||
namespace TapTap.Bootstrap
|
||||
{
|
||||
public class TapGameSave : LCObject
|
||||
{
|
||||
public const string CLASS_NAME = "_GameSave";
|
||||
|
||||
private const string PATH_PREFIX = "gamesaves";
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => this["name"] as string;
|
||||
set => this["name"] = value;
|
||||
}
|
||||
|
||||
public string Summary
|
||||
{
|
||||
get => this["summary"] as string;
|
||||
set => this["summary"] = value;
|
||||
}
|
||||
|
||||
public DateTime ModifiedAt
|
||||
{
|
||||
get => this["modifiedAt"] is DateTime ? (DateTime) this["modifiedAt"] : default;
|
||||
set => this["modifiedAt"] = value;
|
||||
}
|
||||
|
||||
public double PlayedTime
|
||||
{
|
||||
get => this["playedTime"] is double ? (double) this["playedTime"] : -1d;
|
||||
set => this["playedTime"] = value;
|
||||
}
|
||||
|
||||
public int ProgressValue
|
||||
{
|
||||
get => this["progressValue"] is int ? (int) this["progressValue"] : -1;
|
||||
set => this["progressValue"] = value;
|
||||
}
|
||||
|
||||
public LCFile Cover
|
||||
{
|
||||
get => this["cover"] as LCFile;
|
||||
}
|
||||
|
||||
public LCFile GameFile
|
||||
{
|
||||
get => this["gameFile"] as LCFile;
|
||||
}
|
||||
|
||||
public LCUser User
|
||||
{
|
||||
set => this["user"] = value;
|
||||
}
|
||||
|
||||
public string CoverFilePath
|
||||
{
|
||||
set => this["cover"] = new LCFile(Path.GetFileName(value), value);
|
||||
}
|
||||
|
||||
public string GameFilePath
|
||||
{
|
||||
set => this["gameFile"] = new LCFile(Path.GetFileName(value), value);
|
||||
}
|
||||
|
||||
private void CheckArguments()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name)) throw new ArgumentNullException(nameof(Name));
|
||||
if (string.IsNullOrEmpty(Summary)) throw new ArgumentNullException(nameof(Summary));
|
||||
if (Summary.Length > 1000) throw new ArgumentOutOfRangeException(nameof(Summary));
|
||||
if (GameFile == null) throw new ArgumentNullException(nameof(GameFile));
|
||||
if (Cover == null) return;
|
||||
}
|
||||
|
||||
private static class GameSaveMimeType
|
||||
{
|
||||
internal static readonly List<string> SupportImageMimeType = new List<string>
|
||||
{
|
||||
"image/png", "image/jpeg"
|
||||
};
|
||||
}
|
||||
|
||||
public TapGameSave()
|
||||
: base(CLASS_NAME)
|
||||
{
|
||||
}
|
||||
|
||||
#region API
|
||||
|
||||
/// <summary>
|
||||
/// Save a GameSave to cloud for Current User.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<TapGameSave> Save()
|
||||
{
|
||||
var currentUser = await LCUser.GetCurrent();
|
||||
if (currentUser == null) throw new UnauthorizedAccessException("Not Login");
|
||||
CheckArguments();
|
||||
var acl = new LCACL();
|
||||
acl.SetUserWriteAccess(currentUser, true);
|
||||
acl.SetUserReadAccess(currentUser, true);
|
||||
ACL = acl;
|
||||
User = currentUser;
|
||||
if (Cover != null)
|
||||
{
|
||||
Cover.ACL = acl;
|
||||
Cover.PathPrefix = PATH_PREFIX;
|
||||
}
|
||||
|
||||
GameFile.ACL = acl;
|
||||
GameFile.PathPrefix = PATH_PREFIX;
|
||||
return await base.Save() as TapGameSave;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all GameSave by Current User.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static async Task<ReadOnlyCollection<TapGameSave>> GetCurrentUserGameSaves()
|
||||
{
|
||||
var user = await LCUser.GetCurrent();
|
||||
if (user == null) throw new UnauthorizedAccessException("Not Login");
|
||||
return await GetQueryWithUser(user).Find();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor a LCQuery for GameSave.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static LCQuery<TapGameSave> GetQuery() => new LCQuery<TapGameSave>(CLASS_NAME);
|
||||
|
||||
/// <summary>
|
||||
/// Constructor a LCQuery for GameSave with LCUser
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static LCQuery<TapGameSave> GetQueryWithUser(LCUser user)
|
||||
{
|
||||
var query = GetQuery();
|
||||
query.Include("cover");
|
||||
query.Include("gameFile");
|
||||
query.WhereEqualTo("user", user);
|
||||
return query;
|
||||
}
|
||||
|
||||
#endregion API
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ec803f6b9bcc04c97aebbba198757ef4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "TapTap.Bootstrap.Runtime",
|
||||
"references": [
|
||||
"GUID:e8754b6153389406c963cd52996cc80f",
|
||||
"GUID:0b3f64ec33f5b4da98a17367a35b82f2"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ab0f87386c0640798a09051c047d4ab
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d5391b17003874fb2afc3e309a3f63ef
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "com.taptap.tds.bootstrap",
|
||||
"displayName": "TapTap Bootstrap",
|
||||
"description": "TapTap Develop Service",
|
||||
"version": "3.26.2",
|
||||
"unity": "2019.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"com.taptap.tds.login": "3.26.2",
|
||||
"com.leancloud.realtime": "2.3.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e618b9375caf846708cffea428908521
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
# ChangeLog
|
||||
|
||||
## 3.11.1
|
||||
|
||||
### Fixed bugs
|
||||
- iOS: 修复授权模块对系统 URL 回调的使用方式
|
||||
|
||||
## 3.11.0
|
||||
|
||||
## 3.10.0
|
||||
|
||||
## 3.9.0
|
||||
|
||||
## 3.8.0
|
||||
|
||||
## 3.7.1
|
||||
|
||||
## 3.7.0
|
||||
|
||||
## 3.6.3
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- Android 修复特定机型上繁体中文的识别
|
||||
- Android 修复初始化时未配置 TapDBConfig 会初始化失败的问题
|
||||
|
||||
## 3.6.1
|
||||
|
||||
## 3.6.0
|
||||
|
||||
## 3.5.2
|
||||
|
||||
### New Feature
|
||||
- 新增多语言配置
|
||||
|
||||
## 3.5.0
|
||||
|
||||
### Optimization and fixed bugs
|
||||
- 支持性更新
|
||||
|
||||
## 3.4.0
|
||||
|
||||
## 3.3.0
|
||||
|
||||
- Native Update
|
||||
|
||||
## 3.2.0
|
||||
|
||||
- Native Update
|
||||
|
||||
## 3.1.0
|
||||
|
||||
- Native Update
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Optimization
|
||||
|
||||
- Bridge 新增 Task 桥接
|
||||
|
||||
## 2.1.7
|
||||
|
||||
### None
|
||||
|
||||
## 2.1.6
|
||||
|
||||
### BreakingChanges
|
||||
|
||||
- 修改 **TapCommon.OpenReviewInTapGlobal()** 方法命名
|
||||
|
||||
## 2.1.5
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 内部优化
|
||||
|
||||
## 2.1.4
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
- 优化多语言相关
|
||||
- 修复 JSON 解析错误
|
||||
|
||||
## 2.1.3
|
||||
|
||||
### New Feature
|
||||
|
||||
* iOS 新增 TapTap 以及 Tap.IO 客户端安装判断
|
||||
|
||||
## 2.1.2
|
||||
|
||||
### Optimization and fixed bugs
|
||||
|
||||
* 修复 iOS ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES 设置问题可能导致的 AppStore 审核无法通过
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Feature
|
||||
|
||||
* Android 新增 TapTap App 相关支持功能
|
||||
|
||||
## 2.1.0
|
||||
|
||||
* 新增长链接支持 TapTap.Friends
|
||||
* 海内外域名切换
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Feature
|
||||
|
||||
* TapTap Common
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 89a2f2ba3f4d4cf0b55f2f992c6b6afb
|
||||
timeCreated: 1616744142
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e5655844e77cd49d8a69c4a299e31419
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
# TapCommon 用于支持 TapSDK 其他模块中 Android、iOS 与 Unity 的通信
|
||||
|
||||
> 目前 TapSDK 业务中,Unity 业务层实现的功能不多,主要作为桥接来调用 Android、iOS SDK 中的方法。
|
||||
|
||||
## 一、实现 Unity 调用 Android、iOS 方法
|
||||
|
||||
> 为了方便 Unity 一套代码可以调用双端方法,所以定义原生接口时,需要考虑 Android、iOS 语言之间的差异。
|
||||
|
||||
### Android 接口定义
|
||||
|
||||
- 使用 `@BridgeService` 、`@BridgeMethod` 、`@BridgeParam` 注解修饰 `类`、`方法`、`参数`。
|
||||
- `Activity`、`BridgeCallback` 这两个类型参数不需要 `@BridgeParam` 注解。
|
||||
- `@BridgeParam` 仅支持基本数据类型(包含 `String`)。
|
||||
|
||||
```java
|
||||
@BridgeService("TestService")
|
||||
public class TestService implementation IBridgeService {
|
||||
|
||||
@BridgeMethod("testMethodWithCallback")
|
||||
void testMethodWithCallback(BridgeCallback callback);
|
||||
|
||||
@BridgeMethod("testMethodWithArgsAndCallback")
|
||||
void testMethodWithArgsAndCallback(Activity activity, @BridgeParam("args1") String appId, @BridgeParam("args2") int args2, BridgeCallback callback);
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Android 接口实现
|
||||
|
||||
```java
|
||||
public class TestService implementation TestService {
|
||||
|
||||
@Override
|
||||
public void testMethodWithCallback(BridgeCallback callback){
|
||||
callback.onResult("testMethodWithCallback 回调给 Unity 的参数");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMethodWithArgsAndCallback(Activity activity, String appId,int args2, BridgeCallback callback){
|
||||
callback.onResult("testMethodWithArgsAndCallback 回调给 Unity 的参数");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### iOS 接口定义
|
||||
|
||||
> iOS 方法名通过反射获取到的为 `args1:args2:bridgeCallback` ,所以 iOS 的方法定义与 Android 略有不同。
|
||||
|
||||
- 类名必须同 Android `@BridgeService` 所修饰的类名一致。
|
||||
- 参数名例如 `args1`、`args2` 必须同 Android `@BridgeParam` 修饰的一致,用于回调的 `iOS` 闭包的参数名必须为 `bridgeCallback`。
|
||||
- 当参数个数仅为 0 或者 仅为 闭包时,方法名必须同 Android `@BridgeMethod` 修饰的方法一致。
|
||||
|
||||
```objectivec
|
||||
@interface TestService
|
||||
|
||||
// 匹配的是 Android 中 testMethodWithCallback 方法
|
||||
+(void) testMethodWithCallback:(void (^)(NSString *result))callback;
|
||||
|
||||
// 匹配的是 Android 中 testMethodWithArgsAndCallback 方法
|
||||
+(void) args1:(NSString*)args1 args2:(NSNumber*)args2 bridgeCallback:(void (^)(NSString *result))callback;
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
### iOS 接口实现
|
||||
|
||||
```objectivec
|
||||
@implementation TestService
|
||||
|
||||
+(void) testMethodWithCallback:(void (^)(NSString *result)) callback{
|
||||
callback(@"testMethodWithCallback 回调给 Unity 的参数");
|
||||
}
|
||||
|
||||
+(void) args1:(NSString*)args1 args2:(NSNumber*)args2 bridgeCallback:(void (^)(NSString *result))callback{
|
||||
callback(@"testMethodWithArgsAndCallback 回调给 Unity 的参数");
|
||||
}
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
### Unity 调用上文中定义的 Android、iOS 接口
|
||||
|
||||
#### 1.初始化
|
||||
|
||||
```c#
|
||||
// Android 初始化
|
||||
//CLZ_NAME 和IMP_NAME为 接口以及实现类的全路径包名 例如:com.tds.bridge.TestService,com.tds.bridge.TestServiceImpl
|
||||
EngineBridge.GetInstance().Register(CLZ_NAME, IMP_NAME);
|
||||
|
||||
// iOS 无需初始化
|
||||
```
|
||||
#### 2.调用方法
|
||||
|
||||
`Bridge.CallHandler` 为异步方法,执行线程的流程为:
|
||||
|
||||
Unity Thread -> Native MainThread -> Execute Function -> Unity Thread
|
||||
|
||||
所以执行 `CallHandler` 的 Thread 和 `Action<Result>` 的 Thread 都为 Unity 当前 Thread。
|
||||
|
||||
```c#
|
||||
var command = new Command.Builder()
|
||||
.Service("TestService") // @BridgeService 值以及 iOS 类名
|
||||
.Method("testMethodWithArgsAndCallback") // @BridgeMethod 值 以及 iOS 方法名
|
||||
.Args("args1","value") // @BridgeParam 值 以及 iOS 参数名
|
||||
.Args("args2",1) // 同上
|
||||
.Callback(true) // 是否需要添加 BridgeCallback
|
||||
.OnceTime(true) // 当前 BridgeCallback 是否常驻内存
|
||||
.CommandBuilder();
|
||||
|
||||
// 需要回调
|
||||
EngineBridge.GetInstance().CallHandler(command,result=>{
|
||||
if(EngineBridge.CheckResult(result)){
|
||||
// 桥接调用成功
|
||||
// 当前 Content 则为 Android、iOS 通过 BridgeCallback 传给 Unity 的值
|
||||
var content = result.content;
|
||||
}
|
||||
});
|
||||
|
||||
// 不需要回调
|
||||
EngineBridge.GetInstance().CallHandler(command);
|
||||
```
|
||||
|
||||
## 二、Android 、iOS 调用 Unity
|
||||
|
||||
鉴于 TapSDK 3.1.+ 之后,Android 与 iOS 需要同步 `TapBootstrap` 中 `TDSUser` 的部分参数,所以 `TapCommon` 在当前版本支持了原生简单的调用 Unity 接口。
|
||||
|
||||
以下以 Android、iOS 需要 Unity 提供 `sessionToken` 以及 `objectId` 为例
|
||||
|
||||
### Unity 实现 ITapPropertiesProxy 接口并注册
|
||||
|
||||
```c#
|
||||
public class SessionTokenProxy:ITapPropertiesProxy{
|
||||
|
||||
public string GetProperties(){
|
||||
return "sessionToken-kafjaskldfjasjdhfajkdfajdfas";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ObjectIdProxy:ITapPropertiesProxy {
|
||||
|
||||
public string GetProperties(){
|
||||
return "objectId-dafasdfad";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 通过 TapCommon 注册 Native 需要调用的接口
|
||||
TapCommon.RegisterProperties("sessionToken",new SessionTokenProxy());
|
||||
|
||||
TapCommon.RegisterProperties("objectid",new ObjectIdProxy());
|
||||
```
|
||||
|
||||
### Android、iOS 调用 Unity 实现的 ITapPropertiesProxy 来获取所需要的值
|
||||
|
||||
Android 获取 `sessionToken` 以及 `objectId`
|
||||
|
||||
```java
|
||||
String sessionToken = TapPropertiesHolder.INSTANCE.getProperty("sessionToken");
|
||||
String objectId = TapPropertiesHolder.INSTANCE.getProperty("objectId");
|
||||
```
|
||||
|
||||
iOS 获取 `sessionToken` 以及 `objectId`
|
||||
|
||||
```objectivec
|
||||
NSString* sessionToken = [[TapPropertiesHolder shareInstance] getProperty:@"sessionToken"];
|
||||
NSString* objectId = [[TapPropertiesHolder shareInstance] getProperty:@"objectId"];
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c2be0874429944a43820d92aa06185f4
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
## TapTap.Common
|
||||
|
||||
### 接口描述
|
||||
|
||||
#### 1.获取地区
|
||||
|
||||
```c#
|
||||
TapCommon.GetRegionCode(isMainland =>
|
||||
{
|
||||
// true 中国大陆 false 非中国大陆
|
||||
});
|
||||
```
|
||||
|
||||
#### 2. TapTap 是否安装
|
||||
|
||||
```c#
|
||||
TapCommon.IsTapTapInstalled(installed =>
|
||||
{
|
||||
// true 安装 false 未安装
|
||||
});
|
||||
```
|
||||
|
||||
#### 3. TapTap IO 是否安装
|
||||
|
||||
```c#
|
||||
TapCommon.IsTapTapGlobalInstalled(installed =>
|
||||
{
|
||||
// true 安装 false 未安装
|
||||
});
|
||||
```
|
||||
|
||||
### Android 独占方法
|
||||
|
||||
#### 4. 在 TapTap 更新游戏
|
||||
|
||||
```c#
|
||||
TapCommon.UpdateGameInTapTap(appId,updateSuccess =>
|
||||
{
|
||||
// true 更新成功 false 更新失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 5. 在 TapTap IO 更新游戏
|
||||
|
||||
```c#
|
||||
TapCommon.UpdateGameInTapGlobal(appId,updateSuccess =>
|
||||
{
|
||||
// true 更新成功 false 更新失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 6. 在 TapTap 打开当前游戏的评论区
|
||||
|
||||
```c#
|
||||
TapCommon.OpenReviewInTapTap(appId,openSuccess =>
|
||||
{
|
||||
// true 打开评论区 false 打开失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 6. 在 TapTap IO 打开当前游戏的评论区
|
||||
|
||||
```c#
|
||||
TapCommon.OpenReviewInTapGlobal(appId,openSuccess =>
|
||||
{
|
||||
// true 打开评论区 false 打开失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 7. 唤起 TapTap 客户端更新游戏
|
||||
|
||||
appId: 游戏在 TapTap 商店的唯一身份标识
|
||||
|
||||
例如:https://www.taptap.com/app/187168 ,其中 187168 是 appid.
|
||||
|
||||
```c#
|
||||
// 在 TapTap 客户端更新游戏,失败时通过浏览器打开 Tap 网站对应的游戏页面
|
||||
// 当你在国内区上架时使用
|
||||
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapTap(string appId);
|
||||
// 当你在海外区上架时使用
|
||||
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapGlobal(string appId):
|
||||
```
|
||||
|
||||
如果你需要在唤起 Tap 客户端失败时跳转到自己的网页
|
||||
|
||||
```c#
|
||||
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapTap(string appId, string webUrl)
|
||||
bool isSuccess = await TapCommon.UpdateGameAndFailToWebInTapGlobal(string appId, string webUrl)
|
||||
```
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d7008a3a22e45a4bfe9605e6d050a29
|
||||
timeCreated: 1616744132
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28e2e71fed1414ad3978a4e5575065f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using UnityEditor;
|
||||
|
||||
namespace TapTap.Common.Editor {
|
||||
public static class BuildTargetUtils {
|
||||
public static bool IsSupportMobile(BuildTarget platform) {
|
||||
return platform == BuildTarget.iOS || platform == BuildTarget.Android;
|
||||
}
|
||||
|
||||
public static bool IsSupportStandalone(BuildTarget platform) {
|
||||
return platform == BuildTarget.StandaloneOSX ||
|
||||
platform == BuildTarget.StandaloneWindows || platform == BuildTarget.StandaloneWindows64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da005b5e251334d388fe38e6978890cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TapTap.Common.Editor {
|
||||
public class LinkedAssembly {
|
||||
public string Fullname { get; set; }
|
||||
public string[] Types { get; set; }
|
||||
}
|
||||
|
||||
public class LinkXMLGenerator {
|
||||
public static void Generate(string path, IEnumerable<LinkedAssembly> assemblies) {
|
||||
DirectoryInfo parent = Directory.GetParent(path);
|
||||
if (!parent.Exists) {
|
||||
Directory.CreateDirectory(parent.FullName);
|
||||
}
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlNode rootNode = doc.CreateElement("linker");
|
||||
doc.AppendChild(rootNode);
|
||||
|
||||
foreach (LinkedAssembly assembly in assemblies) {
|
||||
XmlNode assemblyNode = doc.CreateElement("assembly");
|
||||
|
||||
XmlAttribute fullnameAttr = doc.CreateAttribute("fullname");
|
||||
fullnameAttr.Value = assembly.Fullname;
|
||||
assemblyNode.Attributes.Append(fullnameAttr);
|
||||
|
||||
if (assembly.Types?.Length > 0) {
|
||||
foreach (string type in assembly.Types) {
|
||||
XmlNode typeNode = doc.CreateElement("type");
|
||||
XmlAttribute typeFullnameAttr = doc.CreateAttribute("fullname");
|
||||
typeFullnameAttr.Value = type;
|
||||
typeNode.Attributes.Append(typeFullnameAttr);
|
||||
|
||||
XmlAttribute typePreserveAttr = doc.CreateAttribute("preserve");
|
||||
typePreserveAttr.Value = "all";
|
||||
typeNode.Attributes.Append(typePreserveAttr);
|
||||
|
||||
assemblyNode.AppendChild(typeNode);
|
||||
}
|
||||
} else {
|
||||
XmlAttribute preserveAttr = doc.CreateAttribute("preserve");
|
||||
preserveAttr.Value = "all";
|
||||
assemblyNode.Attributes.Append(preserveAttr);
|
||||
}
|
||||
|
||||
rootNode.AppendChild(assemblyNode);
|
||||
}
|
||||
|
||||
doc.Save(path);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Debug.Log($"Generate {path} done.");
|
||||
Debug.Log(doc.OuterXml);
|
||||
}
|
||||
|
||||
public static void Delete(string path) {
|
||||
if (File.Exists(path)) {
|
||||
File.Delete(path);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
Debug.Log($"Delete {path} done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c63ed7a6afba54761aca6c388df097e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,954 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public static class Plist
|
||||
{
|
||||
private static List<int> offsetTable = new List<int>();
|
||||
private static List<byte> objectTable = new List<byte>();
|
||||
private static int refCount;
|
||||
private static int objRefSize;
|
||||
private static int offsetByteSize;
|
||||
private static long offsetTableOffset;
|
||||
|
||||
#region Public Functions
|
||||
|
||||
public static object readPlist(string path)
|
||||
{
|
||||
using (FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
return readPlist(f, plistType.Auto);
|
||||
}
|
||||
}
|
||||
|
||||
public static object readPlistSource(string source)
|
||||
{
|
||||
return readPlist(System.Text.Encoding.UTF8.GetBytes(source));
|
||||
}
|
||||
|
||||
public static object readPlist(byte[] data)
|
||||
{
|
||||
return readPlist(new MemoryStream(data), plistType.Auto);
|
||||
}
|
||||
|
||||
public static plistType getPlistType(Stream stream)
|
||||
{
|
||||
byte[] magicHeader = new byte[8];
|
||||
stream.Read(magicHeader, 0, 8);
|
||||
|
||||
if (BitConverter.ToInt64(magicHeader, 0) == 3472403351741427810)
|
||||
{
|
||||
return plistType.Binary;
|
||||
}
|
||||
else
|
||||
{
|
||||
return plistType.Xml;
|
||||
}
|
||||
}
|
||||
|
||||
public static object readPlist(Stream stream, plistType type)
|
||||
{
|
||||
if (type == plistType.Auto)
|
||||
{
|
||||
type = getPlistType(stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
if (type == plistType.Binary)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(stream))
|
||||
{
|
||||
byte[] data = reader.ReadBytes((int) reader.BaseStream.Length);
|
||||
return readBinary(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.XmlResolver = null;
|
||||
xml.Load(stream);
|
||||
return readXml(xml);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeXml(object value, string path)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(path))
|
||||
{
|
||||
writer.Write(writeXml(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeXml(object value, Stream stream)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(stream))
|
||||
{
|
||||
writer.Write(writeXml(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static string writeXml(object value)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
|
||||
xmlWriterSettings.Encoding = new System.Text.UTF8Encoding(false);
|
||||
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Document;
|
||||
xmlWriterSettings.Indent = true;
|
||||
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(ms, xmlWriterSettings))
|
||||
{
|
||||
xmlWriter.WriteStartDocument();
|
||||
//xmlWriter.WriteComment("DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
|
||||
xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN",
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
|
||||
xmlWriter.WriteStartElement("plist");
|
||||
xmlWriter.WriteAttributeString("version", "1.0");
|
||||
compose(value, xmlWriter);
|
||||
xmlWriter.WriteEndElement();
|
||||
xmlWriter.WriteEndDocument();
|
||||
xmlWriter.Flush();
|
||||
xmlWriter.Close();
|
||||
return System.Text.Encoding.UTF8.GetString(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBinary(object value, string path)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create)))
|
||||
{
|
||||
writer.Write(writeBinary(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBinary(object value, Stream stream)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(stream))
|
||||
{
|
||||
writer.Write(writeBinary(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] writeBinary(object value)
|
||||
{
|
||||
offsetTable.Clear();
|
||||
objectTable.Clear();
|
||||
refCount = 0;
|
||||
objRefSize = 0;
|
||||
offsetByteSize = 0;
|
||||
offsetTableOffset = 0;
|
||||
|
||||
//Do not count the root node, subtract by 1
|
||||
int totalRefs = countObject(value) - 1;
|
||||
|
||||
refCount = totalRefs;
|
||||
|
||||
objRefSize = RegulateNullBytes(BitConverter.GetBytes(refCount)).Length;
|
||||
|
||||
composeBinary(value);
|
||||
|
||||
writeBinaryString("bplist00", false);
|
||||
|
||||
offsetTableOffset = (long) objectTable.Count;
|
||||
|
||||
offsetTable.Add(objectTable.Count - 8);
|
||||
|
||||
offsetByteSize = RegulateNullBytes(BitConverter.GetBytes(offsetTable[offsetTable.Count - 1])).Length;
|
||||
|
||||
List<byte> offsetBytes = new List<byte>();
|
||||
|
||||
offsetTable.Reverse();
|
||||
|
||||
for (int i = 0; i < offsetTable.Count; i++)
|
||||
{
|
||||
offsetTable[i] = objectTable.Count - offsetTable[i];
|
||||
byte[] buffer = RegulateNullBytes(BitConverter.GetBytes(offsetTable[i]), offsetByteSize);
|
||||
Array.Reverse(buffer);
|
||||
offsetBytes.AddRange(buffer);
|
||||
}
|
||||
|
||||
objectTable.AddRange(offsetBytes);
|
||||
|
||||
objectTable.AddRange(new byte[6]);
|
||||
objectTable.Add(Convert.ToByte(offsetByteSize));
|
||||
objectTable.Add(Convert.ToByte(objRefSize));
|
||||
|
||||
var a = BitConverter.GetBytes((long) totalRefs + 1);
|
||||
Array.Reverse(a);
|
||||
objectTable.AddRange(a);
|
||||
|
||||
objectTable.AddRange(BitConverter.GetBytes((long) 0));
|
||||
a = BitConverter.GetBytes(offsetTableOffset);
|
||||
Array.Reverse(a);
|
||||
objectTable.AddRange(a);
|
||||
|
||||
return objectTable.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
|
||||
private static object readXml(XmlDocument xml)
|
||||
{
|
||||
XmlNode rootNode = xml.DocumentElement.ChildNodes[0];
|
||||
return parse(rootNode);
|
||||
}
|
||||
|
||||
private static object readBinary(byte[] data)
|
||||
{
|
||||
offsetTable.Clear();
|
||||
List<byte> offsetTableBytes = new List<byte>();
|
||||
objectTable.Clear();
|
||||
refCount = 0;
|
||||
objRefSize = 0;
|
||||
offsetByteSize = 0;
|
||||
offsetTableOffset = 0;
|
||||
|
||||
List<byte> bList = new List<byte>(data);
|
||||
|
||||
List<byte> trailer = bList.GetRange(bList.Count - 32, 32);
|
||||
|
||||
parseTrailer(trailer);
|
||||
|
||||
objectTable = bList.GetRange(0, (int) offsetTableOffset);
|
||||
|
||||
offsetTableBytes = bList.GetRange((int) offsetTableOffset, bList.Count - (int) offsetTableOffset - 32);
|
||||
|
||||
parseOffsetTable(offsetTableBytes);
|
||||
|
||||
return parseBinary(0);
|
||||
}
|
||||
|
||||
private static Dictionary<string, object> parseDictionary(XmlNode node)
|
||||
{
|
||||
XmlNodeList children = node.ChildNodes;
|
||||
if (children.Count % 2 != 0)
|
||||
{
|
||||
throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
|
||||
}
|
||||
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
|
||||
for (int i = 0; i < children.Count; i += 2)
|
||||
{
|
||||
XmlNode keynode = children[i];
|
||||
XmlNode valnode = children[i + 1];
|
||||
|
||||
if (keynode.Name != "key")
|
||||
{
|
||||
throw new ApplicationException("expected a key node");
|
||||
}
|
||||
|
||||
object result = parse(valnode);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
dict.Add(keynode.InnerText, result);
|
||||
}
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
private static List<object> parseArray(XmlNode node)
|
||||
{
|
||||
List<object> array = new List<object>();
|
||||
|
||||
foreach (XmlNode child in node.ChildNodes)
|
||||
{
|
||||
object result = parse(child);
|
||||
if (result != null)
|
||||
{
|
||||
array.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private static void composeArray(List<object> value, XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("array");
|
||||
foreach (object obj in value)
|
||||
{
|
||||
compose(obj, writer);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private static object parse(XmlNode node)
|
||||
{
|
||||
switch (node.Name)
|
||||
{
|
||||
case "dict":
|
||||
return parseDictionary(node);
|
||||
case "array":
|
||||
return parseArray(node);
|
||||
case "string":
|
||||
return node.InnerText;
|
||||
case "integer":
|
||||
// int result;
|
||||
//int.TryParse(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo, out result);
|
||||
return Convert.ToInt32(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
case "real":
|
||||
return Convert.ToDouble(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
case "false":
|
||||
return false;
|
||||
case "true":
|
||||
return true;
|
||||
case "null":
|
||||
return null;
|
||||
case "date":
|
||||
return XmlConvert.ToDateTime(node.InnerText, XmlDateTimeSerializationMode.Utc);
|
||||
case "data":
|
||||
return Convert.FromBase64String(node.InnerText);
|
||||
}
|
||||
|
||||
throw new ApplicationException(String.Format("Plist Node `{0}' is not supported", node.Name));
|
||||
}
|
||||
|
||||
private static void compose(object value, XmlWriter writer)
|
||||
{
|
||||
if (value == null || value is string)
|
||||
{
|
||||
writer.WriteElementString("string", value as string);
|
||||
}
|
||||
else if (value is int || value is long)
|
||||
{
|
||||
writer.WriteElementString("integer",
|
||||
((int) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
|
||||
}
|
||||
else if (value is System.Collections.Generic.Dictionary<string, object> ||
|
||||
value.GetType().ToString().StartsWith("System.Collections.Generic.Dictionary`2[System.String"))
|
||||
{
|
||||
//Convert to Dictionary<string, object>
|
||||
Dictionary<string, object> dic = value as Dictionary<string, object>;
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, object>();
|
||||
IDictionary idic = (IDictionary) value;
|
||||
foreach (var key in idic.Keys)
|
||||
{
|
||||
dic.Add(key.ToString(), idic[key]);
|
||||
}
|
||||
}
|
||||
|
||||
writeDictionaryValues(dic, writer);
|
||||
}
|
||||
else if (value is List<object>)
|
||||
{
|
||||
composeArray((List<object>) value, writer);
|
||||
}
|
||||
else if (value is byte[])
|
||||
{
|
||||
writer.WriteElementString("data", Convert.ToBase64String((Byte[]) value));
|
||||
}
|
||||
else if (value is float || value is double)
|
||||
{
|
||||
writer.WriteElementString("real",
|
||||
((double) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
|
||||
}
|
||||
else if (value is DateTime)
|
||||
{
|
||||
DateTime time = (DateTime) value;
|
||||
string theString = XmlConvert.ToString(time, XmlDateTimeSerializationMode.Utc);
|
||||
writer.WriteElementString("date", theString); //, "yyyy-MM-ddTHH:mm:ssZ"));
|
||||
}
|
||||
else if (value is bool)
|
||||
{
|
||||
writer.WriteElementString(value.ToString().ToLower(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeDictionaryValues(Dictionary<string, object> dictionary, XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("dict");
|
||||
foreach (string key in dictionary.Keys)
|
||||
{
|
||||
object value = dictionary[key];
|
||||
writer.WriteElementString("key", key);
|
||||
compose(value, writer);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private static int countObject(object value)
|
||||
{
|
||||
int count = 0;
|
||||
switch (value.GetType().ToString())
|
||||
{
|
||||
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
|
||||
Dictionary<string, object> dict = (Dictionary<string, object>) value;
|
||||
foreach (string key in dict.Keys)
|
||||
{
|
||||
count += countObject(dict[key]);
|
||||
}
|
||||
|
||||
count += dict.Keys.Count;
|
||||
count++;
|
||||
break;
|
||||
case "System.Collections.Generic.List`1[System.Object]":
|
||||
List<object> list = (List<object>) value;
|
||||
foreach (object obj in list)
|
||||
{
|
||||
count += countObject(obj);
|
||||
}
|
||||
|
||||
count++;
|
||||
break;
|
||||
default:
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryDictionary(Dictionary<string, object> dictionary)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
List<int> refs = new List<int>();
|
||||
for (int i = dictionary.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var o = new object[dictionary.Count];
|
||||
dictionary.Values.CopyTo(o, 0);
|
||||
composeBinary(o[i]);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
for (int i = dictionary.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var o = new string[dictionary.Count];
|
||||
dictionary.Keys.CopyTo(o, 0);
|
||||
composeBinary(o[i]); //);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
if (dictionary.Count < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0xD0 | Convert.ToByte(dictionary.Count)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0xD0 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(dictionary.Count, false));
|
||||
}
|
||||
|
||||
|
||||
foreach (int val in refs)
|
||||
{
|
||||
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
|
||||
Array.Reverse(refBuffer);
|
||||
buffer.InsertRange(0, refBuffer);
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] composeBinaryArray(List<object> objects)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
List<int> refs = new List<int>();
|
||||
|
||||
for (int i = objects.Count - 1; i >= 0; i--)
|
||||
{
|
||||
composeBinary(objects[i]);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
if (objects.Count < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0xA0 | Convert.ToByte(objects.Count)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0xA0 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(objects.Count, false));
|
||||
}
|
||||
|
||||
foreach (int val in refs)
|
||||
{
|
||||
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
|
||||
Array.Reverse(refBuffer);
|
||||
buffer.InsertRange(0, refBuffer);
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] composeBinary(object obj)
|
||||
{
|
||||
byte[] value;
|
||||
switch (obj.GetType().ToString())
|
||||
{
|
||||
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
|
||||
value = writeBinaryDictionary((Dictionary<string, object>) obj);
|
||||
return value;
|
||||
|
||||
case "System.Collections.Generic.List`1[System.Object]":
|
||||
value = composeBinaryArray((List<object>) obj);
|
||||
return value;
|
||||
|
||||
case "System.Byte[]":
|
||||
value = writeBinaryByteArray((byte[]) obj);
|
||||
return value;
|
||||
|
||||
case "System.Double":
|
||||
value = writeBinaryDouble((double) obj);
|
||||
return value;
|
||||
|
||||
case "System.Int32":
|
||||
value = writeBinaryInteger((int) obj, true);
|
||||
return value;
|
||||
|
||||
case "System.String":
|
||||
value = writeBinaryString((string) obj, true);
|
||||
return value;
|
||||
|
||||
case "System.DateTime":
|
||||
value = writeBinaryDate((DateTime) obj);
|
||||
return value;
|
||||
|
||||
case "System.Boolean":
|
||||
value = writeBinaryBool((bool) obj);
|
||||
return value;
|
||||
|
||||
default:
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] writeBinaryDate(DateTime obj)
|
||||
{
|
||||
List<byte> buffer =
|
||||
new List<byte>(RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)),
|
||||
8));
|
||||
buffer.Reverse();
|
||||
buffer.Insert(0, 0x33);
|
||||
objectTable.InsertRange(0, buffer);
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] writeBinaryBool(bool obj)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(new byte[1] {(bool) obj ? (byte) 9 : (byte) 8});
|
||||
objectTable.InsertRange(0, buffer);
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryInteger(int value, bool write)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(BitConverter.GetBytes((long) value));
|
||||
buffer = new List<byte>(RegulateNullBytes(buffer.ToArray()));
|
||||
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
|
||||
buffer.Add(0);
|
||||
int header = 0x10 | (int) (Math.Log(buffer.Count) / Math.Log(2));
|
||||
|
||||
buffer.Reverse();
|
||||
|
||||
buffer.Insert(0, Convert.ToByte(header));
|
||||
|
||||
if (write)
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryDouble(double value)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(RegulateNullBytes(BitConverter.GetBytes(value), 4));
|
||||
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
|
||||
buffer.Add(0);
|
||||
int header = 0x20 | (int) (Math.Log(buffer.Count) / Math.Log(2));
|
||||
|
||||
buffer.Reverse();
|
||||
|
||||
buffer.Insert(0, Convert.ToByte(header));
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryByteArray(byte[] value)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(value);
|
||||
List<byte> header = new List<byte>();
|
||||
if (value.Length < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0x40 | Convert.ToByte(value.Length)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0x40 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(buffer.Count, false));
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryString(string value, bool head)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
foreach (char chr in value.ToCharArray())
|
||||
buffer.Add(Convert.ToByte(chr));
|
||||
|
||||
if (head)
|
||||
{
|
||||
if (value.Length < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0x50 | Convert.ToByte(value.Length)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0x50 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(buffer.Count, false));
|
||||
}
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] RegulateNullBytes(byte[] value)
|
||||
{
|
||||
return RegulateNullBytes(value, 1);
|
||||
}
|
||||
|
||||
private static byte[] RegulateNullBytes(byte[] value, int minBytes)
|
||||
{
|
||||
Array.Reverse(value);
|
||||
List<byte> bytes = new List<byte>(value);
|
||||
for (int i = 0; i < bytes.Count; i++)
|
||||
{
|
||||
if (bytes[i] == 0 && bytes.Count > minBytes)
|
||||
{
|
||||
bytes.Remove(bytes[i]);
|
||||
i--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytes.Count < minBytes)
|
||||
{
|
||||
int dist = minBytes - bytes.Count;
|
||||
for (int i = 0; i < dist; i++)
|
||||
bytes.Insert(0, 0);
|
||||
}
|
||||
|
||||
value = bytes.ToArray();
|
||||
Array.Reverse(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void parseTrailer(List<byte> trailer)
|
||||
{
|
||||
offsetByteSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(6, 1).ToArray(), 4), 0);
|
||||
objRefSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(7, 1).ToArray(), 4), 0);
|
||||
byte[] refCountBytes = trailer.GetRange(12, 4).ToArray();
|
||||
Array.Reverse(refCountBytes);
|
||||
refCount = BitConverter.ToInt32(refCountBytes, 0);
|
||||
byte[] offsetTableOffsetBytes = trailer.GetRange(24, 8).ToArray();
|
||||
Array.Reverse(offsetTableOffsetBytes);
|
||||
offsetTableOffset = BitConverter.ToInt64(offsetTableOffsetBytes, 0);
|
||||
}
|
||||
|
||||
private static void parseOffsetTable(List<byte> offsetTableBytes)
|
||||
{
|
||||
for (int i = 0; i < offsetTableBytes.Count; i += offsetByteSize)
|
||||
{
|
||||
byte[] buffer = offsetTableBytes.GetRange(i, offsetByteSize).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
offsetTable.Add(BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static object parseBinaryDictionary(int objRef)
|
||||
{
|
||||
Dictionary<string, object> buffer = new Dictionary<string, object>();
|
||||
List<int> refs = new List<int>();
|
||||
int refCount = 0;
|
||||
|
||||
int refStartPosition;
|
||||
refCount = getCount(offsetTable[objRef], out refStartPosition);
|
||||
|
||||
|
||||
if (refCount < 15)
|
||||
refStartPosition = offsetTable[objRef] + 1;
|
||||
else
|
||||
refStartPosition = offsetTable[objRef] + 2 +
|
||||
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
|
||||
|
||||
for (int i = refStartPosition; i < refStartPosition + refCount * 2 * objRefSize; i += objRefSize)
|
||||
{
|
||||
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
|
||||
Array.Reverse(refBuffer);
|
||||
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
|
||||
}
|
||||
|
||||
for (int i = 0; i < refCount; i++)
|
||||
{
|
||||
buffer.Add((string) parseBinary(refs[i]), parseBinary(refs[i + refCount]));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static object parseBinaryArray(int objRef)
|
||||
{
|
||||
List<object> buffer = new List<object>();
|
||||
List<int> refs = new List<int>();
|
||||
int refCount = 0;
|
||||
|
||||
int refStartPosition;
|
||||
refCount = getCount(offsetTable[objRef], out refStartPosition);
|
||||
|
||||
|
||||
if (refCount < 15)
|
||||
refStartPosition = offsetTable[objRef] + 1;
|
||||
else
|
||||
//The following integer has a header aswell so we increase the refStartPosition by two to account for that.
|
||||
refStartPosition = offsetTable[objRef] + 2 +
|
||||
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
|
||||
|
||||
for (int i = refStartPosition; i < refStartPosition + refCount * objRefSize; i += objRefSize)
|
||||
{
|
||||
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
|
||||
Array.Reverse(refBuffer);
|
||||
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
|
||||
}
|
||||
|
||||
for (int i = 0; i < refCount; i++)
|
||||
{
|
||||
buffer.Add(parseBinary(refs[i]));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static int getCount(int bytePosition, out int newBytePosition)
|
||||
{
|
||||
byte headerByte = objectTable[bytePosition];
|
||||
byte headerByteTrail = Convert.ToByte(headerByte & 0xf);
|
||||
int count;
|
||||
if (headerByteTrail < 15)
|
||||
{
|
||||
count = headerByteTrail;
|
||||
newBytePosition = bytePosition + 1;
|
||||
}
|
||||
else
|
||||
count = (int) parseBinaryInt(bytePosition + 1, out newBytePosition);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static object parseBinary(int objRef)
|
||||
{
|
||||
byte header = objectTable[offsetTable[objRef]];
|
||||
switch (header & 0xF0)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
//If the byte is
|
||||
//0 return null
|
||||
//9 return true
|
||||
//8 return false
|
||||
return (objectTable[offsetTable[objRef]] == 0)
|
||||
? (object) null
|
||||
: ((objectTable[offsetTable[objRef]] == 9) ? true : false);
|
||||
}
|
||||
case 0x10:
|
||||
{
|
||||
return parseBinaryInt(offsetTable[objRef]);
|
||||
}
|
||||
case 0x20:
|
||||
{
|
||||
return parseBinaryReal(offsetTable[objRef]);
|
||||
}
|
||||
case 0x30:
|
||||
{
|
||||
return parseBinaryDate(offsetTable[objRef]);
|
||||
}
|
||||
case 0x40:
|
||||
{
|
||||
return parseBinaryByteArray(offsetTable[objRef]);
|
||||
}
|
||||
case 0x50: //String ASCII
|
||||
{
|
||||
return parseBinaryAsciiString(offsetTable[objRef]);
|
||||
}
|
||||
case 0x60: //String Unicode
|
||||
{
|
||||
return parseBinaryUnicodeString(offsetTable[objRef]);
|
||||
}
|
||||
case 0xD0:
|
||||
{
|
||||
return parseBinaryDictionary(objRef);
|
||||
}
|
||||
case 0xA0:
|
||||
{
|
||||
return parseBinaryArray(objRef);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("This type is not supported");
|
||||
}
|
||||
|
||||
public static object parseBinaryDate(int headerPosition)
|
||||
{
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, 8).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
double appleTime = BitConverter.ToDouble(buffer, 0);
|
||||
DateTime result = PlistDateConverter.ConvertFromAppleTimeStamp(appleTime);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object parseBinaryInt(int headerPosition)
|
||||
{
|
||||
int output;
|
||||
return parseBinaryInt(headerPosition, out output);
|
||||
}
|
||||
|
||||
private static object parseBinaryInt(int headerPosition, out int newHeaderPosition)
|
||||
{
|
||||
byte header = objectTable[headerPosition];
|
||||
int byteCount = (int) Math.Pow(2, header & 0xf);
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
//Add one to account for the header byte
|
||||
newHeaderPosition = headerPosition + byteCount + 1;
|
||||
return BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0);
|
||||
}
|
||||
|
||||
private static object parseBinaryReal(int headerPosition)
|
||||
{
|
||||
byte header = objectTable[headerPosition];
|
||||
int byteCount = (int) Math.Pow(2, header & 0xf);
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
|
||||
return BitConverter.ToDouble(RegulateNullBytes(buffer, 8), 0);
|
||||
}
|
||||
|
||||
private static object parseBinaryAsciiString(int headerPosition)
|
||||
{
|
||||
int charStartPosition;
|
||||
int charCount = getCount(headerPosition, out charStartPosition);
|
||||
|
||||
var buffer = objectTable.GetRange(charStartPosition, charCount);
|
||||
return buffer.Count > 0 ? Encoding.ASCII.GetString(buffer.ToArray()) : string.Empty;
|
||||
}
|
||||
|
||||
private static object parseBinaryUnicodeString(int headerPosition)
|
||||
{
|
||||
int charStartPosition;
|
||||
int charCount = getCount(headerPosition, out charStartPosition);
|
||||
charCount = charCount * 2;
|
||||
|
||||
byte[] buffer = new byte[charCount];
|
||||
byte one, two;
|
||||
|
||||
for (int i = 0; i < charCount; i += 2)
|
||||
{
|
||||
one = objectTable.GetRange(charStartPosition + i, 1)[0];
|
||||
two = objectTable.GetRange(charStartPosition + i + 1, 1)[0];
|
||||
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
buffer[i] = two;
|
||||
buffer[i + 1] = one;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = one;
|
||||
buffer[i + 1] = two;
|
||||
}
|
||||
}
|
||||
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
}
|
||||
|
||||
private static object parseBinaryByteArray(int headerPosition)
|
||||
{
|
||||
int byteStartPosition;
|
||||
int byteCount = getCount(headerPosition, out byteStartPosition);
|
||||
return objectTable.GetRange(byteStartPosition, byteCount).ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum plistType
|
||||
{
|
||||
Auto,
|
||||
Binary,
|
||||
Xml
|
||||
}
|
||||
|
||||
public static class PlistDateConverter
|
||||
{
|
||||
public static long timeDifference = 978307200;
|
||||
|
||||
public static long GetAppleTime(long unixTime)
|
||||
{
|
||||
return unixTime - timeDifference;
|
||||
}
|
||||
|
||||
public static long GetUnixTime(long appleTime)
|
||||
{
|
||||
return appleTime + timeDifference;
|
||||
}
|
||||
|
||||
public static DateTime ConvertFromAppleTimeStamp(double timestamp)
|
||||
{
|
||||
DateTime origin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
|
||||
return origin.AddSeconds(timestamp);
|
||||
}
|
||||
|
||||
public static double ConvertToAppleTimeStamp(DateTime date)
|
||||
{
|
||||
DateTime begin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
|
||||
TimeSpan diff = date - begin;
|
||||
return Math.Floor(diff.TotalSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66eefeda055244c784769597b08e679e
|
||||
timeCreated: 1617120740
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
namespace TapTap.Common.Editor {
|
||||
/// <summary>
|
||||
/// 模块 SDK 生成 link.xml 构建过程
|
||||
/// </summary>
|
||||
public abstract class SDKLinkProcessBuild : IPreprocessBuildWithReport, IPostprocessBuildWithReport {
|
||||
/// <summary>
|
||||
/// 执行顺序
|
||||
/// </summary>
|
||||
public abstract int callbackOrder { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 生成 link.xml 路径
|
||||
/// </summary>
|
||||
public abstract string LinkPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 防止被裁剪的 Assembly
|
||||
/// </summary>
|
||||
public abstract LinkedAssembly[] LinkedAssemblies { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行平台委托
|
||||
/// </summary>
|
||||
public abstract Func<BuildReport, bool> IsTargetPlatform { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建时忽略目录,目前主要是 PC 内置浏览器 Vuplex
|
||||
/// </summary>
|
||||
public virtual string[] BuildingIgnorePaths => null;
|
||||
|
||||
/// <summary>
|
||||
/// 构建前处理
|
||||
/// </summary>
|
||||
/// <param name="report"></param>
|
||||
public void OnPreprocessBuild(BuildReport report) {
|
||||
if (!IsTargetPlatform.Invoke(report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application.logMessageReceived += OnBuildError;
|
||||
IgnorePaths();
|
||||
|
||||
string linkPath = Path.Combine(Application.dataPath, LinkPath);
|
||||
LinkXMLGenerator.Generate(linkPath, LinkedAssemblies);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建后处理
|
||||
/// </summary>
|
||||
/// <param name="report"></param>
|
||||
public void OnPostprocessBuild(BuildReport report) {
|
||||
if (!IsTargetPlatform.Invoke(report)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application.logMessageReceived -= OnBuildError;
|
||||
RecoverIgnoredPaths();
|
||||
|
||||
string linkPath = Path.Combine(Application.dataPath, LinkPath);
|
||||
LinkXMLGenerator.Delete(linkPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误日志回调
|
||||
/// </summary>
|
||||
/// <param name="condition"></param>
|
||||
/// <param name="stacktrace"></param>
|
||||
/// <param name="logType"></param>
|
||||
private void OnBuildError(string condition, string stacktrace, LogType logType) {
|
||||
// TRICK: 通过捕获错误日志来监听打包错误事件
|
||||
if (logType == LogType.Error) {
|
||||
Application.logMessageReceived -= OnBuildError;
|
||||
RecoverIgnoredPaths();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略目录
|
||||
/// </summary>
|
||||
private void IgnorePaths() {
|
||||
if (BuildingIgnorePaths == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string ignorePath in BuildingIgnorePaths) {
|
||||
if (!Directory.Exists(Path.Combine(Application.dataPath, ignorePath))) {
|
||||
continue;
|
||||
}
|
||||
string ignoreName = Path.GetFileName(ignorePath);
|
||||
AssetDatabase.RenameAsset(Path.Combine("Assets", ignorePath), $"{ignoreName}~");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复目录
|
||||
/// </summary>
|
||||
private void RecoverIgnoredPaths() {
|
||||
if (BuildingIgnorePaths == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string ignorePath in BuildingIgnorePaths) {
|
||||
if (!Directory.Exists(Path.Combine(Application.dataPath, $"{ignorePath}~"))) {
|
||||
continue;
|
||||
}
|
||||
Directory.Move(Path.Combine(Application.dataPath, $"{ignorePath}~"),
|
||||
Path.Combine(Application.dataPath, $"{ignorePath}"));
|
||||
AssetDatabase.ImportAsset(Path.Combine("Assets", ignorePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8566d22eb15da4629a4ae0deae37b0fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEngine;
|
||||
#if UNITY_IOS
|
||||
using System;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
|
||||
#endif
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public static class TapCommonCompile
|
||||
{
|
||||
#if UNITY_IOS
|
||||
public static string GetProjPath(string path)
|
||||
{
|
||||
return PBXProject.GetPBXProjectPath(path);
|
||||
}
|
||||
|
||||
public static PBXProject ParseProjPath(string path)
|
||||
{
|
||||
var proj = new PBXProject();
|
||||
proj.ReadFromString(File.ReadAllText(path));
|
||||
return proj;
|
||||
}
|
||||
|
||||
public static string GetUnityFrameworkTarget(PBXProject proj)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string target = proj.GetUnityFrameworkTargetGuid();
|
||||
return target;
|
||||
#endif
|
||||
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
|
||||
return unityPhoneTarget;
|
||||
}
|
||||
|
||||
public static string GetUnityTarget(PBXProject proj)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string target = proj.GetUnityMainTargetGuid();
|
||||
return target;
|
||||
#endif
|
||||
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
|
||||
return unityPhoneTarget;
|
||||
}
|
||||
|
||||
|
||||
public static bool CheckTarget(string target)
|
||||
{
|
||||
return string.IsNullOrEmpty(target);
|
||||
}
|
||||
|
||||
public static string GetUnityPackagePath(string parentFolder, string unityPackageName) {
|
||||
var request = Client.List(true);
|
||||
while(request.IsCompleted == false) {
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
var pkgs = request.Result;
|
||||
if (pkgs == null)
|
||||
return "";
|
||||
foreach (var pkg in pkgs) {
|
||||
if (pkg.name == unityPackageName) {
|
||||
if (pkg.source == PackageSource.Local)
|
||||
return pkg.resolvedPath;
|
||||
else if (pkg.source == PackageSource.Embedded)
|
||||
return pkg.resolvedPath;
|
||||
else {
|
||||
return pkg.resolvedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static bool HandlerIOSSetting(string path, string appDataPath, string resourceName,
|
||||
string modulePackageName,
|
||||
string moduleName, string[] bundleNames, string target, string projPath, PBXProject proj)
|
||||
{
|
||||
|
||||
var resourcePath = Path.Combine(path, resourceName);
|
||||
|
||||
var parentFolder = Directory.GetParent(appDataPath).FullName;
|
||||
|
||||
Debug.Log($"ProjectFolder path:{parentFolder}");
|
||||
|
||||
if (Directory.Exists(resourcePath))
|
||||
{
|
||||
Directory.Delete(resourcePath, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(resourcePath);
|
||||
|
||||
var remotePackagePath = GetUnityPackagePath(parentFolder, modulePackageName);
|
||||
|
||||
var assetLocalPackagePath = TapFileHelper.FilterFileByPrefix(parentFolder + "/Assets/TapTap/", moduleName);
|
||||
|
||||
var localPackagePath = TapFileHelper.FilterFileByPrefix(parentFolder, moduleName);
|
||||
|
||||
var tdsResourcePath = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(remotePackagePath))
|
||||
{
|
||||
tdsResourcePath = remotePackagePath;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(assetLocalPackagePath))
|
||||
{
|
||||
tdsResourcePath = assetLocalPackagePath;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(localPackagePath))
|
||||
{
|
||||
tdsResourcePath = localPackagePath;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tdsResourcePath)) {
|
||||
throw new Exception(string.Format("Can't find tdsResourcePath with module of : {0}", modulePackageName));
|
||||
}
|
||||
|
||||
tdsResourcePath = $"{tdsResourcePath}/Plugins/iOS/Resource";
|
||||
|
||||
Debug.Log($"Find {moduleName} path:{tdsResourcePath}");
|
||||
|
||||
if (!Directory.Exists(tdsResourcePath)) {
|
||||
throw new Exception(string.Format("Can't Find {0}", tdsResourcePath));
|
||||
}
|
||||
|
||||
TapFileHelper.CopyAndReplaceDirectory(tdsResourcePath, resourcePath);
|
||||
foreach (var name in bundleNames) {
|
||||
var relativePath = GetRelativePath(Path.Combine(resourcePath, name), path);
|
||||
var fileGuid = proj.AddFile(relativePath, relativePath, PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(target, fileGuid);
|
||||
}
|
||||
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string GetRelativePath(string absolutePath, string rootPath) {
|
||||
if (Directory.Exists(rootPath) && !rootPath.EndsWith(Path.AltDirectorySeparatorChar.ToString())) {
|
||||
rootPath += Path.AltDirectorySeparatorChar;
|
||||
}
|
||||
Uri aboslutePathUri = new Uri(absolutePath);
|
||||
Uri rootPathUri = new Uri(rootPath);
|
||||
var relateivePath = rootPathUri.MakeRelativeUri(aboslutePathUri).ToString();
|
||||
Debug.LogFormat($"[TapCommonCompile] GetRelativePath absolutePath:{absolutePath} rootPath:{rootPath} relateivePath:{relateivePath} ");
|
||||
return relateivePath;
|
||||
}
|
||||
|
||||
public static bool HandlerPlist(string pathToBuildProject, string infoPlistPath, bool macos = false)
|
||||
{
|
||||
// #if UNITY_2020_1_OR_NEWER
|
||||
// var macosXCodePlistPath =
|
||||
// $"{pathToBuildProject}/{PlayerSettings.productName}/Info.plist";
|
||||
// #elif UNITY_2019_1_OR_NEWER
|
||||
// var macosXCodePlistPath =
|
||||
// $"{Path.GetDirectoryName(pathToBuildProject)}/{PlayerSettings.productName}/Info.plist";
|
||||
// #endif
|
||||
|
||||
string plistPath;
|
||||
|
||||
if (pathToBuildProject.EndsWith(".app"))
|
||||
{
|
||||
plistPath = $"{pathToBuildProject}/Contents/Info.plist";
|
||||
}
|
||||
else
|
||||
{
|
||||
var macosXCodePlistPath =
|
||||
$"{Path.GetDirectoryName(pathToBuildProject)}/{PlayerSettings.productName}/Info.plist";
|
||||
if (!File.Exists(macosXCodePlistPath))
|
||||
{
|
||||
macosXCodePlistPath = $"{pathToBuildProject}/{PlayerSettings.productName}/Info.plist";
|
||||
}
|
||||
|
||||
plistPath = !macos
|
||||
? pathToBuildProject + "/Info.plist"
|
||||
: macosXCodePlistPath;
|
||||
}
|
||||
|
||||
Debug.Log($"plist path:{plistPath}");
|
||||
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromString(File.ReadAllText(plistPath));
|
||||
var rootDic = plist.root;
|
||||
|
||||
var items = new List<string>
|
||||
{
|
||||
"tapsdk",
|
||||
"tapiosdk",
|
||||
"taptap"
|
||||
};
|
||||
|
||||
if (!(rootDic["LSApplicationQueriesSchemes"] is PlistElementArray plistElementList))
|
||||
{
|
||||
plistElementList = rootDic.CreateArray("LSApplicationQueriesSchemes");
|
||||
}
|
||||
|
||||
foreach (var t in items)
|
||||
{
|
||||
plistElementList.AddString(t);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(infoPlistPath)) return false;
|
||||
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
|
||||
var taptapId = "";
|
||||
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (item.Key.Equals("taptap"))
|
||||
{
|
||||
var taptapDic = (Dictionary<string, object>) item.Value;
|
||||
foreach (var taptapItem in taptapDic.Where(taptapItem => taptapItem.Key.Equals("client_id")))
|
||||
{
|
||||
taptapId = (string) taptapItem.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rootDic.SetString(item.Key, item.Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//添加url
|
||||
var dict = plist.root.AsDict();
|
||||
if (!(dict["CFBundleURLTypes"] is PlistElementArray array))
|
||||
{
|
||||
array = dict.CreateArray("CFBundleURLTypes");
|
||||
}
|
||||
|
||||
if (!macos)
|
||||
{
|
||||
var dict2 = array.AddDict();
|
||||
dict2.SetString("CFBundleURLName", "TapTap");
|
||||
var array2 = dict2.CreateArray("CFBundleURLSchemes");
|
||||
array2.AddString($"tt{taptapId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var dict2 = array.AddDict();
|
||||
dict2.SetString("CFBundleURLName", "TapWeb");
|
||||
var array2 = dict2.CreateArray("CFBundleURLSchemes");
|
||||
array2.AddString($"open-taptap-{taptapId}");
|
||||
}
|
||||
|
||||
Debug.Log("TapSDK change plist Success");
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetValueFromPlist(string infoPlistPath, string key)
|
||||
{
|
||||
if (infoPlistPath == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
|
||||
return (from item in dic where item.Key.Equals(key) select (string) item.Value).FirstOrDefault();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5475af505e04119831448fe963f9c2c
|
||||
timeCreated: 1617120740
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using System.IO;
|
||||
using UnityEditor;
|
||||
# if UNITY_IOS
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
# if UNITY_IOS
|
||||
public static class TapCommonIOSProcessor
|
||||
{
|
||||
// 添加标签,unity导出工程后自动执行该函数
|
||||
[PostProcessBuild(99)]
|
||||
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS) return;
|
||||
|
||||
// 获得工程路径
|
||||
var projPath = TapCommonCompile.GetProjPath(path);
|
||||
var proj = TapCommonCompile.ParseProjPath(projPath);
|
||||
var target = TapCommonCompile.GetUnityTarget(proj);
|
||||
var unityFrameworkTarget = TapCommonCompile.GetUnityFrameworkTarget(proj);
|
||||
|
||||
if (TapCommonCompile.CheckTarget(target))
|
||||
{
|
||||
Debug.LogError("Unity-iPhone is NUll");
|
||||
return;
|
||||
}
|
||||
|
||||
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
|
||||
proj.AddBuildProperty(unityFrameworkTarget, "OTHER_LDFLAGS", "-ObjC");
|
||||
|
||||
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
|
||||
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
|
||||
proj.SetBuildProperty(target, "SWIFT_VERSION", "5.0");
|
||||
proj.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
|
||||
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "ENABLE_BITCODE", "NO");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "SWIFT_VERSION", "5.0");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "CLANG_ENABLE_MODULES", "YES");
|
||||
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "MobileCoreServices.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "WebKit.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "Security.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "CoreTelephony.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
|
||||
|
||||
proj.AddFileToBuild(unityFrameworkTarget,
|
||||
proj.AddFile("usr/lib/libc++.tbd", "libc++.tbd", PBXSourceTree.Sdk));
|
||||
|
||||
proj.AddFileToBuild(unityFrameworkTarget,
|
||||
proj.AddFile("usr/lib/libsqlite3.tbd", "libsqlite3.tbd", PBXSourceTree.Sdk));
|
||||
|
||||
if (TapCommonCompile.HandlerIOSSetting(path,
|
||||
Application.dataPath,
|
||||
"TapCommonResource",
|
||||
"com.taptap.tds.common",
|
||||
"Common",
|
||||
new[] {"TapCommonResource.bundle"},
|
||||
target, projPath, proj))
|
||||
{
|
||||
Debug.Log("TapCommon add Bundle Success!");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogError("TapCommon add Bundle Failed!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28d4870389ed406eac7c8849da60c644
|
||||
timeCreated: 1617120740
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public class TapFileHelper : System.IDisposable
|
||||
{
|
||||
private string filePath;
|
||||
|
||||
public TapFileHelper(string fPath)
|
||||
{
|
||||
filePath = fPath;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
Debug.LogError(filePath + "路径下文件不存在");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteBelow(string below, string text)
|
||||
{
|
||||
StreamReader streamReader = new StreamReader(filePath);
|
||||
string all = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
|
||||
if (beginIndex == -1)
|
||||
{
|
||||
Debug.LogError(filePath + "中没有找到字符串" + below);
|
||||
return;
|
||||
}
|
||||
|
||||
int endIndex = all.LastIndexOf("\n", beginIndex + below.Length, StringComparison.Ordinal);
|
||||
all = all.Substring(0, endIndex) + "\n" + text + "\n" + all.Substring(endIndex);
|
||||
StreamWriter streamWriter = new StreamWriter(filePath);
|
||||
streamWriter.Write(all);
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
public void Replace(string below, string newText)
|
||||
{
|
||||
StreamReader streamReader = new StreamReader(filePath);
|
||||
string all = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
|
||||
if (beginIndex == -1)
|
||||
{
|
||||
Debug.LogError(filePath + "中没有找到字符串" + below);
|
||||
return;
|
||||
}
|
||||
|
||||
all = all.Replace(below, newText);
|
||||
StreamWriter streamWriter = new StreamWriter(filePath);
|
||||
streamWriter.Write(all);
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public static void CopyAndReplaceDirectory(string srcPath, string dstPath)
|
||||
{
|
||||
if (Directory.Exists(dstPath))
|
||||
Directory.Delete(dstPath, true);
|
||||
if (File.Exists(dstPath))
|
||||
File.Delete(dstPath);
|
||||
|
||||
Directory.CreateDirectory(dstPath);
|
||||
|
||||
foreach (var file in Directory.GetFiles(srcPath))
|
||||
File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)));
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcPath))
|
||||
CopyAndReplaceDirectory(dir, Path.Combine(dstPath, Path.GetFileName(dir)));
|
||||
}
|
||||
|
||||
|
||||
public static void DeleteFileBySuffix(string dir, string[] suffix)
|
||||
{
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var file in Directory.GetFiles(dir))
|
||||
{
|
||||
foreach (var suffixName in suffix)
|
||||
{
|
||||
if (file.Contains(suffixName))
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string FilterFileByPrefix(string srcPath, string filterName)
|
||||
{
|
||||
if (!Directory.Exists(srcPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcPath))
|
||||
{
|
||||
string fileName = Path.GetFileName(dir);
|
||||
if (fileName.StartsWith(filterName))
|
||||
{
|
||||
return Path.Combine(srcPath, Path.GetFileName(dir));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string FilterFileBySuffix(string srcPath, string suffix)
|
||||
{
|
||||
if (!Directory.Exists(srcPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcPath))
|
||||
{
|
||||
string fileName = Path.GetFileName(dir);
|
||||
if (fileName.StartsWith(suffix))
|
||||
{
|
||||
return Path.Combine(srcPath, Path.GetFileName(dir));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FileInfo RecursionFilterFile(string dir, string fileName)
|
||||
{
|
||||
List<FileInfo> fileInfoList = new List<FileInfo>();
|
||||
Director(dir, fileInfoList);
|
||||
foreach (FileInfo item in fileInfoList)
|
||||
{
|
||||
if (fileName.Equals(item.Name))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Director(string dir, List<FileInfo> list)
|
||||
{
|
||||
DirectoryInfo d = new DirectoryInfo(dir);
|
||||
FileInfo[] files = d.GetFiles();
|
||||
DirectoryInfo[] directs = d.GetDirectories();
|
||||
foreach (FileInfo f in files)
|
||||
{
|
||||
list.Add(f);
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo dd in directs)
|
||||
{
|
||||
Director(dd.FullName, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d1556fcb81944af6a42170d3e1c99269
|
||||
timeCreated: 1617120740
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.Common.Editor",
|
||||
"references": [
|
||||
"GUID:0b3f64ec33f5b4da98a17367a35b82f2"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 616cea76def2d4f059b94440fc8cc03d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7b757cf9569ee1469081df1e8e79931
|
||||
folderAsset: yes
|
||||
timeCreated: 1533042733
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="ScrollViewEditor.cs" company="AillieoTech">
|
||||
// Copyright (c) AillieoTech. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace TapTap.UI.AillieoTech
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[CustomEditor(typeof(ScrollView))]
|
||||
public class ScrollViewEditor : ScrollRectEditor
|
||||
{
|
||||
private const string bgPath = "UI/Skin/Background.psd";
|
||||
private const string spritePath = "UI/Skin/UISprite.psd";
|
||||
private const string maskPath = "UI/Skin/UIMask.psd";
|
||||
private static Color panelColor = new Color(1f, 1f, 1f, 0.392f);
|
||||
private static Color defaultSelectableColor = new Color(1f, 1f, 1f, 1f);
|
||||
private static Vector2 thinElementSize = new Vector2(160f, 20f);
|
||||
private static Action<GameObject, MenuCommand> PlaceUIElementRoot;
|
||||
|
||||
private SerializedProperty itemTemplate;
|
||||
private SerializedProperty poolSize;
|
||||
private SerializedProperty defaultItemSize;
|
||||
private SerializedProperty layoutType;
|
||||
|
||||
private GUIStyle cachedCaption;
|
||||
|
||||
private GUIStyle caption
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.cachedCaption == null)
|
||||
{
|
||||
this.cachedCaption = new GUIStyle { richText = true, alignment = TextAnchor.MiddleCenter };
|
||||
}
|
||||
|
||||
return this.cachedCaption;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
this.serializedObject.Update();
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
EditorGUILayout.LabelField("<b>Additional configs</b>", this.caption);
|
||||
EditorGUILayout.Space();
|
||||
this.DrawConfigInfo();
|
||||
this.serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
EditorGUILayout.LabelField("<b>For original ScrollRect</b>", this.caption);
|
||||
EditorGUILayout.Space();
|
||||
base.OnInspectorGUI();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected static void InternalAddScrollView<T>(MenuCommand menuCommand)
|
||||
where T : ScrollView
|
||||
{
|
||||
GetPrivateMethodByReflection();
|
||||
|
||||
GameObject root = CreateUIElementRoot(typeof(T).Name, new Vector2(200, 200));
|
||||
PlaceUIElementRoot?.Invoke(root, menuCommand);
|
||||
|
||||
GameObject viewport = CreateUIObject("Viewport", root);
|
||||
GameObject content = CreateUIObject("Content", viewport);
|
||||
|
||||
var parent = menuCommand.context as GameObject;
|
||||
if (parent != null)
|
||||
{
|
||||
root.transform.SetParent(parent.transform, false);
|
||||
}
|
||||
|
||||
Selection.activeGameObject = root;
|
||||
|
||||
GameObject hScrollbar = CreateScrollbar();
|
||||
hScrollbar.name = "Scrollbar Horizontal";
|
||||
hScrollbar.transform.SetParent(root.transform, false);
|
||||
RectTransform hScrollbarRT = hScrollbar.GetComponent<RectTransform>();
|
||||
hScrollbarRT.anchorMin = Vector2.zero;
|
||||
hScrollbarRT.anchorMax = Vector2.right;
|
||||
hScrollbarRT.pivot = Vector2.zero;
|
||||
hScrollbarRT.sizeDelta = new Vector2(0, hScrollbarRT.sizeDelta.y);
|
||||
|
||||
GameObject vScrollbar = CreateScrollbar();
|
||||
vScrollbar.name = "Scrollbar Vertical";
|
||||
vScrollbar.transform.SetParent(root.transform, false);
|
||||
vScrollbar.GetComponent<Scrollbar>().SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
RectTransform vScrollbarRT = vScrollbar.GetComponent<RectTransform>();
|
||||
vScrollbarRT.anchorMin = Vector2.right;
|
||||
vScrollbarRT.anchorMax = Vector2.one;
|
||||
vScrollbarRT.pivot = Vector2.one;
|
||||
vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0);
|
||||
|
||||
RectTransform viewportRect = viewport.GetComponent<RectTransform>();
|
||||
viewportRect.anchorMin = Vector2.zero;
|
||||
viewportRect.anchorMax = Vector2.one;
|
||||
viewportRect.sizeDelta = Vector2.zero;
|
||||
viewportRect.pivot = Vector2.up;
|
||||
|
||||
RectTransform contentRect = content.GetComponent<RectTransform>();
|
||||
contentRect.anchorMin = Vector2.up;
|
||||
contentRect.anchorMax = Vector2.one;
|
||||
contentRect.sizeDelta = new Vector2(0, 300);
|
||||
contentRect.pivot = Vector2.up;
|
||||
|
||||
ScrollView scrollRect = root.AddComponent<T>();
|
||||
scrollRect.content = contentRect;
|
||||
scrollRect.viewport = viewportRect;
|
||||
scrollRect.horizontalScrollbar = hScrollbar.GetComponent<Scrollbar>();
|
||||
scrollRect.verticalScrollbar = vScrollbar.GetComponent<Scrollbar>();
|
||||
scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
scrollRect.horizontalScrollbarSpacing = -3;
|
||||
scrollRect.verticalScrollbarSpacing = -3;
|
||||
|
||||
Image rootImage = root.AddComponent<Image>();
|
||||
rootImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(bgPath);
|
||||
rootImage.type = Image.Type.Sliced;
|
||||
rootImage.color = panelColor;
|
||||
|
||||
Mask viewportMask = viewport.AddComponent<Mask>();
|
||||
viewportMask.showMaskGraphic = false;
|
||||
|
||||
Image viewportImage = viewport.AddComponent<Image>();
|
||||
viewportImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(maskPath);
|
||||
viewportImage.type = Image.Type.Sliced;
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
this.itemTemplate = this.serializedObject.FindProperty("itemTemplate");
|
||||
this.poolSize = this.serializedObject.FindProperty("poolSize");
|
||||
this.defaultItemSize = this.serializedObject.FindProperty("defaultItemSize");
|
||||
this.layoutType = this.serializedObject.FindProperty("layoutType");
|
||||
}
|
||||
|
||||
protected virtual void DrawConfigInfo()
|
||||
{
|
||||
EditorGUILayout.PropertyField(this.itemTemplate);
|
||||
EditorGUILayout.PropertyField(this.poolSize);
|
||||
EditorGUILayout.PropertyField(this.defaultItemSize);
|
||||
this.layoutType.intValue = (int)(ScrollView.ItemLayoutType)EditorGUILayout.EnumPopup("layoutType", (ScrollView.ItemLayoutType)this.layoutType.intValue);
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/DynamicScrollView", false, 90)]
|
||||
private static void AddScrollView(MenuCommand menuCommand)
|
||||
{
|
||||
InternalAddScrollView<ScrollView>(menuCommand);
|
||||
}
|
||||
|
||||
private static GameObject CreateScrollbar()
|
||||
{
|
||||
// Create GOs Hierarchy
|
||||
GameObject scrollbarRoot = CreateUIElementRoot("Scrollbar", thinElementSize);
|
||||
GameObject sliderArea = CreateUIObject("Sliding Area", scrollbarRoot);
|
||||
GameObject handle = CreateUIObject("Handle", sliderArea);
|
||||
|
||||
Image bgImage = scrollbarRoot.AddComponent<Image>();
|
||||
bgImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(bgPath);
|
||||
bgImage.type = Image.Type.Sliced;
|
||||
bgImage.color = defaultSelectableColor;
|
||||
|
||||
Image handleImage = handle.AddComponent<Image>();
|
||||
handleImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(spritePath);
|
||||
handleImage.type = Image.Type.Sliced;
|
||||
handleImage.color = defaultSelectableColor;
|
||||
|
||||
RectTransform sliderAreaRect = sliderArea.GetComponent<RectTransform>();
|
||||
sliderAreaRect.sizeDelta = new Vector2(-20, -20);
|
||||
sliderAreaRect.anchorMin = Vector2.zero;
|
||||
sliderAreaRect.anchorMax = Vector2.one;
|
||||
|
||||
RectTransform handleRect = handle.GetComponent<RectTransform>();
|
||||
handleRect.sizeDelta = new Vector2(20, 20);
|
||||
|
||||
Scrollbar scrollbar = scrollbarRoot.AddComponent<Scrollbar>();
|
||||
scrollbar.handleRect = handleRect;
|
||||
scrollbar.targetGraphic = handleImage;
|
||||
SetDefaultColorTransitionValues(scrollbar);
|
||||
|
||||
return scrollbarRoot;
|
||||
}
|
||||
|
||||
private static GameObject CreateUIElementRoot(string name, Vector2 size)
|
||||
{
|
||||
var child = new GameObject(name);
|
||||
RectTransform rectTransform = child.AddComponent<RectTransform>();
|
||||
rectTransform.sizeDelta = size;
|
||||
return child;
|
||||
}
|
||||
|
||||
private static GameObject CreateUIObject(string name, GameObject parent)
|
||||
{
|
||||
var go = new GameObject(name);
|
||||
go.AddComponent<RectTransform>();
|
||||
SetParentAndAlign(go, parent);
|
||||
return go;
|
||||
}
|
||||
|
||||
private static void SetParentAndAlign(GameObject child, GameObject parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
child.transform.SetParent(parent.transform, false);
|
||||
SetLayerRecursively(child, parent.layer);
|
||||
}
|
||||
|
||||
private static void SetLayerRecursively(GameObject go, int layer)
|
||||
{
|
||||
go.layer = layer;
|
||||
Transform t = go.transform;
|
||||
for (var i = 0; i < t.childCount; i++)
|
||||
{
|
||||
SetLayerRecursively(t.GetChild(i).gameObject, layer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetDefaultColorTransitionValues(Selectable slider)
|
||||
{
|
||||
ColorBlock colors = slider.colors;
|
||||
colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f);
|
||||
colors.pressedColor = new Color(0.698f, 0.698f, 0.698f);
|
||||
colors.disabledColor = new Color(0.521f, 0.521f, 0.521f);
|
||||
}
|
||||
|
||||
private static void GetPrivateMethodByReflection()
|
||||
{
|
||||
if (PlaceUIElementRoot == null)
|
||||
{
|
||||
Assembly uiEditorAssembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.FirstOrDefault(asm => asm.GetName().Name == "UnityEditor.UI");
|
||||
if (uiEditorAssembly != null)
|
||||
{
|
||||
Type menuOptionType = uiEditorAssembly.GetType("UnityEditor.UI.MenuOptions");
|
||||
if (menuOptionType != null)
|
||||
{
|
||||
MethodInfo miPlaceUIElementRoot = menuOptionType.GetMethod(
|
||||
"PlaceUIElementRoot",
|
||||
BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (miPlaceUIElementRoot != null)
|
||||
{
|
||||
PlaceUIElementRoot = Delegate.CreateDelegate(
|
||||
typeof(Action<GameObject, MenuCommand>),
|
||||
miPlaceUIElementRoot)
|
||||
as Action<GameObject, MenuCommand>;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8518bb829bc508049a52f0606b4f43a5
|
||||
timeCreated: 1533042733
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="ScrollViewExEditor.cs" company="AillieoTech">
|
||||
// Copyright (c) AillieoTech. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace TapTap.UI.AillieoTech
|
||||
{
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(ScrollViewEx))]
|
||||
public class ScrollViewExEditor : ScrollViewEditor
|
||||
{
|
||||
private SerializedProperty pageSize;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
this.pageSize = this.serializedObject.FindProperty("pageSize");
|
||||
}
|
||||
|
||||
protected override void DrawConfigInfo()
|
||||
{
|
||||
base.DrawConfigInfo();
|
||||
EditorGUILayout.PropertyField(this.pageSize);
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI/DynamicScrollViewEx", false, 90)]
|
||||
private static void AddScrollViewEx(MenuCommand menuCommand)
|
||||
{
|
||||
InternalAddScrollView<ScrollViewEx>(menuCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 12cd1055a4162f842842a60918857100
|
||||
timeCreated: 1533042733
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.UI.Editor",
|
||||
"references": [
|
||||
"GUID:0b3f64ec33f5b4da98a17367a35b82f2"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d577628a069ab4cdc87654cc7ac4b6a4
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 64083c9579506486096d4c0d2a2a8932
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2d6d99aa661049e6a8c5c365f940e5d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using TapTap.Common.Editor;
|
||||
|
||||
namespace TapTap.Common.Mobile.Editor {
|
||||
public class TapCommonMobileProcessBuild : SDKLinkProcessBuild {
|
||||
public override int callbackOrder => 0;
|
||||
|
||||
public override string LinkPath => "TapTap/Common/link.xml";
|
||||
|
||||
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
|
||||
new LinkedAssembly { Fullname = "TapTap.Common.Runtime" },
|
||||
new LinkedAssembly { Fullname = "TapTap.Common.Mobile.Runtime" }
|
||||
};
|
||||
|
||||
public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
|
||||
return BuildTargetUtils.IsSupportMobile(report.summary.platform);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2f0b99f7553794a8791cee0ebb2c953a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "TapTap.Common.Mobile.Editor",
|
||||
"references": [
|
||||
"GUID:616cea76def2d4f059b94440fc8cc03d"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 747e53b1749584bae9386571797e5eb5
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23fedb802d153432e9b7e8e2dca2d3f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d613cbf7e66b4849b75f0c17665043d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7665fa69688034f88b96e3926a190a78
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,80 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e01d04d4b428e45508e87e973497dbe5
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARM64
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
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:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0fa75c5d7ce549c08ab2fb6353034b8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,80 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 495d1cc3f857842969280c751449b7b9
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
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:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2cb022b37682044e79bd0db5efd0a371
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,80 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 31dfb9eef734041ab91abbac30e8fc0e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 1
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
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:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CPU: AnyCPU
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8357dd3b84a964d1595e1977d6d63177
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TapTap.Common
|
||||
{
|
||||
public class EngineBridge
|
||||
{
|
||||
private static volatile EngineBridge _sInstance;
|
||||
|
||||
private readonly IBridge _bridge;
|
||||
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
public static EngineBridge GetInstance()
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
if (_sInstance == null)
|
||||
{
|
||||
_sInstance = new EngineBridge();
|
||||
}
|
||||
}
|
||||
|
||||
return _sInstance;
|
||||
}
|
||||
|
||||
private EngineBridge()
|
||||
{
|
||||
if (Platform.IsAndroid())
|
||||
{
|
||||
_bridge = BridgeAndroid.GetInstance();
|
||||
}
|
||||
else if (Platform.IsIOS())
|
||||
{
|
||||
_bridge = BridgeIOS.GetInstance();
|
||||
}
|
||||
}
|
||||
|
||||
public void Register(string serviceClzName, string serviceImplName)
|
||||
{
|
||||
_bridge?.Register(serviceClzName, serviceImplName);
|
||||
}
|
||||
|
||||
public void CallHandler(Command command)
|
||||
{
|
||||
_bridge?.Call(command);
|
||||
}
|
||||
|
||||
public void CallHandler(Command command, Action<Result> action)
|
||||
{
|
||||
_bridge?.Call(command, action);
|
||||
}
|
||||
|
||||
public Task<Result> Emit(Command command)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<Result>();
|
||||
CallHandler(command, result =>
|
||||
{
|
||||
tcs.TrySetResult(result);
|
||||
});
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static bool CheckResult(Result result)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.code != Result.RESULT_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !string.IsNullOrEmpty(result.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a59ea35d6e5c450194ab8bd34973ae7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common
|
||||
{
|
||||
public class BridgeAndroid : IBridge
|
||||
{
|
||||
private string bridgeJavaClz = "com.tds.common.bridge.Bridge";
|
||||
|
||||
private string instanceMethod = "getInstance";
|
||||
|
||||
private string registerHandlerMethod = "registerHandler";
|
||||
|
||||
private string callHandlerMethod = "callHandler";
|
||||
|
||||
private string initMethod = "init";
|
||||
|
||||
private string registerMethod = "register";
|
||||
|
||||
private readonly AndroidJavaObject _mAndroidBridge;
|
||||
|
||||
private static readonly BridgeAndroid SInstance = new BridgeAndroid();
|
||||
|
||||
public static BridgeAndroid GetInstance()
|
||||
{
|
||||
return SInstance;
|
||||
}
|
||||
|
||||
private BridgeAndroid()
|
||||
{
|
||||
var mCurrentActivity =
|
||||
new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
|
||||
_mAndroidBridge = new AndroidJavaClass(bridgeJavaClz).CallStatic<AndroidJavaObject>(instanceMethod);
|
||||
_mAndroidBridge.Call(initMethod, mCurrentActivity);
|
||||
}
|
||||
|
||||
public void Register(string serviceClzName, string serviceImplName)
|
||||
{
|
||||
if (_mAndroidBridge == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var serviceClass = new AndroidJavaClass(serviceClzName);
|
||||
var serviceImpl = new AndroidJavaObject(serviceImplName);
|
||||
_mAndroidBridge.Call(registerMethod, serviceClass, serviceImpl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log("register Failed:" + e);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(Command command, Action<Result> action)
|
||||
{
|
||||
_mAndroidBridge?.Call(registerHandlerMethod, command.ToJSON(), new BridgeCallback(action));
|
||||
}
|
||||
|
||||
public void Call(Command command)
|
||||
{
|
||||
_mAndroidBridge?.Call(callHandlerMethod, command.ToJSON());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a30539bf2c5c4b9e891293fc7bd563b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common
|
||||
{
|
||||
|
||||
public class BridgeCallback : AndroidJavaProxy
|
||||
{
|
||||
Action<Result> callback;
|
||||
|
||||
public BridgeCallback(Action<Result> action) :
|
||||
base(new AndroidJavaClass("com.tds.common.bridge.BridgeCallback"))
|
||||
{
|
||||
this.callback = action;
|
||||
}
|
||||
|
||||
public override AndroidJavaObject Invoke(string method, object[] args)
|
||||
{
|
||||
if (method.Equals("onResult"))
|
||||
{
|
||||
if (args[0] is string)
|
||||
{
|
||||
string result = (string)(args[0]);
|
||||
callback(new Result(result));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c7e2835d962a4a4997c93212b4a1171
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common
|
||||
{
|
||||
public class BridgeIOS : IBridge
|
||||
{
|
||||
private static readonly BridgeIOS SInstance = new BridgeIOS();
|
||||
|
||||
private readonly ConcurrentDictionary<string, Action<Result>> dic;
|
||||
|
||||
public static BridgeIOS GetInstance()
|
||||
{
|
||||
return SInstance;
|
||||
}
|
||||
|
||||
private BridgeIOS()
|
||||
{
|
||||
dic = new ConcurrentDictionary<string, Action<Result>>();
|
||||
}
|
||||
|
||||
private ConcurrentDictionary<string, Action<Result>> GetConcurrentDictionary()
|
||||
{
|
||||
return dic;
|
||||
}
|
||||
|
||||
private delegate void EngineBridgeDelegate(string result);
|
||||
|
||||
[AOT.MonoPInvokeCallbackAttribute(typeof(EngineBridgeDelegate))]
|
||||
static void engineBridgeDelegate(string resultJson)
|
||||
{
|
||||
var result = new Result(resultJson);
|
||||
|
||||
var actionDic = GetInstance().GetConcurrentDictionary();
|
||||
|
||||
Action<Result> action = null;
|
||||
|
||||
if (actionDic != null && actionDic.ContainsKey(result.callbackId))
|
||||
{
|
||||
action = actionDic[result.callbackId];
|
||||
}
|
||||
|
||||
if (action != null)
|
||||
{
|
||||
action(result);
|
||||
if (result.onceTime && BridgeIOS.GetInstance().GetConcurrentDictionary()
|
||||
.TryRemove(result.callbackId, out Action<Result> outAction))
|
||||
{
|
||||
Debug.Log($"TapSDK resolved current Action:{result.callbackId}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"TapSDK iOS BridgeAction last Count:{BridgeIOS.GetInstance().GetConcurrentDictionary().Count}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Register(string serviceClz, string serviceImp)
|
||||
{
|
||||
//IOS无需注册
|
||||
}
|
||||
|
||||
public void Call(Command command)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
callHandler(command.ToJSON());
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Call(Command command, Action<Result> action)
|
||||
{
|
||||
if (!command.callback || string.IsNullOrEmpty(command.callbackId)) return;
|
||||
if (!dic.ContainsKey(command.callbackId))
|
||||
{
|
||||
dic.GetOrAdd(command.callbackId, action);
|
||||
}
|
||||
#if UNITY_IOS
|
||||
registerHandler(command.ToJSON(), engineBridgeDelegate);
|
||||
#endif
|
||||
}
|
||||
#if UNITY_IOS
|
||||
[DllImport("__Internal")]
|
||||
private static extern void callHandler(string command);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void registerHandler(string command, EngineBridgeDelegate engineBridgeDelegate);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5a68a7cfba514945b6fba56b7086ea8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue