using System.Collections.Generic; using System.IO; using UnityEditor.AddressableAssets.Settings; namespace UnityEditor.AddressableAssets.Build.AnalyzeRules { /// /// Rule class to check resource dependencies for duplicates /// public class CheckResourcesDupeDependencies : BundleRuleBase { /// public override string ruleName { get { return "Check Resources to Addressable Duplicate Dependencies"; } } /// public override bool CanFix { get { return false; } } /// /// Clear analysis and calculate built in resources and corresponding bundle dependencies /// /// The current Addressables settings object /// List of results from analysis public override List RefreshAnalysis(AddressableAssetSettings settings) { ClearAnalysis(); AddressableAnalytics.ReportUsageEvent(AddressableAnalytics.UsageEventType.RunCheckResourcesDupeDependenciesRule); return CalculateBuiltInResourceDependenciesToBundleDependecies(settings, GetResourcePaths()); } /// public override void FixIssues(AddressableAssetSettings settings) { //Do nothing. There's nothing to fix. } /// internal protected override string[] GetResourcePaths() { string[] resourceDirectory = Directory.GetDirectories("Assets", "Resources", SearchOption.AllDirectories); List resourcePaths = new List(); foreach (string directory in resourceDirectory) resourcePaths.AddRange(Directory.GetFiles(directory, "*", SearchOption.AllDirectories)); return resourcePaths.ToArray(); } } [InitializeOnLoad] class RegisterCheckResourcesDupeDependencies { static RegisterCheckResourcesDupeDependencies() { AnalyzeSystem.RegisterNewRule(); } } }