LoadSamplesSettings.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Reflection;
  5. using UnityEditor;
  6. using UnityEngine;
  7. using UnityEngine.XR;
  8. using UnityEditor.PackageManager;
  9. using UnityEditor.PackageManager.Requests;
  10. public class LoadSamplesSettings
  11. {
  12. [MenuItem("GHZ/GHZXRLoadSamples/RemoveALL")]
  13. public static void RemoveALLInit()
  14. {
  15. try
  16. {
  17. FileUtil.DeleteFileOrDirectory("Assets/Immersal");
  18. }
  19. catch
  20. {
  21. }
  22. try
  23. {
  24. FileUtil.DeleteFileOrDirectory("Assets/AVProPlayer");
  25. }
  26. catch
  27. {
  28. }
  29. try
  30. {
  31. FileUtil.DeleteFileOrDirectory("Assets/GHZSDK");
  32. }
  33. catch
  34. {
  35. }
  36. try
  37. {
  38. FileUtil.DeleteFileOrDirectory("Assets/TriLibXR");
  39. }
  40. catch
  41. {
  42. }
  43. try
  44. {
  45. FileUtil.DeleteFileOrDirectory("Assets/LoginXR");
  46. }
  47. catch
  48. {
  49. }
  50. try
  51. {
  52. FileUtil.DeleteFileOrDirectory("Assets/OOBEPackage");
  53. }
  54. catch
  55. {
  56. }
  57. try
  58. {
  59. FileUtil.DeleteFileOrDirectory("Assets/LiveKitRTC");
  60. }
  61. catch
  62. {
  63. }
  64. try
  65. {
  66. FileUtil.DeleteFileOrDirectory("Assets/YiYanPackage");
  67. }
  68. catch
  69. {
  70. }
  71. List<string> strlist = new List<string>();
  72. strlist.Add("jh.xr.engine");
  73. strlist.Add("con.ghz.login");
  74. strlist.Add("con.ghz.obe");
  75. strlist.Add("com.maxst.unilivekit");
  76. strlist.Add("com.ghz.yiyan");
  77. strlist.Add("jh.trilib.engine");
  78. strlist.Add("com.ghz.avideoplayer");
  79. strlist.Add("jh.immersalsdk.engine");
  80. strlist.Add("com.ximmerse.xr");
  81. strlist.Add("com.unity.xr.arcore");
  82. strlist.Add("com.unity.xr.arfoundation");
  83. strlist.Add("com.unity.webrtc");
  84. strlist.Add("com.cysharp.unitask");
  85. strlist.Add("com.unity.inputsystem");
  86. strlist.Add("com.ghz.xr");
  87. strlist.Add("com.ghz.mqtt");
  88. ListRequest request = Client.List(true);
  89. while (!request.IsCompleted)
  90. {
  91. System.Threading.Thread.Sleep(500);
  92. // 等待PackageManager请求完成
  93. }
  94. List<string> strlist2 = new List<string>();
  95. Directory.CreateDirectory("Assets/LoginXR");
  96. // AssetDatabase.Refresh();
  97. EditorApplication.delayCall += () =>
  98. {
  99. System.Threading.Thread.Sleep(1000);
  100. if (request.Status == StatusCode.Success)
  101. {
  102. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  103. {
  104. if (strlist.Contains(package.name)) // 替换为你的Package名称
  105. {
  106. strlist2.Add(package.name);
  107. }
  108. }
  109. }
  110. else
  111. {
  112. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  113. }
  114. if(strlist2.Count>0)
  115. {
  116. AddAndRemoveRequest rest = Client.AddAndRemove(null, strlist2.ToArray());
  117. while (!rest.IsCompleted)
  118. {
  119. // 等待PackageManager请求完成
  120. System.Threading.Thread.Sleep(500);
  121. }
  122. }
  123. Debug.Log("RemoveBack Error=1=>");
  124. AssetDatabase.Refresh();
  125. };
  126. }
  127. [MenuItem("GHZ/GHZXRLoadSamples/LoadALL")]
  128. public static void LoadALLInit()
  129. {
  130. ListRequest request = Client.List(true);
  131. Debug.Log("LoadALLInit");
  132. if(GHZSDKSettings.loadSDKType!=null)
  133. {
  134. if(GHZSDKSettings.isNewSDK)
  135. {
  136. PlayerSDKLoadSamplesSet(request, GHZSDKSettings.loadSDKType);
  137. }else
  138. {
  139. PlayerShadowSDKSamplesSet(request);
  140. }
  141. }
  142. PlayerAVProSamplesSet(request);
  143. PlayerImmersalSamplesSet(request);
  144. PlayerTriLibSamplesSet(request);
  145. PlayerYiTanSamplesSet(request);
  146. PlayerLiveSamplesSet(request);
  147. PlayerOOBESamplesSet(request);
  148. PlayerLoginSamplesSet(request);
  149. PlayerBaseSamplesSet(request);
  150. PlayerMQTTSamplesSet(request);
  151. }
  152. public static void PlayerMQTTSamplesSet(ListRequest request)
  153. {
  154. try
  155. {
  156. FileUtil.DeleteFileOrDirectory("Assets/MQTT");
  157. }
  158. catch
  159. {
  160. }
  161. AssetDatabase.Refresh();
  162. System.Threading.Thread.Sleep(1000);
  163. while (!request.IsCompleted)
  164. {
  165. System.Threading.Thread.Sleep(500);
  166. // 等待PackageManager请求完成
  167. }
  168. Directory.CreateDirectory("Assets/MQTT");
  169. AssetDatabase.Refresh();
  170. System.Threading.Thread.Sleep(1000);
  171. EditorApplication.delayCall += () =>
  172. {
  173. System.Threading.Thread.Sleep(1000);
  174. if (request.Status == StatusCode.Success)
  175. {
  176. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  177. {
  178. if (package.name == "com.ghz.mqtt") // 替换为你的Package名称
  179. {
  180. string packagePath = package.assetPath + "/package/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  181. string destinationPath = "Assets/MQTT/" + package.name; // 替换为你想要放置Samples的目标路径
  182. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  183. AssetDatabase.Refresh();
  184. }
  185. }
  186. }
  187. else
  188. {
  189. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  190. }
  191. };
  192. }
  193. public static void PlayerBaseSamplesSet(ListRequest request)
  194. {
  195. try
  196. {
  197. FileUtil.DeleteFileOrDirectory("Assets/BaseLoad");
  198. }
  199. catch
  200. {
  201. }
  202. AssetDatabase.Refresh();
  203. System.Threading.Thread.Sleep(1000);
  204. while (!request.IsCompleted)
  205. {
  206. System.Threading.Thread.Sleep(500);
  207. // 等待PackageManager请求完成
  208. }
  209. Directory.CreateDirectory("Assets/BaseLoad");
  210. AssetDatabase.Refresh();
  211. System.Threading.Thread.Sleep(1000);
  212. EditorApplication.delayCall += () =>
  213. {
  214. System.Threading.Thread.Sleep(1000);
  215. if (request.Status == StatusCode.Success)
  216. {
  217. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  218. {
  219. if (package.name == "jh.baseeditor.engine") // 替换为你的Package名称
  220. {
  221. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  222. string destinationPath = "Assets/BaseLoad/" + package.name; // 替换为你想要放置Samples的目标路径
  223. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  224. AssetDatabase.Refresh();
  225. }
  226. }
  227. }
  228. else
  229. {
  230. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  231. }
  232. };
  233. }
  234. public static void PlayerLoginSamplesSet(ListRequest request)
  235. {
  236. try
  237. {
  238. FileUtil.DeleteFileOrDirectory("Assets/LoginXR");
  239. }
  240. catch
  241. {
  242. }
  243. AssetDatabase.Refresh();
  244. System.Threading.Thread.Sleep(1000);
  245. while (!request.IsCompleted)
  246. {
  247. System.Threading.Thread.Sleep(500);
  248. // 等待PackageManager请求完成
  249. }
  250. Directory.CreateDirectory("Assets/LoginXR");
  251. AssetDatabase.Refresh();
  252. System.Threading.Thread.Sleep(1000);
  253. EditorApplication.delayCall += () =>
  254. {
  255. System.Threading.Thread.Sleep(1000);
  256. if (request.Status == StatusCode.Success)
  257. {
  258. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  259. {
  260. if (package.name == "con.ghz.login") // 替换为你的Package名称
  261. {
  262. string packagePath = package.assetPath + "/package/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  263. string destinationPath = "Assets/LoginXR/" + package.name; // 替换为你想要放置Samples的目标路径
  264. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  265. AssetDatabase.Refresh();
  266. }
  267. }
  268. }
  269. else
  270. {
  271. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  272. }
  273. };
  274. }
  275. public static void PlayerOOBESamplesSet(ListRequest request)
  276. {
  277. try
  278. {
  279. FileUtil.DeleteFileOrDirectory("Assets/OOBEPackage");
  280. }
  281. catch
  282. {
  283. }
  284. AssetDatabase.Refresh();
  285. System.Threading.Thread.Sleep(1000);
  286. while (!request.IsCompleted)
  287. {
  288. // 等待PackageManager请求完成
  289. System.Threading.Thread.Sleep(500);
  290. }
  291. Directory.CreateDirectory("Assets/OOBEPackage");
  292. AssetDatabase.Refresh();
  293. System.Threading.Thread.Sleep(1000);
  294. EditorApplication.delayCall += () =>
  295. {
  296. System.Threading.Thread.Sleep(1000);
  297. if (request.Status == StatusCode.Success)
  298. {
  299. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  300. {
  301. if (package.name == "con.ghz.obe") // 替换为你的Package名称
  302. {
  303. string packagePath = package.assetPath + "/package/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  304. string destinationPath = "Assets/OOBEPackage/" + package.name; // 替换为你想要放置Samples的目标路径
  305. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  306. AssetDatabase.Refresh();
  307. }
  308. }
  309. }
  310. else
  311. {
  312. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  313. }
  314. };
  315. }
  316. public static void PlayerLiveSamplesSet(ListRequest request)
  317. {
  318. try
  319. {
  320. FileUtil.DeleteFileOrDirectory("Assets/LiveKitRTC");
  321. }
  322. catch
  323. {
  324. }
  325. AssetDatabase.Refresh();
  326. System.Threading.Thread.Sleep(1000);
  327. while (!request.IsCompleted)
  328. {
  329. System.Threading.Thread.Sleep(500);
  330. // 等待PackageManager请求完成
  331. }
  332. Directory.CreateDirectory("Assets/LiveKitRTC");
  333. AssetDatabase.Refresh();
  334. System.Threading.Thread.Sleep(1000);
  335. EditorApplication.delayCall += () =>
  336. {
  337. System.Threading.Thread.Sleep(1000);
  338. if (request.Status == StatusCode.Success)
  339. {
  340. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  341. {
  342. if (package.name == "com.maxst.unilivekit") // 替换为你的Package名称
  343. {
  344. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  345. string destinationPath = "Assets/LiveKitRTC/" + package.name; // 替换为你想要放置Samples的目标路径
  346. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  347. AssetDatabase.Refresh();
  348. }
  349. }
  350. }
  351. else
  352. {
  353. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  354. }
  355. };
  356. }
  357. public static void PlayerYiTanSamplesSet(ListRequest request)
  358. {
  359. try
  360. {
  361. FileUtil.DeleteFileOrDirectory("Assets/YiYanPackage");
  362. }
  363. catch
  364. {
  365. }
  366. AssetDatabase.Refresh();
  367. System.Threading.Thread.Sleep(1000);
  368. while (!request.IsCompleted)
  369. {
  370. // 等待PackageManager请求完成
  371. System.Threading.Thread.Sleep(500);
  372. }
  373. Directory.CreateDirectory("Assets/YiYanPackage");
  374. AssetDatabase.Refresh();
  375. System.Threading.Thread.Sleep(1000);
  376. EditorApplication.delayCall += () =>
  377. {
  378. System.Threading.Thread.Sleep(1000);
  379. if (request.Status == StatusCode.Success)
  380. {
  381. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  382. {
  383. if (package.name == "com.ghz.yiyan") // 替换为你的Package名称
  384. {
  385. string packagePath = package.assetPath + "/package/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  386. string destinationPath = "Assets/YiYanPackage/" + package.name; // 替换为你想要放置Samples的目标路径
  387. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  388. AssetDatabase.Refresh();
  389. }
  390. }
  391. }
  392. else
  393. {
  394. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  395. }
  396. };
  397. }
  398. public static void PlayerTriLibSamplesSet(ListRequest request)
  399. {
  400. try
  401. {
  402. FileUtil.DeleteFileOrDirectory("Assets/TriLibXR");
  403. }
  404. catch
  405. {
  406. }
  407. AssetDatabase.Refresh();
  408. System.Threading.Thread.Sleep(1000);
  409. while (!request.IsCompleted)
  410. {
  411. // 等待PackageManager请求完成
  412. System.Threading.Thread.Sleep(500);
  413. }
  414. Directory.CreateDirectory("Assets/TriLibXR");
  415. AssetDatabase.Refresh();
  416. System.Threading.Thread.Sleep(1000);
  417. EditorApplication.delayCall += () =>
  418. {
  419. System.Threading.Thread.Sleep(1000);
  420. if (request.Status == StatusCode.Success)
  421. {
  422. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  423. {
  424. if (package.name == "jh.trilib.engine") // 替换为你的Package名称
  425. {
  426. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  427. string destinationPath = "Assets/TriLibXR/" + package.name; // 替换为你想要放置Samples的目标路径
  428. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  429. AssetDatabase.Refresh();
  430. }
  431. }
  432. }
  433. else
  434. {
  435. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  436. }
  437. };
  438. }
  439. public static void PlayerImmersalSamplesSet(ListRequest request)
  440. {
  441. try
  442. {
  443. FileUtil.DeleteFileOrDirectory("Assets/Immersal");
  444. }
  445. catch
  446. {
  447. }
  448. AssetDatabase.Refresh();
  449. System.Threading.Thread.Sleep(1000);
  450. Directory.CreateDirectory("Assets/Immersal");
  451. AssetDatabase.Refresh();
  452. System.Threading.Thread.Sleep(1000);
  453. while (!request.IsCompleted)
  454. {
  455. System.Threading.Thread.Sleep(500);
  456. // 等待PackageManager请求完成
  457. }
  458. AssetDatabase.Refresh();
  459. EditorApplication.delayCall += () =>
  460. {
  461. System.Threading.Thread.Sleep(1000);
  462. if (request.Status == StatusCode.Success)
  463. {
  464. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  465. {
  466. if (package.name == "jh.immersalsdk.engine") // 替换为你的Package名称
  467. {
  468. string packagePath = package.assetPath + "/package/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  469. string destinationPath = "Assets/Immersal/" + package.name; // 替换为你想要放置Samples的目标路径
  470. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  471. AssetDatabase.Refresh();
  472. }
  473. }
  474. }
  475. else
  476. {
  477. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  478. }
  479. };
  480. }
  481. public static void PlayerAVProSamplesSet(ListRequest request)
  482. {
  483. try
  484. {
  485. FileUtil.DeleteFileOrDirectory("Assets/AVProPlayer");
  486. }
  487. catch
  488. {
  489. }
  490. AssetDatabase.Refresh();
  491. System.Threading.Thread.Sleep(1000);
  492. Debug.Log("正在加载插件包:CreateDirectory");
  493. Directory.CreateDirectory("Assets/AVProPlayer");
  494. AssetDatabase.Refresh();
  495. System.Threading.Thread.Sleep(1000);
  496. while (!request.IsCompleted)
  497. {
  498. }
  499. AssetDatabase.Refresh();
  500. Debug.Log("正在加载插件包:IsCompleted");
  501. if (request.Status == StatusCode.Success)
  502. {
  503. Debug.Log("正在加载插件包:Success");
  504. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  505. {
  506. if (package.name == "com.ghz.avideoplayer") // 替换为你的Package名称
  507. {
  508. Debug.Log("正在加载插件包:package");
  509. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  510. EditorApplication.delayCall += () =>
  511. {
  512. Debug.Log("正在加载插件包:delayCall");
  513. System.Threading.Thread.Sleep(1000);
  514. string destinationPath = "Assets/AVProPlayer/" + package.name; // 替换为你想要放置Samples的目标路径
  515. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  516. AssetDatabase.Refresh();
  517. Debug.Log("正在加载插件包:Refresh");
  518. };
  519. }
  520. }
  521. }
  522. else
  523. {
  524. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  525. }
  526. }
  527. public static void PlayerShadowSDKSamplesSet(ListRequest request)
  528. {
  529. try
  530. {
  531. FileUtil.DeleteFileOrDirectory("Assets/GHZSDK");
  532. }
  533. catch
  534. {
  535. }
  536. AssetDatabase.Refresh();
  537. System.Threading.Thread.Sleep(1000);
  538. while (!request.IsCompleted)
  539. {
  540. System.Threading.Thread.Sleep(500);
  541. // 等待PackageManager请求完成
  542. }
  543. try
  544. {
  545. if (!Directory.Exists("Assets/Plugins/Android/"))
  546. {
  547. Directory.CreateDirectory("Assets/Plugins");
  548. Directory.CreateDirectory("Assets/Plugins/Android");
  549. }
  550. }
  551. catch
  552. {
  553. }
  554. try
  555. {
  556. if (File.Exists("Assets/Plugins/Android/AndroidManifest.xml"))
  557. {
  558. FileUtil.DeleteFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml");
  559. }
  560. }
  561. catch
  562. {
  563. }
  564. if (request.Status == StatusCode.Success)
  565. {
  566. Debug.Log("开始所搜是否有测试案例:");
  567. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  568. {
  569. if (package.name == "jh.xr.engine" || package.name == "com.ximmerse.xr" || package.name == "com.ghz.xr") // 替换为你的Package名称
  570. {
  571. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  572. string destinationPath = "Assets/GHZSDK/" + package.name; // 替换为你想要放置Samples的目标路径
  573. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  574. // if (type =="DreamGlass")
  575. // {
  576. Debug.Log("找到测试案例 进行复制:");
  577. packagePath = package.assetPath + "/Samples~/ShadowCreator/Plugins/Android/AndroidManifest.xml";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  578. destinationPath = "Assets/Plugins/Android/AndroidManifest.xml"; // 替换为你想要放置Samples的目标路径
  579. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  580. // }
  581. Debug.Log("找到测试案例 全部复制完成:");
  582. AssetDatabase.Refresh();
  583. }
  584. }
  585. }
  586. else
  587. {
  588. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  589. }
  590. // 模拟等待2秒
  591. // 在这里执行异步操作完成后的逻辑
  592. }
  593. public static void PlayerSDKLoadSamplesSet(ListRequest request ,string type)
  594. {
  595. try
  596. {
  597. FileUtil.DeleteFileOrDirectory("Assets/GHZSDK");
  598. }
  599. catch
  600. {
  601. }
  602. AssetDatabase.Refresh();
  603. while (!request.IsCompleted)
  604. {
  605. // 等待PackageManager请求完成
  606. }
  607. if (type == "DreamGlass")
  608. {
  609. try
  610. {
  611. if (!Directory.Exists("Assets/Plugins/Android/"))
  612. {
  613. Directory.CreateDirectory("Assets/Plugins");
  614. Directory.CreateDirectory("Assets/Plugins/Android");
  615. }
  616. }
  617. catch
  618. {
  619. }
  620. try
  621. {
  622. if (File.Exists("Assets/Plugins/Android/AndroidManifest.xml.OLD"))
  623. {
  624. FileUtil.DeleteFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml.OLD");
  625. }
  626. }
  627. catch
  628. {
  629. }
  630. try
  631. {
  632. if (File.Exists("Assets/Plugins/Android/AndroidManifest.xml"))
  633. {
  634. FileUtil.CopyFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml", "Assets/Plugins/Android/AndroidManifest.xml.OLD");
  635. FileUtil.DeleteFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml");
  636. }
  637. }
  638. catch
  639. {
  640. }
  641. }
  642. else
  643. {
  644. try
  645. {
  646. if (File.Exists("Assets/Plugins/Android/AndroidManifest.xml.OLD"))
  647. {
  648. if (File.Exists("Assets/Plugins/Android/AndroidManifest.xml"))
  649. {
  650. FileUtil.DeleteFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml");
  651. }
  652. FileUtil.CopyFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml.OLD", "Assets/Plugins/Android/AndroidManifest.xml");
  653. FileUtil.DeleteFileOrDirectory("Assets/Plugins/Android/AndroidManifest.xml.OLD");
  654. }
  655. }
  656. catch
  657. {
  658. }
  659. }
  660. if (request.Status == StatusCode.Success)
  661. {
  662. Debug.Log("开始所搜是否有测试案例:");
  663. foreach (UnityEditor.PackageManager.PackageInfo package in request.Result)
  664. {
  665. Debug.Log("开始所搜是否有测试案例:" + package.name);
  666. if (package.name == "jh.xr.engine" || package.name == "com.ximmerse.xr" || package.name == "com.ghz.xr") // 替换为你的Package名称
  667. {
  668. string packagePath = package.assetPath + "/Samples~";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  669. string destinationPath = "Assets/GHZSDK/" + package.name; // 替换为你想要放置Samples的目标路径
  670. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  671. if (type == "DreamGlass")
  672. {
  673. Debug.Log("找到测试案例 进行复制:");
  674. packagePath = package.assetPath + "/Samples~/SDK/Plugins/Android/AndroidManifest.xml";//"Packages/com.ghz.avideoplayer"; // 替换为你的Package路径
  675. destinationPath = "Assets/Plugins/Android/AndroidManifest.xml"; // 替换为你想要放置Samples的目标路径
  676. FileUtil.CopyFileOrDirectory(packagePath, destinationPath);
  677. }
  678. Debug.Log("找到测试案例 全部复制完成:");
  679. AssetDatabase.Refresh();
  680. }
  681. }
  682. }
  683. else
  684. {
  685. Debug.LogError("Failed to list installed packages: " + request.Error.message);
  686. }
  687. }
  688. }