Ptest.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using PottingMobileSDK.MiniJSON;
  5. using System;
  6. using System.IO;
  7. using PottingMobileSDK;
  8. using UnityEngine.UI;
  9. public class Ptest : MonoBehaviour
  10. {
  11. //事件名称
  12. string loadVideo = "load\nRewarded";
  13. string loadInters = "load\nInterstitial";
  14. string loadBanner = "load\nbanner";
  15. string loadAppOpen = "load\nApp Open";
  16. string showAppOpen = "Show\nApp Open";
  17. string showVideo = "Show\nRewarded Video";
  18. string showInters = "show\nInterstitial";
  19. string gameCenterLogin = "GameCenter 登录";
  20. string sev_login = "Login";
  21. string sev_UploadScore = "Upload\nScore";
  22. string sev_GetUserRank = "Get\nUserRank";
  23. string sev_DedeemConsume = "dedeem\nConsume";
  24. string sev_HeartBeat = "Heart\nbeat";
  25. string sev_PayGetAppVersion = "channel\nPayGetAppVersion";
  26. string sev_getActivitiesWithChannel = "getActivitiesWithChannel";
  27. string sev_channelPayOrder = "channel\nPayOrder";
  28. string sev_userSync = "userSync";
  29. string sev_feedback = "feedback";
  30. string sev_userResumePurchase = "userResume\npurchase";
  31. string sev_userConsume = "userConsume";
  32. string sev_redeemConsume = "redeemConsume";
  33. string sev_userQueryOrder = "userQueryOrdery";
  34. string sev_configSync = "config\nSync";
  35. string shareFB = "shareFB\nimg";
  36. string sev_redeemUserConsume = "redeemUser\nConsume";
  37. string InternalPay = "Internal\nPay";
  38. string sev_Serverinfo = "Server\ninfo";
  39. string loadInterstitialRewarded = "load\nInterstitialRewarded";
  40. string showInterstitialRewarded = "show\nInterstitialRewarded";
  41. string loadGame = "load\ngame";
  42. string uploadGame = "upload\ngame";
  43. string deleGame = "dele\ngame";
  44. string loadAllGame = "load all\ngame";
  45. string resloveGame = "reslove\ngame";
  46. public static string[] PlaySearchStr =
  47. {
  48. "com.ccgame.dartordie_1", "com.ccgame.dartordie_2", "com.ccgame.dartordie_3",
  49. "com.ccgame.dartordie_4", "awards_per_month"
  50. };
  51. private void Awake()
  52. {
  53. }
  54. // Start is called before the first frame update
  55. void Start()
  56. {
  57. //创建滚动视图
  58. string[] nameArr =
  59. {
  60. loadAppOpen, showAppOpen, loadInterstitialRewarded, showInterstitialRewarded, loadVideo, showVideo,
  61. loadInters, showInters,
  62. loadBanner, shareFB, InternalPay, gameCenterLogin,
  63. sev_login, sev_UploadScore, sev_GetUserRank, sev_DedeemConsume, sev_redeemUserConsume, sev_HeartBeat,
  64. sev_PayGetAppVersion, sev_getActivitiesWithChannel, sev_channelPayOrder, sev_userSync, sev_feedback,
  65. sev_userResumePurchase, sev_userConsume, sev_redeemConsume, sev_userQueryOrder, sev_configSync,
  66. sev_Serverinfo, loadGame, uploadGame, deleGame, loadAllGame, resloveGame
  67. };
  68. #if UNITY_EDITOR
  69. GameObject canvas = GameObject.Find("Canvas");
  70. Vector2 size = new Vector2(canvas.GetComponent<RectTransform>().sizeDelta.x,
  71. canvas.GetComponent<RectTransform>().sizeDelta.y / 2.0f);
  72. #else
  73. Vector2 size = new Vector2(Screen.width - 20, (float)(Screen.height * 0.5));
  74. #endif
  75. Debug.Log("当前屏幕分辨率:" + Screen.currentResolution + " ,屏幕宽高:(" + Screen.width + "," + Screen.height + ")" +
  76. " ,DPI:" + Screen.dpi);
  77. Debug.Log("ScrollView大小为:" + size);
  78. ScroolTest.Instance.InitScrollview(nameArr, new Vector3(Screen.width / 2, Screen.height / 3, 0), size,
  79. new Vector2((size.x - 10) * 0.5f, 100));
  80. //设置滚动视图回调
  81. ScroolTest.Instance.ButtonBeClickEvent += ButtonBeClickEvent;
  82. //文本视图
  83. //广告SDK
  84. PottingMobile.InitializeSdk();
  85. PottingMobile.withLogDebug(true);
  86. PottingMobileManger.Instance.MGetADIDEvent += MGetADIDEvent;
  87. PottingMobileManger.Instance.MhasRewardedVideoEvent += MhasRewardedVideoEvent;
  88. PottingMobileManger.Instance.MloginDidCompleteEvent += MloginDidCompleteEvent;
  89. PottingMobileManger.Instance.MOnSkuDetailEvent += MOnSkuDetailEvent;
  90. PottingMobileManger.Instance.MOnConversionDataEvent += MOnConversionDataEvent;
  91. PottingMobileManger.Instance.MOnImpressionDataEvent += MOnImpressionDataEvent;
  92. PottingMobileManger.Instance.MOnRewardedVideoLoadedEvent += MOnRewardedVideoLoadedEvent;
  93. PottingMobileManger.Instance.MOnRewardedVideoReceivedRewardEvent += MOnRewardedVideoReceivedRewardEvent;
  94. PottingMobileManger.Instance.MOnRewardedVideoClosedEvent += MOnRewardedVideoClosedEvent;
  95. PottingMobileManger.Instance.MOnInterstitialShownEvent += MOnInterstitialShownEvent;
  96. PottingMobileManger.Instance.MloginUseFacebookEvent += MloginUseFacebookEvent;
  97. PottingMobileManger.Instance.MloginGameEvent += MloginGameCenterEvent;
  98. //google服务 gameCenter
  99. PottingMobileServicesManger.Instance.LoginStatusEvent += LoginStatusEvent;
  100. PottingMobileServicesManger.Instance.UserLoginResponsesEvent += UserLoginResponsesEvent;
  101. PottingMobileServicesManger.Instance.UserUploadScoreResponsesEvent += UserUploadScoreResponsesEvent;
  102. PottingMobileServicesManger.Instance.UserGetUserRankResponsesEvent += UserGetUserRankResponsesEvent;
  103. PottingMobileServicesManger.Instance.DedeemConsumeResponsesEvent += DedeemConsumeResponsesEvent;
  104. PottingMobileServicesManger.Instance.UserHeartbeatResponsesEvent += UserHeartbeatResponsesEvent;
  105. PottingMobileServicesManger.Instance.ConfigSyncResponsesEvent += ConfigSyncResponsesEvent;
  106. PottingMobileServicesManger.Instance.ChannelpayGetAppVersionResponsesEvent +=
  107. ChannelpayGetAppVersionResponsesEvent;
  108. PottingMobileServicesManger.Instance.GetActivitiesWithChannelkEvent += GetActivitiesWithChannelkEvent;
  109. PottingMobileServicesManger.Instance.GameAnoncementsWithChannelEvent += GameAnoncementsWithChannelEvent;
  110. //存档
  111. PottingMobileManger.Instance.MloadGameEvent += MloadGameEvent;
  112. PottingMobileManger.Instance.MsaveGameEvent += MsaveGameEvent;
  113. PottingMobileManger.Instance.MdeleteGameEvent += MdeleteGameEvent;
  114. PottingMobileManger.Instance.MloadAllGameEvent += MloadAllGameEvent;
  115. PottingMobileManger.Instance.MresolveConflictGameEvent += MresolveConflictGameEvent;
  116. //接口测试
  117. PottingMobileServicesManger.Instance.ChannelpayOrderResponsesEvent += ChannelpayOrderResponsesEvent;
  118. PottingMobileServicesManger.Instance.UserSyncResponsesEvent += UserSyncResponsesEvent;
  119. PottingMobileServicesManger.Instance.UserOrderResponsesEvent += UserOrderResponsesEvent;
  120. PottingMobileServicesManger.Instance.UserResumepurchaseResponsesEvent += UserResumepurchaseResponsesEvent;
  121. PottingMobileServicesManger.Instance.UserConsumeResponsesEvent += UserConsumeResponsesEvent;
  122. PottingMobileServicesManger.Instance.UserQueryOrderResponsesEvent += UserQueryOrderResponsesEvent;
  123. PottingMobileServicesManger.Instance.RedeemConsumeEvent += RedeemConsumeEvent;
  124. PottingMobileServicesManger.Instance.RedeemUserConsumeEvent += RedeemUserConsumeEvent;
  125. PottingMobileServicesManger.Instance.ServerinfoEvent += ServerinfoEvent;
  126. PottingMobileManger.Instance.MShareCompleteEvent += MShareCompleteEvent;
  127. PottingMobileManger.Instance.MOnPayResultEvent += MOnPayResultEvent;
  128. PottingMobileManger.Instance.MValidateEvent += MValidateEvent;
  129. PottingMobileManger.Instance.MOnRewardedInterstitialClosedEvent += MOnRewardedInterstitialClosedEvent;
  130. PottingMobileManger.Instance.MOnRewardedInterstitialReceivedRewardEvent +=
  131. MOnRewardedInterstitialReceivedRewardEvent;
  132. PottingMobileManger.Instance.MOnRewardedInterstitialLoadedEvent += MOnRewardedInterstitialLoadedEvent;
  133. PottingMobileManger.Instance.MOnRewardedInterstitialFailedEvent += MOnRewardedInterstitialFailedEvent;
  134. PottingMobileManger.Instance.MOnAppOpenAdLoadedEvent += MOnAppOpenAdLoadedEvent;
  135. PottingMobileManger.Instance.MOnAppOpenAdFailedEvent += MOnAppOpenAdFailedEvent;
  136. PottingMobileManger.Instance.MOnAppOpenAdShownEvent += MOnAppOpenAdShownEvent;
  137. PottingMobileManger.Instance.MOnAppOpenAdClosedEvent += MOnAppOpenAdClosedEvent;
  138. //string json = "[\n" +
  139. // " {\n" +
  140. // " \"orderId\" : \"1000000627660493\",\n" +
  141. // " \"purchaseTime\" : \"2020-02-17 10:38:28\",\n" +
  142. // " \"productId\" : \"com.youloft.mummy.99\"\n" +
  143. // " }\n" +
  144. // "]";
  145. //var data = Json.Deserialize(json) as List<object>;
  146. //foreach (var i in data) {
  147. // var dict = i as Dictionary<string, object>;
  148. // string orderId=(string)dict["orderId"];
  149. // string purchaseTime= (string)dict["purchaseTime"];
  150. // string productId = (string)dict["productId"];
  151. //}
  152. PottingMobile._querySkuDetail(PlaySearchStr);
  153. PottingMobileManger.Instance.MGetADIDEvent += MGetADIDEvent;
  154. PottingMobile._GetADID();
  155. }
  156. private void MGetADIDEvent(string obj)
  157. {
  158. Debug.Log("MGetADIDEvent--" + obj);
  159. addText("MGetADIDEvent--" + obj);
  160. }
  161. private void MloadGameEvent(string obj)
  162. {
  163. Debug.Log("MloadGameEvent--" + obj);
  164. addText("MloadGameEvent--" + obj);
  165. }
  166. private void MsaveGameEvent(string obj)
  167. {
  168. Debug.Log("MsaveGameEvent--" + obj);
  169. addText("MsaveGameEvent--" + obj);
  170. }
  171. private void MdeleteGameEvent(string obj)
  172. {
  173. Debug.Log("MdeleteGameEvent--" + obj);
  174. addText("MdeleteGameEvent--" + obj);
  175. }
  176. private void MloadAllGameEvent(string obj)
  177. {
  178. Debug.Log("MloadAllGameEvent--" + obj);
  179. addText("MloadAllGameEvent--" + obj);
  180. }
  181. private void MresolveConflictGameEvent(string obj)
  182. {
  183. Debug.Log("MresolveConflictGameEvent--" + obj);
  184. addText("MresolveConflictGameEvent--" + obj);
  185. }
  186. private void MOnAppOpenAdLoadedEvent(string obj)
  187. {
  188. Debug.Log("MOnAppOpenAdLoadedEvent--" + obj);
  189. addText("MOnAppOpenAdLoadedEvent--" + obj);
  190. }
  191. private void MOnAppOpenAdFailedEvent(string obj, string errs)
  192. {
  193. Debug.Log("MOnAppOpenAdFailedEvent--" + obj);
  194. addText("MOnAppOpenAdFailedEvent--" + obj);
  195. }
  196. private void MOnAppOpenAdShownEvent(string obj)
  197. {
  198. Debug.Log("MOnAppOpenAdShownEvent--" + obj);
  199. addText("MOnAppOpenAdShownEvent--" + obj);
  200. }
  201. private void MOnAppOpenAdClosedEvent(string obj)
  202. {
  203. Debug.Log("MOnAppOpenAdClosedEvent--" + obj);
  204. addText("MOnAppOpenAdClosedEvent--" + obj);
  205. }
  206. private void MOnRewardedInterstitialReceivedRewardEvent(string arg1, string arg2, float arg3)
  207. {
  208. Debug.Log("MOnRewardedInterstitialReceivedRewardEvent--");
  209. addText("MOnRewardedInterstitialReceivedRewardEvent--");
  210. }
  211. private void MOnRewardedInterstitialFailedEvent(string arg1, string arg2)
  212. {
  213. Debug.Log("MOnRewardedInterstitialFailedEvent--" + arg1);
  214. addText("MOnRewardedInterstitialFailedEvent--" + arg1);
  215. }
  216. private void MOnRewardedInterstitialLoadedEvent(string obj)
  217. {
  218. Debug.Log("MOnRewardedInterstitialLoadedEvent--" + obj);
  219. addText("MOnRewardedInterstitialLoadedEvent--" + obj);
  220. }
  221. private void MOnRewardedInterstitialClosedEvent(string obj)
  222. {
  223. Debug.Log("MOnRewardedInterstitialClosedEvent--" + obj);
  224. addText("MOnRewardedInterstitialClosedEvent--" + obj);
  225. }
  226. private void ServerinfoEvent(string obj)
  227. {
  228. Debug.Log("ServerinfoEvent--" + obj);
  229. addText("ServerinfoEvent--" + obj);
  230. }
  231. private void MValidateEvent(string obj)
  232. {
  233. Debug.Log("MValidateEvent--" + obj);
  234. addText("MValidateEvent--" + obj);
  235. }
  236. private void MOnPayResultEvent(string obj)
  237. {
  238. Debug.Log("MOnPayResultEvent--" + obj);
  239. addText("MOnPayResultEvent--" + obj);
  240. }
  241. private void RedeemUserConsumeEvent(string obj)
  242. {
  243. Debug.Log("RedeemUserConsumeEvent--" + obj);
  244. addText("RedeemUserConsumeEvent--" + obj);
  245. }
  246. private void MShareCompleteEvent(string obj)
  247. {
  248. addText("MShareCompleteEvent--" + obj);
  249. }
  250. private void MloginUseFacebookEvent(string obj)
  251. {
  252. Debug.Log("MloginUseFacebookEvent--" + obj);
  253. addText("MloginUseFacebookEvent--" + obj);
  254. }
  255. private void MloginGameCenterEvent(string obj)
  256. {
  257. Debug.Log("MloginGameCenterEvent--" + obj);
  258. addText("MloginGameCenterEvent--" + obj);
  259. }
  260. private void MOnImpressionDataEvent(string obj)
  261. {
  262. Debug.Log("ImpressionData--" + obj);
  263. }
  264. private void MOnConversionDataEvent(string obj)
  265. {
  266. Debug.Log("onversionData--" + obj);
  267. }
  268. private void MOnSkuDetailEvent(string obj)
  269. {
  270. Debug.Log("sku价格回调--" + obj);
  271. }
  272. private void MloginDidCompleteEvent(string obj)
  273. {
  274. Debug.Log("登录的回调--" + obj);
  275. }
  276. private void MhasRewardedVideoEvent(Dictionary<string, object> obj)
  277. {
  278. foreach (var item in obj)
  279. {
  280. Debug.Log(item.Key + "的值" + item.Value);
  281. Debug.Log(item.Key + "---" + PottingMobile._HasRewardedVideo(item.Key));
  282. }
  283. }
  284. private void MOnInterstitialShownEvent(string obj)
  285. {
  286. addText("MOnInterstitialShownEvent--");
  287. }
  288. private void MOnRewardedVideoClosedEvent(string obj)
  289. {
  290. addText("MOnRewardedVideoClosedEvent--");
  291. }
  292. private void MOnRewardedVideoReceivedRewardEvent(string arg1, string arg2, float arg3)
  293. {
  294. addText("MOnRewardedVideoReceivedRewardEvent--");
  295. }
  296. private void MOnRewardedVideoLoadedEvent(string obj)
  297. {
  298. addText("MOnRewardedVideoLoadedEvent--广告加载完成");
  299. PottingMobile._SetLocalNotification(1, "广告加载完成", "广告已经加载成功", 1);
  300. }
  301. private void GameAnoncementsWithChannelEvent(string obj)
  302. {
  303. Debug.Log("GameAnoncementsWithChannelEvent--" + obj);
  304. }
  305. private void GetActivitiesWithChannelkEvent(string obj)
  306. {
  307. Debug.Log("GetActivitiesWithChannelkEvent--" + obj);
  308. }
  309. private void ChannelpayGetAppVersionResponsesEvent(string obj)
  310. {
  311. Debug.Log("ChannelpayGetAppVersionResponsesEvent--" + obj);
  312. }
  313. private void ConfigSyncResponsesEvent(string obj)
  314. {
  315. Debug.Log("ConfigSyncResponsesEvent--" + obj);
  316. }
  317. private void UserLoginResponsesEvent(string obj)
  318. {
  319. Debug.Log("UserLoginResponsesEvent--" + obj);
  320. }
  321. private void UserHeartbeatResponsesEvent(string obj)
  322. {
  323. Debug.Log("UserHeartbeatResponsesEvent--" + obj);
  324. }
  325. private void DedeemConsumeResponsesEvent(string obj)
  326. {
  327. Debug.Log("DedeemConsumeResponsesEvent--" + obj);
  328. }
  329. private void UserGetUserRankResponsesEvent(string obj)
  330. {
  331. Debug.Log("UserGetUserRankResponsesEvent--" + obj);
  332. }
  333. private void UserUploadScoreResponsesEvent(string obj)
  334. {
  335. Debug.Log("UserUploadScoreResponsesEvent--" + obj);
  336. }
  337. private void LoginStatusEvent(string obj)
  338. {
  339. Debug.Log("LoginStatusEvent--" + obj);
  340. }
  341. //接口回调
  342. private void RedeemConsumeEvent(string obj)
  343. {
  344. Debug.Log("RedeemConsumeEvent--" + obj);
  345. }
  346. private void UserQueryOrderResponsesEvent(string obj)
  347. {
  348. Debug.Log("UserQueryOrderResponsesEvent--" + obj);
  349. }
  350. private void UserConsumeResponsesEvent(string obj)
  351. {
  352. Debug.Log("UserConsumeResponsesEvent--" + obj);
  353. }
  354. private void UserResumepurchaseResponsesEvent(string obj)
  355. {
  356. Debug.Log("UserResumepurchaseResponsesEvent--" + obj);
  357. }
  358. private void UserOrderResponsesEvent(string obj)
  359. {
  360. Debug.Log("UserOrderResponsesEvent--" + obj);
  361. }
  362. private void UserSyncResponsesEvent(string obj)
  363. {
  364. Debug.Log("UserSyncResponsesEvent--" + obj);
  365. }
  366. private void ChannelpayOrderResponsesEvent(string obj)
  367. {
  368. Debug.Log("ChannelpayOrderResponsesEvent--" + obj);
  369. }
  370. //滚动视图回调
  371. private void ButtonBeClickEvent(int idx, string btnName)
  372. {
  373. Debug.Log("ButtonBeClickEvent--" + btnName);
  374. if (btnName.Equals(loadAppOpen))
  375. {
  376. PottingMobile._LoadAppOpenAd();
  377. }
  378. if (btnName.Equals(showAppOpen))
  379. {
  380. PottingMobile._ShowAppOpenAd();
  381. }
  382. if (btnName.Equals(loadInterstitialRewarded))
  383. {
  384. PottingMobile._LoadRewardedInterstitialAd();
  385. }
  386. if (btnName.Equals(showInterstitialRewarded))
  387. {
  388. PottingMobile._ShowRewardedInterstitialAd();
  389. }
  390. if (btnName.Equals(sev_Serverinfo))
  391. {
  392. PottingMobileServices._Serverinfo();
  393. }
  394. if (btnName.Equals(loadVideo))
  395. {
  396. PottingMobile._LoadRewardedVideoAd();
  397. addText("load ..Rewarded");
  398. }
  399. if (btnName.Equals(loadInters))
  400. {
  401. PottingMobile._LoadInterstitialAd();
  402. addText("load ..Interstitial");
  403. }
  404. if (btnName.Equals(loadBanner))
  405. {
  406. PottingMobile._LoadAndShowBannerAd(PottingMobileBase.AdPosition.BottomCenter,
  407. PottingMobileBase.AdSize.H_50);
  408. addText("load ..banner");
  409. }
  410. if (btnName.Equals(showVideo))
  411. {
  412. Debug.Log("hasvideo--" + PottingMobile._HasRewardedVideo());
  413. //这个函数是unity函数
  414. PottingMobile._ShowRewardedVideoAd();
  415. addText("Show ..Rewarded Video");
  416. }
  417. if (btnName.Equals(showInters))
  418. {
  419. PottingMobile._ShowInterstitialAd();
  420. addText("Show ..Interstitial");
  421. }
  422. if (btnName.Equals(gameCenterLogin))
  423. {
  424. PottingMobile._GameLogin();
  425. addText("GameCenter 登录");
  426. }
  427. //服务
  428. if (btnName.Equals(sev_login))
  429. {
  430. PottingMobileServices._userLogin("test", 0, "test", "test");
  431. }
  432. if (btnName.Equals(sev_UploadScore))
  433. {
  434. PottingMobileServices._userUploadScore(10, "测试排行榜描述第10名", "900a4b40-783e-4c1e-b77d-d75570ae23ce");
  435. }
  436. if (btnName.Equals(sev_GetUserRank))
  437. {
  438. PottingMobileServices._userGetUserRank("900a4b40-783e-4c1e-b77d-d75570ae23ce");
  439. }
  440. if (btnName.Equals(sev_DedeemConsume))
  441. {
  442. PottingMobileServices._dedeemConsume("TEST000309");
  443. }
  444. if (btnName.Equals(sev_HeartBeat))
  445. {
  446. PottingMobileServices._userHeartbeat();
  447. }
  448. if (btnName.Equals(sev_PayGetAppVersion))
  449. {
  450. PottingMobileServices._channelPayGetAppVersion(3);
  451. }
  452. if (btnName.Equals(sev_getActivitiesWithChannel))
  453. {
  454. Debug.Log("Potting-->getActivitiesWithChannel");
  455. PottingMobileServices._getActivitiesWithChannel("0", "CN");
  456. PottingMobileServices._getGameAnoncementsWithChannel("3", "2.0", "CN");
  457. }
  458. if (btnName.Equals(sev_channelPayOrder))
  459. {
  460. #if UNITY_EDITOR
  461. PottingMobileServices._channelPayOrder(7, "900a0733-2e50-4479-99b9-df331e4fbab8");
  462. #elif UNITY_ANDROID
  463. PottingMobileServices._channelPayOrder(7, "900a0733-2e50-4479-99b9-df331e4fbab8");
  464. #else
  465. #endif
  466. }
  467. if (btnName.Equals(sev_userSync))
  468. {
  469. PottingMobileServices._userSync("", 11);
  470. }
  471. if (btnName.Equals(sev_feedback))
  472. {
  473. PottingMobile._showFeedBackHtml();
  474. }
  475. if (btnName.Equals(sev_userResumePurchase))
  476. {
  477. PottingMobileServices._userResumepurchase();
  478. }
  479. if (btnName.Equals(sev_userConsume))
  480. {
  481. PottingMobileServices._userConsume("900a0733-2e50-4479-99b9-df331e4fbab8",
  482. "c8ac1773-ab8b-4728-952d-ab7901127006");
  483. }
  484. if (btnName.Equals(sev_redeemConsume))
  485. {
  486. PottingMobileServices._redeemConsume("202006031603", "3");
  487. }
  488. if (btnName.Equals(sev_userQueryOrder))
  489. {
  490. PottingMobileServices._userQueryOrder("900a0733-2e50-4479-99b9-df331e4fbab8",
  491. "915b9ad0-bb55-47c9-81b2-ab7900f1b81e");
  492. }
  493. if (btnName.Equals(sev_configSync))
  494. {
  495. PottingMobileServices._configSync("11", 10);
  496. }
  497. if (btnName.Equals(shareFB))
  498. {
  499. SaveScreenShot(this, new Rect(0, 0, Screen.width, Screen.height),
  500. (s) => { PottingMobile._uploadPhoto(s); });
  501. }
  502. if (btnName.Equals(sev_redeemUserConsume))
  503. {
  504. PottingMobileServices._redeemUserConsume("TEST000309", "0", "");
  505. }
  506. if (btnName.Equals(InternalPay))
  507. {
  508. PottingMobile._InternalPay("com.ccgame.dartordie_1");
  509. }
  510. if (btnName.Equals(loadGame))
  511. {
  512. PottingMobile._LoadGame("UserData");
  513. }
  514. if (btnName.Equals(uploadGame))
  515. {
  516. PottingMobile._SavedGame("UserData", "qwewqe122dadqweqwe");
  517. PottingMobile._SavedGame("GameConfig", "ckxzjkljkweq564786478");
  518. PottingMobile._SavedGame("ObjcConfig",
  519. "faxzwqewwfagaxzcaaczwqeqqgvaczdsadqwrqxzlkcjklasdklv,nza shdakdhoqwhczsblk");
  520. }
  521. if (btnName.Equals(deleGame))
  522. {
  523. PottingMobile._DeleteGame("UserData");
  524. }
  525. if (btnName.Equals(loadAllGame))
  526. {
  527. PottingMobile._LoadAllGame();
  528. }
  529. if (btnName.Equals(resloveGame))
  530. {
  531. PottingMobile._ResolveConflictGame("UserData", "change by func: ResolveConflictGame");
  532. }
  533. }
  534. // Update is called once per frame
  535. void Update()
  536. {
  537. }
  538. //unity渲染截图 左下起点 (0,0)
  539. public static IEnumerator ScreenShot(Rect rect, Action<Texture2D> outTextrue)
  540. {
  541. //只在每一帧渲染完成后才读取屏幕信息
  542. yield return new WaitForEndOfFrame();
  543. // 先创建一个的空纹理,大小可根据实现需要来设置
  544. Texture2D screenShot = new Texture2D((int)(rect.width - rect.x), (int)(rect.height - rect.y),
  545. TextureFormat.RGB24, false);
  546. // 读取屏幕像素信息并存储为纹理数据,
  547. screenShot.ReadPixels(rect, 0, 0);
  548. screenShot.Apply();
  549. outTextrue?.Invoke(screenShot);
  550. }
  551. //保存图片的app目录下
  552. public static void SaveScreenShot(MonoBehaviour behaviour, Rect rect, Action<string> outPath = null)
  553. {
  554. behaviour.StartCoroutine(ScreenShot(rect, texture2D =>
  555. {
  556. string imgDir = Application.persistentDataPath + "/IMG";
  557. if (!Directory.Exists(imgDir)) Directory.CreateDirectory(imgDir);
  558. string fileName = $"{Application.productName}_1111.png";
  559. string imgPath = Path.Combine(imgDir, fileName);
  560. byte[] imgData = texture2D.EncodeToPNG();
  561. File.WriteAllBytes(imgPath, imgData);
  562. outPath?.Invoke(imgPath);
  563. }));
  564. }
  565. private void addText(string s)
  566. {
  567. }
  568. }