mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Fixed #609
This commit is contained in:
parent
f904bc138b
commit
ee0cd4ab52
@ -87,7 +87,6 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Studio.cs" />
|
<Compile Include="Studio.cs" />
|
||||||
<Compile Include="TGASharpLib.cs" />
|
|
||||||
<EmbeddedResource Include="AssetStudioGUIForm.resx">
|
<EmbeddedResource Include="AssetStudioGUIForm.resx">
|
||||||
<DependentUpon>AssetStudioGUIForm.cs</DependentUpon>
|
<DependentUpon>AssetStudioGUIForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
@ -324,14 +324,18 @@ namespace AssetStudioGUI
|
|||||||
exportFullPath = Path.Combine(exportPath, item.Text + item.UniqueID, item.Text + ".fbx");
|
exportFullPath = Path.Combine(exportPath, item.Text + item.UniqueID, item.Text + ".fbx");
|
||||||
}
|
}
|
||||||
var m_Animator = (Animator)item.Asset;
|
var m_Animator = (Animator)item.Asset;
|
||||||
var convert = animationList != null ? new ModelConverter(m_Animator, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) : new ModelConverter(m_Animator);
|
var convert = animationList != null
|
||||||
|
? new ModelConverter(m_Animator, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
|
||||||
|
: new ModelConverter(m_Animator, Properties.Settings.Default.convertType);
|
||||||
ExportFbx(convert, exportFullPath);
|
ExportFbx(convert, exportFullPath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ExportGameObject(GameObject gameObject, string exportPath, List<AssetItem> animationList = null)
|
public static void ExportGameObject(GameObject gameObject, string exportPath, List<AssetItem> animationList = null)
|
||||||
{
|
{
|
||||||
var convert = animationList != null ? new ModelConverter(gameObject, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) : new ModelConverter(gameObject);
|
var convert = animationList != null
|
||||||
|
? new ModelConverter(gameObject, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
|
||||||
|
: new ModelConverter(gameObject, Properties.Settings.Default.convertType);
|
||||||
exportPath = exportPath + FixFileName(gameObject.m_Name) + ".fbx";
|
exportPath = exportPath + FixFileName(gameObject.m_Name) + ".fbx";
|
||||||
ExportFbx(convert, exportPath);
|
ExportFbx(convert, exportPath);
|
||||||
}
|
}
|
||||||
@ -339,7 +343,9 @@ namespace AssetStudioGUI
|
|||||||
public static void ExportGameObjectMerge(List<GameObject> gameObject, string exportPath, List<AssetItem> animationList = null)
|
public static void ExportGameObjectMerge(List<GameObject> gameObject, string exportPath, List<AssetItem> animationList = null)
|
||||||
{
|
{
|
||||||
var rootName = Path.GetFileNameWithoutExtension(exportPath);
|
var rootName = Path.GetFileNameWithoutExtension(exportPath);
|
||||||
var convert = animationList != null ? new ModelConverter(rootName, gameObject, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) : new ModelConverter(rootName, gameObject);
|
var convert = animationList != null
|
||||||
|
? new ModelConverter(rootName, gameObject, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
|
||||||
|
: new ModelConverter(rootName, gameObject, Properties.Settings.Default.convertType);
|
||||||
ExportFbx(convert, exportPath);
|
ExportFbx(convert, exportPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
<Compile Include="ModelExporter.cs" />
|
<Compile Include="ModelExporter.cs" />
|
||||||
<Compile Include="MonoBehaviourConverter.cs" />
|
<Compile Include="MonoBehaviourConverter.cs" />
|
||||||
<Compile Include="SerializedTypeHelper.cs" />
|
<Compile Include="SerializedTypeHelper.cs" />
|
||||||
|
<Compile Include="TGASharpLib.cs" />
|
||||||
<Compile Include="TypeDefinitionConverter.cs" />
|
<Compile Include="TypeDefinitionConverter.cs" />
|
||||||
<Compile Include="MyAssemblyResolver.cs" />
|
<Compile Include="MyAssemblyResolver.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -4,6 +4,7 @@ using System.Drawing.Imaging;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using TGASharpLib;
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@ -16,6 +17,7 @@ namespace AssetStudio
|
|||||||
public List<ImportedKeyframedAnimation> AnimationList { get; protected set; } = new List<ImportedKeyframedAnimation>();
|
public List<ImportedKeyframedAnimation> AnimationList { get; protected set; } = new List<ImportedKeyframedAnimation>();
|
||||||
public List<ImportedMorph> MorphList { get; protected set; } = new List<ImportedMorph>();
|
public List<ImportedMorph> MorphList { get; protected set; } = new List<ImportedMorph>();
|
||||||
|
|
||||||
|
private string imageFormat;
|
||||||
private Avatar avatar;
|
private Avatar avatar;
|
||||||
private HashSet<AnimationClip> animationClipHashSet = new HashSet<AnimationClip>();
|
private HashSet<AnimationClip> animationClipHashSet = new HashSet<AnimationClip>();
|
||||||
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
||||||
@ -23,8 +25,9 @@ namespace AssetStudio
|
|||||||
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
||||||
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
||||||
|
|
||||||
public ModelConverter(GameObject m_GameObject, AnimationClip[] animationList = null)
|
public ModelConverter(GameObject m_GameObject, string imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
|
this.imageFormat = imageFormat;
|
||||||
if (m_GameObject.m_Animator != null)
|
if (m_GameObject.m_Animator != null)
|
||||||
{
|
{
|
||||||
InitWithAnimator(m_GameObject.m_Animator);
|
InitWithAnimator(m_GameObject.m_Animator);
|
||||||
@ -47,8 +50,9 @@ namespace AssetStudio
|
|||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelConverter(string rootName, List<GameObject> m_GameObjects, AnimationClip[] animationList = null)
|
public ModelConverter(string rootName, List<GameObject> m_GameObjects, string imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
|
this.imageFormat = imageFormat;
|
||||||
RootFrame = CreateFrame(rootName, Vector3.Zero, new Quaternion(0, 0, 0, 0), Vector3.One);
|
RootFrame = CreateFrame(rootName, Vector3.Zero, new Quaternion(0, 0, 0, 0), Vector3.One);
|
||||||
foreach (var m_GameObject in m_GameObjects)
|
foreach (var m_GameObject in m_GameObjects)
|
||||||
{
|
{
|
||||||
@ -76,8 +80,9 @@ namespace AssetStudio
|
|||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelConverter(Animator m_Animator, AnimationClip[] animationList = null)
|
public ModelConverter(Animator m_Animator, string imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
|
this.imageFormat = imageFormat;
|
||||||
InitWithAnimator(m_Animator);
|
InitWithAnimator(m_Animator);
|
||||||
if (animationList == null)
|
if (animationList == null)
|
||||||
{
|
{
|
||||||
@ -689,15 +694,16 @@ namespace AssetStudio
|
|||||||
|
|
||||||
texture.Dest = dest;
|
texture.Dest = dest;
|
||||||
|
|
||||||
|
var ext = $".{imageFormat.ToLower()}";
|
||||||
if (textureNameDictionary.TryGetValue(m_Texture2D, out var textureName))
|
if (textureNameDictionary.TryGetValue(m_Texture2D, out var textureName))
|
||||||
{
|
{
|
||||||
texture.Name = textureName;
|
texture.Name = textureName;
|
||||||
}
|
}
|
||||||
else if (ImportedHelpers.FindTexture(m_Texture2D.m_Name + ".png", TextureList) != null) //已有相同名字的图片
|
else if (ImportedHelpers.FindTexture(m_Texture2D.m_Name + ext, TextureList) != null) //已有相同名字的图片
|
||||||
{
|
{
|
||||||
for (int i = 1; ; i++)
|
for (int i = 1; ; i++)
|
||||||
{
|
{
|
||||||
var name = m_Texture2D.m_Name + $" ({i}).png";
|
var name = m_Texture2D.m_Name + $" ({i}){ext}";
|
||||||
if (ImportedHelpers.FindTexture(name, TextureList) == null)
|
if (ImportedHelpers.FindTexture(name, TextureList) == null)
|
||||||
{
|
{
|
||||||
texture.Name = name;
|
texture.Name = name;
|
||||||
@ -708,7 +714,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texture.Name = m_Texture2D.m_Name + ".png";
|
texture.Name = m_Texture2D.m_Name + ext;
|
||||||
textureNameDictionary.Add(m_Texture2D, texture.Name);
|
textureNameDictionary.Add(m_Texture2D, texture.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,7 +745,22 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
using (var stream = new MemoryStream())
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
bitmap.Save(stream, ImageFormat.Png);
|
switch (imageFormat)
|
||||||
|
{
|
||||||
|
case "BMP":
|
||||||
|
bitmap.Save(stream, ImageFormat.Bmp);
|
||||||
|
break;
|
||||||
|
case "PNG":
|
||||||
|
bitmap.Save(stream, ImageFormat.Png);
|
||||||
|
break;
|
||||||
|
case "JPEG":
|
||||||
|
bitmap.Save(stream, ImageFormat.Jpeg);
|
||||||
|
break;
|
||||||
|
case "TGA":
|
||||||
|
var tga = new TGA(bitmap);
|
||||||
|
tga.Save(stream);
|
||||||
|
break;
|
||||||
|
}
|
||||||
iTex = new ImportedTexture(stream, name);
|
iTex = new ImportedTexture(stream, name);
|
||||||
TextureList.Add(iTex);
|
TextureList.Add(iTex);
|
||||||
bitmap.Dispose();
|
bitmap.Dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user