This commit is contained in:
Razmoth
2024-01-27 20:42:18 +04:00
parent 873597730c
commit e19d7b91fe
26 changed files with 484 additions and 348 deletions

View File

@@ -22,6 +22,7 @@
<add key="minimalAssetMap" value="True" />
<add key="allowDuplicates" value="False" />
<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="texs" value="{}" />
<add key="texs" value='{"0": "", "1": "", "2": "", "3": "", "4": "", "5": "", "6": "", "7": ""}' />
<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>
</configuration>

View File

@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0-windows;net7.0-windows</TargetFrameworks>
<TargetFrameworks>net7.0-windows;net8.0-windows</TargetFrameworks>
<ApplicationIcon>Resources\as.ico</ApplicationIcon>
<Version>1.00.00</Version>
<AssemblyVersion>1.00.00</AssemblyVersion>
<FileVersion>1.00.00</FileVersion>
<Version>1.36.00</Version>
<AssemblyVersion>1.36.00</AssemblyVersion>
<FileVersion>1.36.00</FileVersion>
<Copyright>Copyright © Razmoth 2022; Copyright © Perfare 2018-2022</Copyright>
<BaseOutputPath>..\AssetStudio.GUI\bin</BaseOutputPath>
</PropertyGroup>

View File

@@ -33,7 +33,6 @@ namespace AssetStudio.CLI
optionsBinder.UnityVersion,
optionsBinder.GroupAssetsType,
optionsBinder.AssetExportType,
optionsBinder.Model,
optionsBinder.Key,
optionsBinder.AIFile,
optionsBinder.DummyDllFolder,
@@ -61,7 +60,6 @@ namespace AssetStudio.CLI
public string UnityVersion { get; set; }
public AssetGroupOption GroupAssetsType { get; set; }
public ExportType AssetExportType { get; set; }
public bool Model { get; set; }
public byte Key { get; set; }
public FileInfo AIFile { get; set; }
public DirectoryInfo DummyDllFolder { get; set; }
@@ -84,7 +82,6 @@ namespace AssetStudio.CLI
public readonly Option<string> UnityVersion;
public readonly Option<AssetGroupOption> GroupAssetsType;
public readonly Option<ExportType> AssetExportType;
public readonly Option<bool> Model;
public readonly Option<byte> Key;
public readonly Option<FileInfo> AIFile;
public readonly Option<DirectoryInfo> DummyDllFolder;
@@ -106,7 +103,6 @@ namespace AssetStudio.CLI
UnityVersion = new Option<string>("--unity_version", "Specify Unity version.");
GroupAssetsType = new Option<AssetGroupOption>("--group_assets", "Specify how exported assets should be grouped.");
AssetExportType = new Option<ExportType>("--export_type", "Specify how assets should be exported.");
Model = new Option<bool>("--models", "Enable to export models only");
AIFile = new Option<FileInfo>("--ai_file", "Specify asset_index json file path (to recover GI containers).").LegalFilePathsOnly();
DummyDllFolder = new Option<DirectoryInfo>("--dummy_dlls", "Specify DummyDll path.").LegalFilePathsOnly();
Input = new Argument<FileInfo>("input_path", "Input file/folder.").LegalFilePathsOnly();
@@ -200,7 +196,6 @@ namespace AssetStudio.CLI
UnityVersion = bindingContext.ParseResult.GetValueForOption(UnityVersion),
GroupAssetsType = bindingContext.ParseResult.GetValueForOption(GroupAssetsType),
AssetExportType = bindingContext.ParseResult.GetValueForOption(AssetExportType),
Model = bindingContext.ParseResult.GetValueForOption(Model),
Key = bindingContext.ParseResult.GetValueForOption(Key),
AIFile = bindingContext.ParseResult.GetValueForOption(AIFile),
DummyDllFolder = bindingContext.ParseResult.GetValueForOption(DummyDllFolder),

View File

@@ -366,7 +366,7 @@ namespace AssetStudio.CLI
game = Studio.Game,
collectAnimations = Properties.Settings.Default.collectAnimations,
uvs = JsonConvert.DeserializeObject<Dictionary<string, (bool, int)>>(Properties.Settings.Default.uvs),
texs = JsonConvert.DeserializeObject<Dictionary<string, int>>(Properties.Settings.Default.texs),
texs = JsonConvert.DeserializeObject<Dictionary<int, string>>(Properties.Settings.Default.texs),
};
var convert = animationList != null
? new ModelConverter(m_Animator, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray())
@@ -392,7 +392,7 @@ namespace AssetStudio.CLI
game = Studio.Game,
collectAnimations = Properties.Settings.Default.collectAnimations,
uvs = JsonConvert.DeserializeObject<Dictionary<string, (bool, int)>>(Properties.Settings.Default.uvs),
texs = JsonConvert.DeserializeObject<Dictionary<string, int>>(Properties.Settings.Default.texs),
texs = JsonConvert.DeserializeObject<Dictionary<int, string>>(Properties.Settings.Default.texs),
};
var convert = animationList != null
? new ModelConverter(gameObject, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray())

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using AssetStudio.CLI.Properties;
using Newtonsoft.Json;
using static AssetStudio.CLI.Studio;
namespace AssetStudio.CLI
@@ -44,10 +45,34 @@ namespace AssetStudio.CLI
AssetsHelper.Minimal = Settings.Default.minimalAssetMap;
AssetsHelper.SetUnityVersion(o.UnityVersion);
if (o.TypeFilter == null)
{
TypeFlags.SetTypes(JsonConvert.DeserializeObject<Dictionary<ClassIDType, (bool, bool)>>(Settings.Default.types));
}
else
{
foreach (var type in o.TypeFilter)
{
TypeFlags.SetType(type, true, true);
}
if (ClassIDType.GameObject.CanExport() || ClassIDType.Animator.CanExport())
{
TypeFlags.SetType(ClassIDType.Texture2D, true, false);
if (ClassIDType.GameObject.CanExport())
{
TypeFlags.SetType(ClassIDType.Animator, true, false);
}
else if(ClassIDType.Animator.CanExport())
{
TypeFlags.SetType(ClassIDType.GameObject, true, false);
}
}
}
assetsManager.Silent = o.Silent;
assetsManager.Game = game;
assetsManager.SpecifyUnityVersion = o.UnityVersion;
ModelOnly = o.Model;
o.Output.Create();
if (o.Key != default)

View File

@@ -55,6 +55,7 @@ namespace AssetStudio.CLI.Properties {
public bool enableFileLogging => AppSettings.Get("enableFileLogging", false);
public bool minimalAssetMap => AppSettings.Get("minimalAssetMap", true);
public bool allowDuplicates => AppSettings.Get("allowDuplicates", false);
public string types => AppSettings.Get("types", string.Empty);
public string texs => AppSettings.Get("texs", string.Empty);
public string uvs => AppSettings.Get("uvs", string.Empty);

View File

@@ -25,7 +25,6 @@ namespace AssetStudio.CLI
internal static class Studio
{
public static Game Game;
public static bool ModelOnly = false;
public static bool SkipContainer = false;
public static AssetsManager assetsManager = new AssetsManager() { ResolveDependencies = false };
public static AssemblyLoader assemblyLoader = new AssemblyLoader();
@@ -286,25 +285,25 @@ namespace AssetStudio.CLI
switch (asset)
{
case GameObject m_GameObject:
exportable = ModelOnly && m_GameObject.HasModel();
exportable = ClassIDType.GameObject.CanExport() && m_GameObject.HasModel();
break;
case Texture2D m_Texture2D:
if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path))
assetItem.FullSize = asset.byteSize + m_Texture2D.m_StreamData.size;
exportable = !ModelOnly;
exportable = ClassIDType.Texture2D.CanExport();
break;
case AudioClip m_AudioClip:
if (!string.IsNullOrEmpty(m_AudioClip.m_Source))
assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size;
exportable = !ModelOnly;
exportable = ClassIDType.AudioClip.CanExport();
break;
case VideoClip m_VideoClip:
if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath))
assetItem.FullSize = asset.byteSize + (long)m_VideoClip.m_ExternalResources.m_Size;
exportable = !ModelOnly;
assetItem.FullSize = asset.byteSize + m_VideoClip.m_ExternalResources.m_Size;
exportable = ClassIDType.VideoClip.CanExport();
break;
case MonoBehaviour m_MonoBehaviour:
exportable = !ModelOnly && assemblyLoader.Loaded;
exportable = ClassIDType.MonoBehaviour.CanExport();
break;
case AssetBundle m_AssetBundle:
foreach (var m_Container in m_AssetBundle.m_Container)
@@ -317,30 +316,36 @@ namespace AssetStudio.CLI
containers.Add((m_AssetBundle.m_PreloadTable[k], m_Container.Key));
}
}
exportable = ClassIDType.AssetBundle.CanExport();
break;
case IndexObject m_IndexObject:
foreach (var index in m_IndexObject.AssetMap)
{
mihoyoBinDataNames.Add((index.Value.Object, index.Key));
}
exportable = ClassIDType.IndexObject.CanExport();
break;
case ResourceManager m_ResourceManager:
foreach (var m_Container in m_ResourceManager.m_Container)
{
containers.Add((m_Container.Value, m_Container.Key));
}
exportable = ClassIDType.GameObject.CanExport();
break;
case Mesh _:
case TextAsset _:
case AnimationClip _:
case Font _:
case MovieTexture _:
case Sprite _:
case Material _:
case MiHoYoBinData _:
case Shader _:
case Animator _:
exportable = !ModelOnly;
case Mesh _ when ClassIDType.Mesh.CanExport():
case TextAsset _ when ClassIDType.TextAsset.CanExport():
case AnimationClip _ when ClassIDType.Font.CanExport():
case Font _ when ClassIDType.GameObject.CanExport():
case MovieTexture _ when ClassIDType.MovieTexture.CanExport():
case Sprite _ when ClassIDType.Sprite.CanExport():
case Material _ when ClassIDType.Material.CanExport():
case MiHoYoBinData _ when ClassIDType.MiHoYoBinData.CanExport():
case Shader _ when ClassIDType.Shader.CanExport():
case Animator _ when ClassIDType.Animator.CanExport():
exportable = true;
break;
}
if (assetItem.Text == "")