【m】框架大更新
This commit is contained in:
81
Assets/03.YooAsset/Editor/Common/AssetInfo.cs
Normal file
81
Assets/03.YooAsset/Editor/Common/AssetInfo.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetInfo : IComparable<AssetInfo>
|
||||
{
|
||||
private string _fileExtension = null;
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public System.Type AssetType;
|
||||
|
||||
/// <summary>
|
||||
/// 文件格式
|
||||
/// </summary>
|
||||
public string FileExtension
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_fileExtension))
|
||||
_fileExtension = System.IO.Path.GetExtension(AssetPath);
|
||||
return _fileExtension;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AssetInfo(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
|
||||
|
||||
// 注意:如果资源文件损坏或者实例化关联脚本丢失,获取的资源类型会无效!
|
||||
if (AssetType == null)
|
||||
{
|
||||
throw new Exception($"Found invalid asset : {AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为着色器资源
|
||||
/// </summary>
|
||||
public bool IsShaderAsset()
|
||||
{
|
||||
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为图集资源
|
||||
/// </summary>
|
||||
public bool IsSpriteAtlas()
|
||||
{
|
||||
if (AssetType == typeof(UnityEngine.U2D.SpriteAtlas))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public int CompareTo(AssetInfo other)
|
||||
{
|
||||
return this.AssetPath.CompareTo(other.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/03.YooAsset/Editor/Common/AssetInfo.cs.meta
Normal file
11
Assets/03.YooAsset/Editor/Common/AssetInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00f74a74bf5cc21488052d2d012c984c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user