AssetStudio/AssetStudioUtility/CubismLive2DExtractor/CubismObjectList.cs
VaDiM 70213e3012 Improve integration with Live2D assets
- Improved export method of AnimationClip motions
- [GUI] Added display of model info on the preview tab
- [GUI] Added support for partial export:
  - selected models
  - model + selected AnimationClip motions
  - model + selected Fade motions
  - model + selected Fade Motion List
2024-02-08 22:34:00 +03:00

63 lines
1.8 KiB
C#

using System.Collections.Generic;
using System.Linq;
using AssetStudio;
namespace CubismLive2DExtractor
{
public sealed class CubismObjectList
{
public static SerializedFile AssetsFile { get; set; }
public HashSet<ObjectData> CubismExpressionObjects { get; set; }
public HashSet<ObjectData> CubismFadeMotionObjects { get; set; }
public class ObjectData
{
private long _pathID;
public Object Asset { get; set; }
public int m_FileID { get; set; }
public long m_PathID
{
get => _pathID;
set
{
_pathID = value;
Asset = GetObjByPathID(_pathID);
}
}
public override bool Equals(object obj)
{
return obj is ObjectData objectData && _pathID == objectData.m_PathID;
}
public override int GetHashCode()
{
return _pathID.GetHashCode();
}
}
public List<MonoBehaviour> GetFadeMotionAssetList()
{
return CubismFadeMotionObjects?.Where(x => x.Asset != null).Select(x => (MonoBehaviour)x.Asset).ToList();
}
public List<MonoBehaviour> GetExpressionList()
{
return CubismExpressionObjects?.Where(x => x.Asset != null).Select(x => (MonoBehaviour)x.Asset).ToList();
}
private static Object GetObjByPathID(long pathID)
{
var assetFileList = AssetsFile.assetsManager.assetsFileList;
foreach (var assetFile in assetFileList)
{
if (assetFile.ObjectsDic.TryGetValue(pathID, out var obj))
{
return obj;
}
}
return null;
}
}
}