123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //==========================================================
- //
- // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd.
- // All rights reserved.
- //
- //==========================================================
- using System.IO;
- using UnityEditor;
- namespace GxrSdk.Editor
- {
- /// <summary>
- /// gradle文件校验
- /// 根据Unity版本使用对应的gradle文件
- /// </summary>
- [InitializeOnLoad]
- public class GxrGradleVerify
- {
- /// <summary>
- /// 本地存放不同版本的Gradle文件的路径
- /// </summary>
- private static readonly string GradleFolder = "Assets/Plugins/Android/gradle/";
- /// <summary>
- /// launcherTemplate.gradle默认路径
- /// </summary>
- private static readonly string DestLauncherTemplateGradle = "Assets/Plugins/Android/launcherTemplate.gradle";
- /// <summary>
- /// mainTemplate.gradle默认路径
- /// </summary>
- private static readonly string DestMainTemplateGradle = "Assets/Plugins/Android/mainTemplate.gradle";
- static GxrGradleVerify()
- {
- EditorApplication.update += Update;
- }
- private static void Update()
- {
- EditorApplication.update -= Update;
- string launcherTemplateGradle = null;
- string mainTemplateGradle = null;
- #if UNITY_2022_1_OR_NEWER
- launcherTemplateGradle = GradleFolder + "Unity2022/launcherTemplate.gradle";
- #elif UNITY_2021_1_OR_NEWER
- launcherTemplateGradle = GradleFolder + "Unity2021/launcherTemplate.gradle";
- #elif UNITY_2020_1_OR_NEWER
- launcherTemplateGradle = GradleFolder + "Unity2020/launcherTemplate.gradle";
- #elif UNITY_2019_1_OR_NEWER
- launcherTemplateGradle = GradleFolder + "Unity2019/launcherTemplate.gradle";
- mainTemplateGradle = GradleFolder + "Unity2019/mainTemplate.gradle";
- #endif
- if (File.Exists(launcherTemplateGradle))
- {
- File.Copy(launcherTemplateGradle, DestLauncherTemplateGradle, true);
- }
- if (File.Exists(mainTemplateGradle))
- {
- File.Copy(mainTemplateGradle, DestMainTemplateGradle, true);
- }
- }
- }
- }
|