您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
59 行
1.6 KiB
59 行
1.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.Experimental.ShaderTools.Internal
|
|
{
|
|
public class AssetMetadata : ScriptableObject, ISerializationCallbackReceiver
|
|
{
|
|
[Serializable]
|
|
class ReportEntry
|
|
{
|
|
[SerializeField]
|
|
internal string guid;
|
|
[SerializeField]
|
|
internal ShaderBuildReport report;
|
|
}
|
|
|
|
[SerializeField]
|
|
List<ReportEntry> m_Entries = new List<ReportEntry>();
|
|
[SerializeField]
|
|
BuildTarget m_Target;
|
|
public BuildTarget target { get { return m_Target; } set { m_Target = value; } }
|
|
|
|
Dictionary<string, int> m_GUIDIndex = new Dictionary<string, int>();
|
|
|
|
public ShaderBuildReport GetReport(string guid)
|
|
{
|
|
int index;
|
|
return m_GUIDIndex.TryGetValue(guid, out index)
|
|
? m_Entries[index].report
|
|
: null;
|
|
}
|
|
|
|
public void SetReport(string guid, ShaderBuildReport report)
|
|
{
|
|
int index;
|
|
if (m_GUIDIndex.TryGetValue(guid, out index))
|
|
m_Entries[index].report = report;
|
|
else
|
|
{
|
|
m_Entries.Add(new ReportEntry { report = report, guid = guid });
|
|
m_GUIDIndex[guid] = m_Entries.Count - 1;
|
|
}
|
|
}
|
|
|
|
public void OnBeforeSerialize()
|
|
{
|
|
}
|
|
|
|
public void OnAfterDeserialize()
|
|
{
|
|
if (m_Entries != null)
|
|
{
|
|
for (var i = 0; i < m_Entries.Count; i++)
|
|
m_GUIDIndex[m_Entries[i].guid] = i;
|
|
}
|
|
}
|
|
}
|
|
}
|