using System.Collections.Generic;
using System.Linq;
using UnityEditor.AddressableAssets.Settings;
namespace UnityEditor.AddressableAssets.Build.AnalyzeRules
{
///
/// Rule class to check scene dependencies for duplicates
///
public class CheckSceneDupeDependencies : BundleRuleBase
{
///
public override string ruleName
{
get { return "Check Scene to Addressable Duplicate Dependencies"; }
}
///
public override bool CanFix
{
get { return false; }
}
///
public override void FixIssues(AddressableAssetSettings settings)
{
//Do nothing, there's nothing to fix.
}
///
/// Clear analysis and calculate built in resources and corresponding bundle dependencies for scenes
///
/// The current Addressables settings object
/// List of results from analysis
public override List RefreshAnalysis(AddressableAssetSettings settings)
{
ClearAnalysis();
string[] scenePaths = (from editorScene in EditorBuildSettings.scenes
where editorScene.enabled
select editorScene.path).ToArray();
AddressableAnalytics.ReportUsageEvent(AddressableAnalytics.UsageEventType.RunCheckSceneDupeDependenciesRule);
return CalculateBuiltInResourceDependenciesToBundleDependecies(settings, scenePaths);
}
///
internal protected override string[] GetResourcePaths()
{
List scenes = new List(EditorBuildSettings.scenes.Length);
foreach (EditorBuildSettingsScene settingsScene in EditorBuildSettings.scenes)
{
if (settingsScene.enabled)
scenes.Add(settingsScene.path);
}
return scenes.ToArray();
}
}
[InitializeOnLoad]
class RegisterCheckSceneDupeDependencies
{
static RegisterCheckSceneDupeDependencies()
{
AnalyzeSystem.RegisterNewRule();
}
}
}