- [Core] Added export option to include materials with models in /Materials.

- [GUI] fix issue with `Reset` button causing unintended behaviour.
- [Core] fix bug where `Logger` causes performance issues.
This commit is contained in:
Razmoth
2024-01-30 19:57:10 +04:00
parent f2d65e458c
commit 92d7470082
14 changed files with 144 additions and 152 deletions

View File

@@ -10,6 +10,7 @@
<add key="filterPrecision" value="0.25" />
<add key="exportAllNodes" value="True" />
<add key="exportSkins" value="True" />
<add key="exportMaterials" value="False" />
<add key="exportAnimations" value="True" />
<add key="boneSize" value="10" />
<add key="fbxVersion" value="3" />
@@ -21,7 +22,7 @@
<add key="enableFileLogging" value="False" />
<add key="minimalAssetMap" value="True" />
<add key="allowDuplicates" value="False" />
<add key="texs" value='' />
<add key="texs" value='{}' />
<add key="uvs" value='{"UV0":{"Item1":true,"Item2":0},"UV1":{"Item1":true,"Item2":1},"UV2":{"Item1":false,"Item2":0},"UV3":{"Item1":false,"Item2":0},"UV4":{"Item1":false,"Item2":0},"UV5":{"Item1":false,"Item2":0},"UV6":{"Item1":false,"Item2":0},"UV7":{"Item1":false,"Item2":0}}' />
<add key="types" value='{"Animation":{"Item1":true,"Item2":false},"AnimationClip":{"Item1":true,"Item2":true},"Animator":{"Item1":true,"Item2":true},"AnimatorController":{"Item1":true,"Item2":false},"AnimatorOverrideController":{"Item1":true,"Item2":false},"AssetBundle":{"Item1":true,"Item2":false},"AudioClip":{"Item1":true,"Item2":true},"Avatar":{"Item1":true,"Item2":false},"Font":{"Item1":true,"Item2":true},"GameObject":{"Item1":true,"Item2":false},"IndexObject":{"Item1":true,"Item2":false},"Material":{"Item1":true,"Item2":true},"Mesh":{"Item1":true,"Item2":true},"MeshFilter":{"Item1":true,"Item2":false},"MeshRenderer":{"Item1":true,"Item2":false},"MiHoYoBinData":{"Item1":true,"Item2":true},"MonoBehaviour":{"Item1":true,"Item2":true},"MonoScript":{"Item1":true,"Item2":false},"MovieTexture":{"Item1":true,"Item2":true},"PlayerSettings":{"Item1":true,"Item2":false},"RectTransform":{"Item1":true,"Item2":false},"Shader":{"Item1":true,"Item2":true},"SkinnedMeshRenderer":{"Item1":true,"Item2":false},"Sprite":{"Item1":true,"Item2":true},"SpriteAtlas":{"Item1":true,"Item2":false},"TextAsset":{"Item1":true,"Item2":true},"Texture2D":{"Item1":true,"Item2":true},"Transform":{"Item1":true,"Item2":false},"VideoClip":{"Item1":true,"Item2":true},"ResourceManager":{"Item1":true,"Item2":false}}' />
</appSettings>

View File

@@ -365,12 +365,24 @@ namespace AssetStudio.CLI
imageFormat = Properties.Settings.Default.convertType,
game = Studio.Game,
collectAnimations = Properties.Settings.Default.collectAnimations,
exportMaterials = Properties.Settings.Default.exportMaterials,
materials = new HashSet<Material>(),
uvs = JsonConvert.DeserializeObject<Dictionary<string, (bool, int)>>(Properties.Settings.Default.uvs),
texs = JsonConvert.DeserializeObject<Dictionary<string, int>>(Properties.Settings.Default.texs),
};
var convert = animationList != null
? new ModelConverter(m_Animator, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
: new ModelConverter(m_Animator, options);
if (options.exportMaterials)
{
var materialExportPath = Path.Combine(exportFullPath, "Materials");
Directory.CreateDirectory(materialExportPath);
foreach (var material in options.materials)
{
var matItem = new AssetItem(material);
ExportJSONFile(matItem, materialExportPath);
}
}
ExportFbx(convert, exportFullPath);
return true;
}
@@ -391,6 +403,8 @@ namespace AssetStudio.CLI
imageFormat = Properties.Settings.Default.convertType,
game = Studio.Game,
collectAnimations = Properties.Settings.Default.collectAnimations,
exportMaterials = Properties.Settings.Default.exportMaterials,
materials = new HashSet<Material>(),
uvs = JsonConvert.DeserializeObject<Dictionary<string, (bool, int)>>(Properties.Settings.Default.uvs),
texs = JsonConvert.DeserializeObject<Dictionary<string, int>>(Properties.Settings.Default.texs),
};
@@ -403,6 +417,16 @@ namespace AssetStudio.CLI
Logger.Info($"GameObject {gameObject.m_Name} has no mesh, skipping...");
return false;
}
if (options.exportMaterials)
{
var materialExportPath = Path.Combine(exportPath, "Materials");
Directory.CreateDirectory(materialExportPath);
foreach (var material in options.materials)
{
var matItem = new AssetItem(material);
ExportJSONFile(matItem, materialExportPath);
}
}
exportPath = exportPath + FixFileName(gameObject.m_Name) + ".fbx";
ExportFbx(convert, exportPath);
return true;

View File

@@ -40,7 +40,8 @@ namespace AssetStudio.CLI
}
Studio.Game = game;
Logger.Default = new ConsoleLogger() { Flags = o.LoggerFlags.Aggregate((e, x) => e |= x) };
Logger.Default = new ConsoleLogger();
Logger.Flags = o.LoggerFlags.Aggregate((e, x) => e |= x);
Logger.FileLogging = Settings.Default.enableFileLogging;
AssetsHelper.Minimal = Settings.Default.minimalAssetMap;
AssetsHelper.SetUnityVersion(o.UnityVersion);
@@ -67,6 +68,10 @@ namespace AssetStudio.CLI
{
TypeFlags.SetType(ClassIDType.GameObject, true, false);
}
if (Settings.Default.exportMaterials)
{
TypeFlags.SetType(ClassIDType.Material, true, false);
}
}
}

View File

@@ -43,6 +43,7 @@ namespace AssetStudio.CLI.Properties {
public decimal filterPrecision => AppSettings.Get("filterPrecision", (decimal)0.25);
public bool exportAllNodes => AppSettings.Get("exportAllNodes", true);
public bool exportSkins => AppSettings.Get("exportSkins", true);
public bool exportMaterials => AppSettings.Get("exportMaterials", false);
public bool collectAnimations => AppSettings.Get("collectAnimations", true);
public bool exportAnimations => AppSettings.Get("exportAnimations", true);
public decimal boneSize => AppSettings.Get("boneSize", (decimal)10);