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
This commit is contained in:
VaDiM
2024-02-07 03:51:52 +03:00
parent 2f6d9ec77f
commit 70213e3012
17 changed files with 1144 additions and 461 deletions

View File

@ -68,7 +68,12 @@
this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.allLive2DModelsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.live2DCubismModelsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.allL2DModelsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectedL2DModelsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.l2DModelWithFadeListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.l2DModelWithFadeMotionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.l2DModelWithClipsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem10 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem();
@ -140,8 +145,12 @@
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAnimatorwithselectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dumpSelectedAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAnimatorWithSelectedAnimationClipMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportAsLive2DModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportL2DWithFadeLstToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportL2DWithFadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportL2DWithClipsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goToSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showOriginalFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
@ -327,7 +336,7 @@
this.exportAllObjectssplitToolStripMenuItem1.Name = "exportAllObjectssplitToolStripMenuItem1";
this.exportAllObjectssplitToolStripMenuItem1.Size = new System.Drawing.Size(382, 22);
this.exportAllObjectssplitToolStripMenuItem1.Text = "Export all objects (split)";
this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectssplitToolStripMenuItem1_Click);
this.exportAllObjectssplitToolStripMenuItem1.Click += new System.EventHandler(this.exportAllObjectsSplitToolStripMenuItem1_Click);
//
// exportSelectedObjectsToolStripMenuItem
//
@ -341,7 +350,7 @@
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Name = "exportSelectedObjectsWithAnimationClipToolStripMenuItem";
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(382, 22);
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Text = "Export selected objects (split) + selected AnimationClips";
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportObjectswithAnimationClipMenuItem_Click);
this.exportSelectedObjectsWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportObjectsWithAnimationClipMenuItem_Click);
//
// toolStripSeparator1
//
@ -353,14 +362,14 @@
this.exportSelectedObjectsmergeToolStripMenuItem.Name = "exportSelectedObjectsmergeToolStripMenuItem";
this.exportSelectedObjectsmergeToolStripMenuItem.Size = new System.Drawing.Size(382, 22);
this.exportSelectedObjectsmergeToolStripMenuItem.Text = "Export selected objects (merge)";
this.exportSelectedObjectsmergeToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsmergeToolStripMenuItem_Click);
this.exportSelectedObjectsmergeToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsMergeToolStripMenuItem_Click);
//
// exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem
//
this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem.Name = "exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem";
this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(382, 22);
this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem.Text = "Export selected objects (merge) + selected AnimationClips";
this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem_Click);
this.exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedObjectsMergeWithAnimationClipToolStripMenuItem_Click);
//
// exportToolStripMenuItem
//
@ -374,7 +383,7 @@
this.toolStripMenuItem2,
this.toolStripMenuItem3,
this.toolStripSeparator6,
this.allLive2DModelsToolStripMenuItem,
this.live2DCubismModelsToolStripMenuItem,
this.toolStripSeparator2,
this.toolStripMenuItem10});
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
@ -412,7 +421,7 @@
this.exportAnimatorWithSelectedAnimationClipToolStripMenuItem.Name = "exportAnimatorWithSelectedAnimationClipToolStripMenuItem";
this.exportAnimatorWithSelectedAnimationClipToolStripMenuItem.Size = new System.Drawing.Size(266, 22);
this.exportAnimatorWithSelectedAnimationClipToolStripMenuItem.Text = "Animator + selected AnimationClips";
this.exportAnimatorWithSelectedAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportAnimatorwithAnimationClipMenuItem_Click);
this.exportAnimatorWithSelectedAnimationClipToolStripMenuItem.Click += new System.EventHandler(this.exportAnimatorWithAnimationClipMenuItem_Click);
//
// toolStripSeparator4
//
@ -486,12 +495,52 @@
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(263, 6);
//
// allLive2DModelsToolStripMenuItem
// live2DCubismModelsToolStripMenuItem
//
this.allLive2DModelsToolStripMenuItem.Name = "allLive2DModelsToolStripMenuItem";
this.allLive2DModelsToolStripMenuItem.Size = new System.Drawing.Size(266, 22);
this.allLive2DModelsToolStripMenuItem.Text = "Live2D Cubism models";
this.allLive2DModelsToolStripMenuItem.Click += new System.EventHandler(this.allLive2DModelsToolStripMenuItem_Click);
this.live2DCubismModelsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.allL2DModelsToolStripMenuItem,
this.selectedL2DModelsToolStripMenuItem,
this.l2DModelWithFadeListToolStripMenuItem,
this.l2DModelWithFadeMotionsToolStripMenuItem,
this.l2DModelWithClipsToolStripMenuItem});
this.live2DCubismModelsToolStripMenuItem.Name = "live2DCubismModelsToolStripMenuItem";
this.live2DCubismModelsToolStripMenuItem.Size = new System.Drawing.Size(266, 22);
this.live2DCubismModelsToolStripMenuItem.Text = "Live2D Cubism models";
//
// allL2DModelsToolStripMenuItem
//
this.allL2DModelsToolStripMenuItem.Name = "allL2DModelsToolStripMenuItem";
this.allL2DModelsToolStripMenuItem.Size = new System.Drawing.Size(292, 22);
this.allL2DModelsToolStripMenuItem.Text = "All models";
this.allL2DModelsToolStripMenuItem.Click += new System.EventHandler(this.exportAllL2D_Click);
//
// selectedL2DModelsToolStripMenuItem
//
this.selectedL2DModelsToolStripMenuItem.Name = "selectedL2DModelsToolStripMenuItem";
this.selectedL2DModelsToolStripMenuItem.Size = new System.Drawing.Size(292, 22);
this.selectedL2DModelsToolStripMenuItem.Text = "Selected models";
this.selectedL2DModelsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2D_Click);
//
// l2DModelWithFadeListToolStripMenuItem
//
this.l2DModelWithFadeListToolStripMenuItem.Name = "l2DModelWithFadeListToolStripMenuItem";
this.l2DModelWithFadeListToolStripMenuItem.Size = new System.Drawing.Size(292, 22);
this.l2DModelWithFadeListToolStripMenuItem.Text = "Model + selected Fade Motion List";
this.l2DModelWithFadeListToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithFadeList_Click);
//
// l2DModelWithFadeMotionsToolStripMenuItem
//
this.l2DModelWithFadeMotionsToolStripMenuItem.Name = "l2DModelWithFadeMotionsToolStripMenuItem";
this.l2DModelWithFadeMotionsToolStripMenuItem.Size = new System.Drawing.Size(292, 22);
this.l2DModelWithFadeMotionsToolStripMenuItem.Text = "Model + selected Fade motions";
this.l2DModelWithFadeMotionsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithFadeMotions_Click);
//
// l2DModelWithClipsToolStripMenuItem
//
this.l2DModelWithClipsToolStripMenuItem.Name = "l2DModelWithClipsToolStripMenuItem";
this.l2DModelWithClipsToolStripMenuItem.Size = new System.Drawing.Size(292, 22);
this.l2DModelWithClipsToolStripMenuItem.Text = "Model + selected AnimationClip motions";
this.l2DModelWithClipsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithClips_Click);
//
// toolStripSeparator2
//
@ -1226,46 +1275,82 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.copyToolStripMenuItem,
this.exportSelectedAssetsToolStripMenuItem,
this.exportAnimatorwithselectedAnimationClipMenuItem,
this.dumpSelectedAssetsToolStripMenuItem,
this.exportAnimatorWithSelectedAnimationClipMenuItem,
this.exportAsLive2DModelToolStripMenuItem,
this.exportL2DWithFadeLstToolStripMenuItem,
this.exportL2DWithFadeToolStripMenuItem,
this.exportL2DWithClipsToolStripMenuItem,
this.goToSceneHierarchyToolStripMenuItem,
this.showOriginalFileToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(304, 136);
this.contextMenuStrip1.Size = new System.Drawing.Size(332, 246);
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(303, 22);
this.copyToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.copyToolStripMenuItem.Text = "Copy text";
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
//
// exportSelectedAssetsToolStripMenuItem
//
this.exportSelectedAssetsToolStripMenuItem.Name = "exportSelectedAssetsToolStripMenuItem";
this.exportSelectedAssetsToolStripMenuItem.Size = new System.Drawing.Size(303, 22);
this.exportSelectedAssetsToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportSelectedAssetsToolStripMenuItem.Text = "Export selected assets";
this.exportSelectedAssetsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedAssetsToolStripMenuItem_Click);
//
// exportAnimatorwithselectedAnimationClipMenuItem
//
this.exportAnimatorwithselectedAnimationClipMenuItem.Name = "exportAnimatorwithselectedAnimationClipMenuItem";
this.exportAnimatorwithselectedAnimationClipMenuItem.Size = new System.Drawing.Size(303, 22);
this.exportAnimatorwithselectedAnimationClipMenuItem.Text = "Export Animator + selected AnimationClips";
this.exportAnimatorwithselectedAnimationClipMenuItem.Visible = false;
this.exportAnimatorwithselectedAnimationClipMenuItem.Click += new System.EventHandler(this.exportAnimatorwithAnimationClipMenuItem_Click);
//
// dumpSelectedAssetsToolStripMenuItem
//
this.dumpSelectedAssetsToolStripMenuItem.Name = "dumpSelectedAssetsToolStripMenuItem";
this.dumpSelectedAssetsToolStripMenuItem.Size = new System.Drawing.Size(303, 22);
this.dumpSelectedAssetsToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.dumpSelectedAssetsToolStripMenuItem.Text = "Dump selected assets";
this.dumpSelectedAssetsToolStripMenuItem.Click += new System.EventHandler(this.dumpSelectedAssetsToolStripMenuItem_Click);
//
// exportAnimatorWithSelectedAnimationClipMenuItem
//
this.exportAnimatorWithSelectedAnimationClipMenuItem.Name = "exportAnimatorWithSelectedAnimationClipMenuItem";
this.exportAnimatorWithSelectedAnimationClipMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportAnimatorWithSelectedAnimationClipMenuItem.Text = "Export Animator + selected AnimationClips";
this.exportAnimatorWithSelectedAnimationClipMenuItem.Visible = false;
this.exportAnimatorWithSelectedAnimationClipMenuItem.Click += new System.EventHandler(this.exportAnimatorWithAnimationClipMenuItem_Click);
//
// exportAsLive2DModelToolStripMenuItem
//
this.exportAsLive2DModelToolStripMenuItem.Name = "exportAsLive2DModelToolStripMenuItem";
this.exportAsLive2DModelToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportAsLive2DModelToolStripMenuItem.Text = "Export as Live2D model(s)";
this.exportAsLive2DModelToolStripMenuItem.Visible = false;
this.exportAsLive2DModelToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2D_Click);
//
// exportL2DWithFadeLstToolStripMenuItem
//
this.exportL2DWithFadeLstToolStripMenuItem.Name = "exportL2DWithFadeLstToolStripMenuItem";
this.exportL2DWithFadeLstToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportL2DWithFadeLstToolStripMenuItem.Text = "Export Live2D model + selected Fade Motion List";
this.exportL2DWithFadeLstToolStripMenuItem.Visible = false;
this.exportL2DWithFadeLstToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithFadeList_Click);
//
// exportL2DWithFadeToolStripMenuItem
//
this.exportL2DWithFadeToolStripMenuItem.Name = "exportL2DWithFadeToolStripMenuItem";
this.exportL2DWithFadeToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportL2DWithFadeToolStripMenuItem.Text = "Export Live2D model + selected Fade motions";
this.exportL2DWithFadeToolStripMenuItem.Visible = false;
this.exportL2DWithFadeToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithFadeMotions_Click);
//
// exportL2DWithClipsToolStripMenuItem
//
this.exportL2DWithClipsToolStripMenuItem.Name = "exportL2DWithClipsToolStripMenuItem";
this.exportL2DWithClipsToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.exportL2DWithClipsToolStripMenuItem.Text = "Export Live2D model + selected AnimationClips";
this.exportL2DWithClipsToolStripMenuItem.Visible = false;
this.exportL2DWithClipsToolStripMenuItem.Click += new System.EventHandler(this.exportSelectedL2DWithClips_Click);
//
// goToSceneHierarchyToolStripMenuItem
//
this.goToSceneHierarchyToolStripMenuItem.Name = "goToSceneHierarchyToolStripMenuItem";
this.goToSceneHierarchyToolStripMenuItem.Size = new System.Drawing.Size(303, 22);
this.goToSceneHierarchyToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.goToSceneHierarchyToolStripMenuItem.Text = "Go to scene hierarchy";
this.goToSceneHierarchyToolStripMenuItem.Visible = false;
this.goToSceneHierarchyToolStripMenuItem.Click += new System.EventHandler(this.goToSceneHierarchyToolStripMenuItem_Click);
@ -1273,7 +1358,7 @@
// showOriginalFileToolStripMenuItem
//
this.showOriginalFileToolStripMenuItem.Name = "showOriginalFileToolStripMenuItem";
this.showOriginalFileToolStripMenuItem.Size = new System.Drawing.Size(303, 22);
this.showOriginalFileToolStripMenuItem.Size = new System.Drawing.Size(331, 22);
this.showOriginalFileToolStripMenuItem.Text = "Show original file";
this.showOriginalFileToolStripMenuItem.Visible = false;
this.showOriginalFileToolStripMenuItem.Click += new System.EventHandler(this.showOriginalFileToolStripMenuItem_Click);
@ -1387,7 +1472,7 @@
private OpenTK.GLControl glControl1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem showOriginalFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAnimatorwithselectedAnimationClipMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAnimatorWithSelectedAnimationClipMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportSelectedAssetsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem filterTypeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem allToolStripMenuItem;
@ -1437,13 +1522,22 @@
private System.Windows.Forms.ComboBox listSearchHistory;
private System.Windows.Forms.RichTextBox listSearch;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
private System.Windows.Forms.ToolStripMenuItem allLive2DModelsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem showRelatedAssetsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ListView assetListView;
private System.Windows.Forms.ToolStripMenuItem showConsoleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem writeLogToFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem buildTreeStructureToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportL2DWithClipsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportAsLive2DModelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem live2DCubismModelsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem allL2DModelsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem selectedL2DModelsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem l2DModelWithClipsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem l2DModelWithFadeMotionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportL2DWithFadeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem l2DModelWithFadeListToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportL2DWithFadeLstToolStripMenuItem;
}
}

View File

@ -822,7 +822,16 @@ namespace AssetStudioGUI
PreviewTextAsset(assetItem.Asset as TextAsset);
break;
case ClassIDType.MonoBehaviour:
PreviewMonoBehaviour(assetItem.Asset as MonoBehaviour);
var m_MonoBehaviour = (MonoBehaviour)assetItem.Asset;
if (m_MonoBehaviour.m_Script.TryGet(out var m_Script))
{
if (m_Script.m_ClassName == "CubismMoc")
{
PreviewMoc(assetItem, m_MonoBehaviour);
break;
}
}
PreviewMonoBehaviour(m_MonoBehaviour);
break;
case ClassIDType.Font:
PreviewFont(assetItem.Asset as Font);
@ -1083,6 +1092,27 @@ namespace AssetStudioGUI
PreviewText(str);
}
private void PreviewMoc(AssetItem assetItem, MonoBehaviour m_MonoBehaviour)
{
using (var cubismModel = new CubismModel(m_MonoBehaviour))
{
var sb = new StringBuilder();
sb.AppendLine($"SDK Version: {cubismModel.VersionDescription}");
if (cubismModel.Version > 0)
{
sb.AppendLine($"Canvas Width: {cubismModel.CanvasWidth}");
sb.AppendLine($"Canvas Height: {cubismModel.CanvasHeight}");
sb.AppendLine($"Center X: {cubismModel.CentralPosX}");
sb.AppendLine($"Center Y: {cubismModel.CentralPosY}");
sb.AppendLine($"Pixel Per Unit: {cubismModel.PixelPerUnit}");
sb.AppendLine($"Parameter Count: {cubismModel.ParamCount}");
sb.AppendLine($"Part Count: {cubismModel.PartCount}");
}
assetItem.InfoText = sb.ToString();
}
StatusStripUpdate("Can be exported as Live2D Cubism model.");
}
private void PreviewFont(Font m_Font)
{
if (m_Font.m_FontData != null)
@ -1374,6 +1404,7 @@ namespace AssetStudioGUI
classesListView.Groups.Clear();
selectedAnimationAssetsList.Clear();
selectedIndicesPrevList.Clear();
cubismMocList.Clear();
previewPanel.BackgroundImage = Properties.Resources.preview;
imageTexture?.Dispose();
imageTexture = null;
@ -1417,7 +1448,11 @@ namespace AssetStudioGUI
{
goToSceneHierarchyToolStripMenuItem.Visible = false;
showOriginalFileToolStripMenuItem.Visible = false;
exportAnimatorwithselectedAnimationClipMenuItem.Visible = false;
exportAnimatorWithSelectedAnimationClipMenuItem.Visible = false;
exportAsLive2DModelToolStripMenuItem.Visible = false;
exportL2DWithFadeLstToolStripMenuItem.Visible = false;
exportL2DWithFadeToolStripMenuItem.Visible = false;
exportL2DWithClipsToolStripMenuItem.Visible = false;
if (assetListView.SelectedIndices.Count == 1)
{
@ -1427,10 +1462,42 @@ namespace AssetStudioGUI
if (assetListView.SelectedIndices.Count >= 1)
{
var selectedAssets = GetSelectedAssets();
if (selectedAssets.Any(x => x.Type == ClassIDType.Animator) && selectedAssets.Any(x => x.Type == ClassIDType.AnimationClip))
var selectedTypes = (SelectedAssetType)0;
foreach (var asset in selectedAssets)
{
exportAnimatorwithselectedAnimationClipMenuItem.Visible = true;
switch (asset.Asset)
{
case MonoBehaviour m_MonoBehaviour:
if (Studio.cubismMocList.Count > 0 && m_MonoBehaviour.m_Script.TryGet(out var m_Script))
{
if (m_Script.m_ClassName == "CubismMoc")
{
selectedTypes |= SelectedAssetType.MonoBehaviourMoc;
}
else if (m_Script.m_ClassName == "CubismFadeMotionData")
{
selectedTypes |= SelectedAssetType.MonoBehaviourFade;
}
else if (m_Script.m_ClassName == "CubismFadeMotionList")
{
selectedTypes |= SelectedAssetType.MonoBehaviourFadeLst;
}
}
break;
case AnimationClip _:
selectedTypes |= SelectedAssetType.AnimationClip;
break;
case Animator _:
selectedTypes |= SelectedAssetType.Animator;
break;
}
}
exportAnimatorWithSelectedAnimationClipMenuItem.Visible = (selectedTypes & SelectedAssetType.Animator) !=0 && (selectedTypes & SelectedAssetType.AnimationClip) != 0;
exportAsLive2DModelToolStripMenuItem.Visible = (selectedTypes & SelectedAssetType.MonoBehaviourMoc) != 0;
exportL2DWithFadeLstToolStripMenuItem.Visible = (selectedTypes & SelectedAssetType.MonoBehaviourMoc) !=0 && (selectedTypes & SelectedAssetType.MonoBehaviourFadeLst) != 0;
exportL2DWithFadeToolStripMenuItem.Visible = (selectedTypes & SelectedAssetType.MonoBehaviourMoc) != 0 && (selectedTypes & SelectedAssetType.MonoBehaviourFade) !=0;
exportL2DWithClipsToolStripMenuItem.Visible = (selectedTypes & SelectedAssetType.MonoBehaviourMoc) !=0 && (selectedTypes & SelectedAssetType.AnimationClip) != 0;
}
var selectedElement = assetListView.HitTest(new Point(e.X, e.Y));
@ -1458,13 +1525,13 @@ namespace AssetStudioGUI
private void showOriginalFileToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectasset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]];
var args = $"/select, \"{selectasset.SourceFile.originalPath ?? selectasset.SourceFile.fullName}\"";
var selectAsset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]];
var args = $"/select, \"{selectAsset.SourceFile.originalPath ?? selectAsset.SourceFile.fullName}\"";
var pfi = new ProcessStartInfo("explorer.exe", args);
Process.Start(pfi);
}
private void exportAnimatorwithAnimationClipMenuItem_Click(object sender, EventArgs e)
private void exportAnimatorWithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
AssetItem animator = null;
var selectedAssets = GetSelectedAssets();
@ -1494,7 +1561,7 @@ namespace AssetStudioGUI
ExportObjects(false);
}
private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventArgs e)
private void exportObjectsWithAnimationClipMenuItem_Click(object sender, EventArgs e)
{
ExportObjects(true);
}
@ -1527,12 +1594,12 @@ namespace AssetStudioGUI
}
}
private void exportSelectedObjectsmergeToolStripMenuItem_Click(object sender, EventArgs e)
private void exportSelectedObjectsMergeToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportMergeObjects(false);
}
private void exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem_Click(object sender, EventArgs e)
private void exportSelectedObjectsMergeWithAnimationClipToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportMergeObjects(true);
}
@ -1575,10 +1642,10 @@ namespace AssetStudioGUI
private void goToSceneHierarchyToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectasset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]];
if (selectasset.TreeNode != null)
var selectAsset = (AssetItem)assetListView.Items[assetListView.SelectedIndices[0]];
if (selectAsset.TreeNode != null)
{
sceneTreeView.SelectedNode = selectasset.TreeNode;
sceneTreeView.SelectedNode = selectAsset.TreeNode;
tabControl1.SelectedTab = tabPage1;
}
}
@ -1643,7 +1710,7 @@ namespace AssetStudioGUI
ExportAssetsList(ExportFilter.Filtered);
}
private void exportAllObjectssplitToolStripMenuItem1_Click(object sender, EventArgs e)
private void exportAllObjectsSplitToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (sceneTreeView.Nodes.Count > 0)
{
@ -1938,42 +2005,6 @@ namespace AssetStudioGUI
listSearch.SelectionStart = listSearch.Text.Length;
}
private void allLive2DModelsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (exportableAssets.Count > 0)
{
var cubismMocs = exportableAssets.Where(x =>
{
if (x.Type == ClassIDType.MonoBehaviour)
{
((MonoBehaviour)x.Asset).m_Script.TryGet(out var m_Script);
return m_Script?.m_ClassName == "CubismMoc";
}
return false;
}).Select(x => x.Asset).ToArray();
if (cubismMocs.Length == 0)
{
Logger.Info("Live2D Cubism models were not found.");
return;
}
var saveFolderDialog = new OpenFolderDialog();
saveFolderDialog.InitialFolder = saveDirectoryBackup;
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
{
timer.Stop();
saveDirectoryBackup = saveFolderDialog.Folder;
Progress.Reset();
BeginInvoke(new Action(() => { progressBar1.Style = ProgressBarStyle.Marquee; }));
Studio.ExportLive2D(cubismMocs, saveFolderDialog.Folder);
}
}
else
{
Logger.Info("No exportable assets loaded");
}
}
private void selectRelatedAsset(object sender, EventArgs e)
{
var selectedItem = (ToolStripMenuItem)sender;
@ -2077,6 +2108,138 @@ namespace AssetStudioGUI
Properties.Settings.Default.Save();
}
private void exportAllL2D_Click(object sender, EventArgs e)
{
if (exportableAssets.Count > 0)
{
if (Studio.cubismMocList.Count == 0)
{
Logger.Info("Live2D Cubism models were not found.");
return;
}
Live2DExporter();
}
else
{
Logger.Info("No exportable assets loaded");
}
}
private void exportSelectedL2D_Click(object sender, EventArgs e)
{
ExportSelectedL2DModels(ExportL2DFilter.Selected);
}
private void exportSelectedL2DWithClips_Click(object sender, EventArgs e)
{
ExportSelectedL2DModels(ExportL2DFilter.SelectedWithClips);
}
private void exportSelectedL2DWithFadeMotions_Click(object sender, EventArgs e)
{
ExportSelectedL2DModels(ExportL2DFilter.SelectedWithFade);
}
private void exportSelectedL2DWithFadeList_Click(object sender, EventArgs e)
{
ExportSelectedL2DModels(ExportL2DFilter.SelectedWithFadeList);
}
private void ExportSelectedL2DModels(ExportL2DFilter l2dExportMode)
{
if (exportableAssets.Count == 0)
{
Logger.Info("No exportable assets loaded");
return;
}
if (Studio.cubismMocList.Count == 0)
{
Logger.Info("Live2D Cubism models were not found.");
return;
}
var selectedAssets = GetSelectedAssets();
if (selectedAssets.Count == 0)
return;
MonoBehaviour selectedFadeLst = null;
var selectedMocs = new List<MonoBehaviour>();
var selectedFadeMotions = new List<MonoBehaviour>();
var selectedClips = new List<AnimationClip>();
foreach (var assetItem in selectedAssets)
{
if (assetItem.Asset is MonoBehaviour m_MonoBehaviour && m_MonoBehaviour.m_Script.TryGet(out var m_Script))
{
if (m_Script.m_ClassName == "CubismMoc")
{
selectedMocs.Add(m_MonoBehaviour);
}
else if (m_Script.m_ClassName == "CubismFadeMotionData")
{
selectedFadeMotions.Add(m_MonoBehaviour);
}
else if (m_Script.m_ClassName == "CubismFadeMotionList")
{
selectedFadeLst = m_MonoBehaviour;
}
}
else if (assetItem.Asset is AnimationClip m_AnimationClip)
{
selectedClips.Add(m_AnimationClip);
}
}
if (selectedMocs.Count == 0)
{
Logger.Info("Live2D Cubism models were not selected.");
return;
}
switch (l2dExportMode)
{
case ExportL2DFilter.Selected:
Live2DExporter(selectedMocs);
break;
case ExportL2DFilter.SelectedWithFadeList:
if (selectedFadeLst == null)
{
Logger.Info("Fade Motion List was not selected.");
return;
}
Live2DExporter(selectedMocs, selFadeLst: selectedFadeLst);
break;
case ExportL2DFilter.SelectedWithFade:
if (selectedFadeMotions.Count == 0)
{
Logger.Info("No Fade motions were selected.");
return;
}
Live2DExporter(selectedMocs, selFadeMotions: selectedFadeMotions);
break;
case ExportL2DFilter.SelectedWithClips:
if (selectedClips.Count == 0)
{
Logger.Info("No AnimationClips were selected.");
return;
}
Live2DExporter(selectedMocs, selectedClips);
break;
}
}
private void Live2DExporter(List<MonoBehaviour> selMocs = null, List<AnimationClip> selClipMotions = null, List<MonoBehaviour> selFadeMotions = null, MonoBehaviour selFadeLst = null)
{
var saveFolderDialog = new OpenFolderDialog();
saveFolderDialog.InitialFolder = saveDirectoryBackup;
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
{
timer.Stop();
saveDirectoryBackup = saveFolderDialog.Folder;
Progress.Reset();
BeginInvoke(new Action(() => { progressBar1.Style = ProgressBarStyle.Marquee; }));
Studio.ExportLive2D(saveFolderDialog.Folder, selMocs, selClipMotions, selFadeMotions, selFadeLst);
}
}
#region FMOD
private void FMODinit()
{

View File

@ -120,6 +120,9 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>312, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<data name="fontPreviewBox.Text" xml:space="preserve">
<value>abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ
1234567890.:,;'\"(!?)+-*/=
@ -138,9 +141,6 @@ The quick brown fox jumps over the lazy dog. 1234567890
The quick brown fox jumps over the lazy dog. 1234567890</value>
</data>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>432, 17</value>
</metadata>
<metadata name="contextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>775, 21</value>
</metadata>

View File

@ -305,7 +305,7 @@
//
// l2dAnimationClipRadioButton
//
this.l2dAnimationClipRadioButton.AccessibleName = "AnimationClip";
this.l2dAnimationClipRadioButton.AccessibleName = "AnimationClipV2";
this.l2dAnimationClipRadioButton.AutoSize = true;
this.l2dAnimationClipRadioButton.Location = new System.Drawing.Point(172, 5);
this.l2dAnimationClipRadioButton.Name = "l2dAnimationClipRadioButton";

View File

@ -1,4 +1,5 @@
using AssetStudio;
using CubismLive2DExtractor;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -9,7 +10,6 @@ using System.Threading;
using System.Windows.Forms;
using System.Xml.Linq;
using static AssetStudioGUI.Exporter;
using static CubismLive2DExtractor.Live2DExtractor;
using Object = AssetStudio.Object;
namespace AssetStudioGUI
@ -28,6 +28,15 @@ namespace AssetStudioGUI
Filtered
}
internal enum ExportL2DFilter
{
All,
Selected,
SelectedWithFadeList,
SelectedWithFade,
SelectedWithClips,
}
internal enum ExportListType
{
XML
@ -49,13 +58,24 @@ namespace AssetStudioGUI
RegexContainer,
}
[Flags]
internal enum SelectedAssetType
{
Animator = 0x01,
AnimationClip = 0x02,
MonoBehaviourMoc = 0x04,
MonoBehaviourFade = 0x08,
MonoBehaviourFadeLst = 0x10
}
internal static class Studio
{
public static AssetsManager assetsManager = new AssetsManager();
public static AssemblyLoader assemblyLoader = new AssemblyLoader();
public static List<AssetItem> exportableAssets = new List<AssetItem>();
public static List<AssetItem> visibleAssets = new List<AssetItem>();
private static Dictionary<Object, string> allContainers = new Dictionary<Object, string>();
public static List<MonoBehaviour> cubismMocList = new List<MonoBehaviour>();
private static Dictionary<Object, string> l2dResourceContainers = new Dictionary<Object, string>();
internal static Action<string> StatusStripUpdate = x => { };
public static int ExtractFolder(string path, string savePath)
@ -158,7 +178,7 @@ namespace AssetStudioGUI
var objectCount = assetsManager.assetsFileList.Sum(x => x.Objects.Count);
var objectAssetItemDic = new Dictionary<Object, AssetItem>(objectCount);
var containers = new List<(PPtr<Object>, string)>();
allContainers.Clear();
l2dResourceContainers.Clear();
var i = 0;
Progress.Reset();
foreach (var assetsFile in assetsManager.assetsFileList)
@ -218,14 +238,16 @@ namespace AssetStudioGUI
exportable = true;
break;
case MonoBehaviour m_MonoBehaviour:
if (m_MonoBehaviour.m_Name == "" && m_MonoBehaviour.m_Script.TryGet(out var m_Script))
var assetName = m_MonoBehaviour.m_Name;
if (m_MonoBehaviour.m_Script.TryGet(out var m_Script))
{
assetItem.Text = m_Script.m_ClassName;
}
else
{
assetItem.Text = m_MonoBehaviour.m_Name;
assetName = assetName == "" ? m_Script.m_ClassName : assetName;
if (m_Script.m_ClassName == "CubismMoc")
{
cubismMocList.Add(m_MonoBehaviour);
}
}
assetItem.Text = assetName;
exportable = true;
break;
case PlayerSettings m_PlayerSettings:
@ -276,7 +298,15 @@ namespace AssetStudioGUI
if (pptr.TryGet(out var obj))
{
objectAssetItemDic[obj].Container = container;
allContainers[obj] = container;
switch (obj)
{
case AnimationClip _:
case GameObject _:
case Texture2D _:
case MonoBehaviour _:
l2dResourceContainers[obj] = container;
break;
}
}
}
foreach (var tmp in exportableAssets)
@ -725,6 +755,12 @@ namespace AssetStudioGUI
}
public static TypeTree MonoBehaviourToTypeTree(MonoBehaviour m_MonoBehaviour)
{
SelectAssemblyFolder();
return m_MonoBehaviour.ConvertToTypeTree(assemblyLoader);
}
private static void SelectAssemblyFolder()
{
if (!assemblyLoader.Loaded)
{
@ -739,7 +775,6 @@ namespace AssetStudioGUI
assemblyLoader.Loaded = true;
}
}
return m_MonoBehaviour.ConvertToTypeTree(assemblyLoader);
}
public static string DumpAsset(Object obj)
@ -760,54 +795,64 @@ namespace AssetStudioGUI
Process.Start(info);
}
public static void ExportLive2D(Object[] cubismMocs, string exportPath)
public static void ExportLive2D(string exportPath, List<MonoBehaviour> selMocs = null, List<AnimationClip> selClipMotions = null, List<MonoBehaviour> selFadeMotions = null, MonoBehaviour selFadeLst = null)
{
var baseDestPath = Path.Combine(exportPath, "Live2DOutput");
var motionMode = Properties.Settings.Default.l2dMotionMode;
var forceBezier = Properties.Settings.Default.l2dForceBezier;
var mocList = selMocs ?? cubismMocList;
var motionMode = Properties.Settings.Default.l2dMotionMode;
if (selClipMotions != null)
motionMode = Live2DMotionMode.AnimationClipV2;
else if (selFadeMotions != null || selFadeLst != null)
motionMode = Live2DMotionMode.MonoBehaviour;
ThreadPool.QueueUserWorkItem(state =>
{
Logger.Info($"Searching for Live2D files...");
var useFullContainerPath = false;
if (cubismMocs.Length > 1)
var mocPathDict = new Dictionary<MonoBehaviour, (string, string)>();
var mocPathList = new List<string>();
foreach (var mocMonoBehaviour in cubismMocList)
{
var basePathSet = cubismMocs.Select(x =>
{
var pathLen = allContainers.TryGetValue(x, out var itemContainer) ? itemContainer.LastIndexOf("/") : 0;
pathLen = pathLen < 0 ? allContainers[x].Length : pathLen;
return itemContainer?.Substring(0, pathLen);
}).ToHashSet();
if (!l2dResourceContainers.TryGetValue(mocMonoBehaviour, out var fullContainerPath))
continue;
if (basePathSet.All(x => x == null))
{
Logger.Error($"Live2D Cubism export error\r\nCannot find any model related files");
StatusStripUpdate("Live2D export canceled");
Progress.Reset();
return;
}
if (basePathSet.Count != cubismMocs.Length)
{
useFullContainerPath = true;
}
var pathSepIndex = fullContainerPath.LastIndexOf('/');
var basePath = pathSepIndex > 0
? fullContainerPath.Substring(0, pathSepIndex)
: fullContainerPath;
mocPathDict.Add(mocMonoBehaviour, (fullContainerPath, basePath));
}
if (mocPathDict.Count == 0)
{
Logger.Error("Live2D Cubism export error\r\nCannot find any model related files");
StatusStripUpdate("Live2D export canceled");
Progress.Reset();
return;
}
var basePathList = cubismMocs.Select(x =>
var basePathSet = mocPathDict.Values.Select(x => x.Item2).ToHashSet();
var useFullContainerPath = mocPathDict.Count != basePathSet.Count;
foreach (var moc in mocList)
{
allContainers.TryGetValue(x, out var container);
container = useFullContainerPath
? container
: container?.Substring(0, container.LastIndexOf("/"));
return container;
}).Where(x => x != null).ToList();
var mocPath = useFullContainerPath
? mocPathDict[moc].Item1 //fullContainerPath
: mocPathDict[moc].Item2; //basePath
mocPathList.Add(mocPath);
}
mocPathDict.Clear();
var lookup = allContainers.ToLookup(
x => basePathList.Find(b => x.Value.Contains(b) && x.Value.Split('/').Any(y => y == b.Substring(b.LastIndexOf("/") + 1))),
var lookup = l2dResourceContainers.ToLookup(
x => mocPathList.Find(b => x.Value.Contains(b) && x.Value.Split('/').Any(y => y == b.Substring(b.LastIndexOf("/") + 1))),
x => x.Key
);
if (mocList[0].serializedType?.m_Type == null && !assemblyLoader.Loaded)
{
Logger.Warning("Specifying the assembly folder may be needed for proper extraction");
SelectAssemblyFolder();
}
var totalModelCount = lookup.LongCount(x => x.Key != null);
var modelCounter = 0;
foreach (var assets in lookup)
@ -820,11 +865,16 @@ namespace AssetStudioGUI
Logger.Info($"[{modelCounter + 1}/{totalModelCount}] Exporting Live2D: \"{srcContainer}\"...");
try
{
var modelName = useFullContainerPath ? Path.GetFileNameWithoutExtension(container) : container.Substring(container.LastIndexOf('/') + 1);
container = Path.HasExtension(container) ? container.Replace(Path.GetExtension(container), "") : container;
var modelName = useFullContainerPath
? Path.GetFileNameWithoutExtension(container)
: container.Substring(container.LastIndexOf('/') + 1);
container = Path.HasExtension(container)
? container.Replace(Path.GetExtension(container), "")
: container;
var destPath = Path.Combine(baseDestPath, container) + Path.DirectorySeparatorChar;
ExtractLive2D(assets, destPath, modelName, assemblyLoader, motionMode, forceBezier);
var modelExtractor = new Live2DExtractor(assets, selClipMotions, selFadeMotions, selFadeLst);
modelExtractor.ExtractCubismModel(destPath, modelName, motionMode, assemblyLoader, forceBezier);
modelCounter++;
}
catch (Exception ex)