using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.Properties;
using UnityEditor;
using UnityEditor.U2D.Tooling.Analyzer;
using UnityEditor.U2D.Tooling.Analyzer.UIElement;
using UnityEngine;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;
namespace SampleReport.Reports
{
///
/// Generates a report identifying Sprites that are included in multiple Sprite Atlases.
///
class SpriteInMultipleAtlasIssue : AnalyzerIssueReportBase
{
/// The GUID for the associated style sheet asset.
const string k_USSPath = "99d5a6a1b13e4a648392a5aef877ed80";
/// The UI element displaying the report content in a multi-column tree view.
MultiColumnTreeView m_ReportContent;
/// The data source providing Sprite Atlas data for the report.
SpriteAtlasDataSource m_DataSource;
///
/// Initializes a new instance of the class and sets up the report UI.
///
public SpriteInMultipleAtlasIssue()
: base(new [] {typeof(SpriteAtlasDataSource)})
{
SetReportListItemName("Sprites in Multiple Atlases");
SetReportListemCount("0");
SetupReportContent();
if(EditorGUIUtility.isProSkin)
m_ReportContent.AddToClassList("dark");
m_ReportContent.AddToClassList("report-content");
var path = AssetDatabase.GUIDToAssetPath(k_USSPath);
var styleSheet = AssetDatabase.LoadAssetAtPath(path);
m_ReportContent.styleSheets.Add(styleSheet);
}
///
/// Sets up the columns and tree view for the report UI.
///
void SetupReportContent()
{
var columns = new Columns()
{
new Column()
{
name = "Name",
title = "Name",
width = Length.Pixels(100),
makeCell = () =>
{
var ve = new VisualElement()
{
name = "cell"
};
var icon = new VisualElement()
{
name = "icon"
};
var label = new Label()
{
name ="name",
text = ""
};
ve.Add(icon);
ve.Add(label);
return ve;
},
bindCell = (e, i) =>
{
var cellData = m_ReportContent.GetItemDataForIndex(i);
if (cellData != null)
{
e.Q