internal static bool IsRCForThisEditor(string packageName, VettingContext context) { // RC is a joined state between a package and an editor version (package a is a candidate for editor x) // we can detect RCs if the package has a prerelease tag, but is added to the editor // I can get this info only in 2021.1+ // packageInfo.unityLifecycle.version = version field directly found in the editor manifest // use reflection to get the packageInfo.unityLifecycle.version field #if UNITY_2021_1_OR_NEWER var packageInfo = context.GetPackageInfo(packageName); if (packageInfo != null) { var unityLifecycle = typeof(PackageInfo) .GetField("m_UnityLifecycle", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(packageInfo); var unityLifecycleVersion = Type.GetType("UnityEditor.PackageManager.UnityLifecycle.UnityLifecycleInfo, UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null") .GetField("m_Version", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(unityLifecycle); return(packageInfo.version == (string)unityLifecycleVersion && packageInfo.version.Contains("-")); } return(false); #else return(false); #endif }
/** * Use this to know which package phase or which relationship it has for a given editor. Release Candidate (RC) is not a phase. It is a status that is applied on top of the existing phase, meaning that the package is being stabilised towards release. * However, if you need to know only the phase of the package, then use GetLifecyclePhase */ internal static LifecyclePhase GetLifecyclePhaseOrRelation(string version, string packageName, VettingContext context) { if (IsRCForThisEditor(packageName, context)) { return(LifecyclePhase.ReleaseCandidate); } return(GetLifecyclePhase(version)); }