using System;
using UnityEditor.AddressableAssets.Build;
using UnityEditor.AddressableAssets.Build.AnalyzeRules;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
namespace UnityEditor.AddressableAssets.GUI
{
///
/// Window used to execute AnalyzeRule sets.
///
public class AnalyzeWindow : EditorWindow
{
private static AnalyzeWindow s_Instance = null;
private static AnalyzeWindow instance
{
get
{
if (s_Instance == null)
s_Instance = GetWindow(false, "Addressables Analyze", false);
return s_Instance;
}
}
private AddressableAssetSettings m_Settings;
[SerializeField]
private AnalyzeRuleGUI m_AnalyzeEditor;
private Rect displayAreaRect
{
get { return new Rect(0, 0, position.width, position.height); }
}
[MenuItem("Window/Asset Management/Addressables/Analyze", priority = 2052)]
internal static void ShowWindow()
{
AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null)
{
EditorUtility.DisplayDialog("Error",
"Attempting to open Addressables Analyze window, but no Addressables Settings file exists. \n\nOpen 'Window/Asset Management/Addressables/Groups' for more info.", "Ok");
return;
}
AddressableAnalytics.ReportUsageEvent(AddressableAnalytics.UsageEventType.OpenAnalyzeWindow);
instance.titleContent = new GUIContent("Addressables Analyze");
instance.Show();
}
void OnEnable()
{
AddressableAnalytics.ReportUsageEvent(AddressableAnalytics.UsageEventType.OpenAnalyzeWindow, true);
if (m_AnalyzeEditor == null)
m_AnalyzeEditor = new AnalyzeRuleGUI();
}
void OnGUI()
{
AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null)
return;
GUILayout.BeginArea(displayAreaRect);
m_AnalyzeEditor.OnGUI(displayAreaRect);
GUILayout.EndArea();
}
///
/// Obsolete - please use AnalyzeSystem.RegisterNewRule<TRule>()
///
/// The rule type.
[Obsolete("Please use AnalyzeSystem.RegisterNewRule()")]
public static void RegisterNewRule() where TRule : AnalyzeRule, new()
{
AnalyzeSystem.RegisterNewRule();
}
}
}