mirror of
https://github.com/AssetRipper/AssetRipper.Mining.git
synced 2026-11-13 20:05:34 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51873aaef9 | ||
|
|
a43a560f9a | ||
|
|
54eb41b856 | ||
|
|
2b22375c90 | ||
|
|
d989f9f16a | ||
|
|
19fb8b36dd | ||
|
|
9479c1aa66 | ||
|
|
5bb396ffda | ||
|
|
e014834c04 | ||
|
|
bf8806c154 | ||
|
|
40841a3c19 | ||
|
|
a0fc1e8bc9 | ||
|
|
5832762d66 | ||
|
|
cfcbb3e7ba | ||
|
|
a3dfe6341b | ||
|
|
bd12d9eae3 | ||
|
|
87328aaac2 | ||
|
|
9ca9112942 |
No files matched your search
+3
-7
@@ -1,18 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetsTools.NET" Version="3.0.0-preview3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AssetRipper.Mining.PredefinedAssets\AssetRipper.Mining.PredefinedAssets.csproj" />
|
||||
<ProjectReference Include="..\..\AssetRipper\Source\AssetRipper.Import\AssetRipper.Import.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,12 +0,0 @@
|
||||
using AssetsTools.NET;
|
||||
|
||||
namespace AssetRipper.Mining.EngineFileExtractor;
|
||||
|
||||
internal static class AssetTypeValueFieldExtensions
|
||||
{
|
||||
public static AssetTypeValueField? TryGet(this AssetTypeValueField @this, string name)
|
||||
{
|
||||
AssetTypeValueField result = @this.Get(name);
|
||||
return result.IsDummy ? null : result;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
using AssetRipper.Mining.PredefinedAssets;
|
||||
using AssetsTools.NET;
|
||||
using AssetsTools.NET.Extra;
|
||||
using System.Diagnostics;
|
||||
using AssetRipper.Assets;
|
||||
using AssetRipper.Assets.Bundles;
|
||||
using AssetRipper.Assets.Collections;
|
||||
using AssetRipper.Assets.Generics;
|
||||
using AssetRipper.Assets.IO;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.Import.AssetCreation;
|
||||
using AssetRipper.Import.Structure.Assembly.Serializable;
|
||||
using AssetRipper.Import.Structure.Assembly.TypeTrees;
|
||||
using AssetRipper.IO.Endian;
|
||||
using AssetRipper.IO.Files.SerializedFiles.Parser;
|
||||
using AssetRipper.Mining.PredefinedAssets;
|
||||
using Object = AssetRipper.Mining.PredefinedAssets.Object;
|
||||
|
||||
namespace AssetRipper.Mining.EngineFileExtractor;
|
||||
@@ -40,32 +48,52 @@ internal static class Program
|
||||
|
||||
private static Dictionary<long, Object> ReadDictionary(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
return LoadAllAssetInfo(path).OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
}
|
||||
|
||||
private static IEnumerable<UnityAsset> LoadAllAssets(string path)
|
||||
private static AssetCollection LoadAllAssets(string path)
|
||||
{
|
||||
AssetsManager manager = new();
|
||||
AssetsFileInstance assetsFileInstance = manager.LoadAssetsFile(path, false);
|
||||
foreach (AssetFileInfo assetFileInfo in assetsFileInstance.file.AssetInfos)
|
||||
return GameBundle.FromPaths([path], TypeTreeAssetFactory.Instance).FetchAssetCollections().Single();
|
||||
}
|
||||
|
||||
private sealed class TypeTreeAssetFactory : AssetFactoryBase
|
||||
{
|
||||
public static TypeTreeAssetFactory Instance { get; } = new();
|
||||
public override IUnityObjectBase? ReadAsset(AssetInfo assetInfo, ReadOnlyArraySegment<byte> assetData, SerializedType? assetType)
|
||||
{
|
||||
yield return new UnityAsset(manager, assetsFileInstance, assetFileInfo);
|
||||
ArgumentNullException.ThrowIfNull(assetType);
|
||||
ArgumentOutOfRangeException.ThrowIfZero(assetType.OldType.Nodes.Count);
|
||||
if (!TypeTreeNodeStruct.TryMakeFromTypeTree(assetType.OldType, out TypeTreeNodeStruct root))
|
||||
{
|
||||
throw new NotSupportedException("Type tree node struct creation failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
TypeTreeObject asset = TypeTreeObject.Create(assetInfo, root);
|
||||
EndianSpanReader reader = new(assetData, assetInfo.Collection.EndianType);
|
||||
asset.Read(ref reader);
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<KeyValuePair<long, Object>> LoadAllAssetInfo(string path)
|
||||
{
|
||||
foreach (UnityAsset asset in LoadAllAssets(path))
|
||||
foreach (TypeTreeObject asset in LoadAllAssets(path).Cast<TypeTreeObject>())
|
||||
{
|
||||
Object obj;
|
||||
switch (asset.TypeID)
|
||||
switch (asset.ClassID)
|
||||
{
|
||||
case 21://Material
|
||||
{
|
||||
obj = new Material()
|
||||
{
|
||||
Name = asset.Name,
|
||||
Shader = asset.TryGetAsset("m_Shader")?.Name
|
||||
Name = asset.Name(),
|
||||
Shader = asset.TryGetAsset("m_Shader")?.Name()
|
||||
};
|
||||
}
|
||||
break;
|
||||
@@ -73,7 +101,7 @@ internal static class Program
|
||||
{
|
||||
obj = new Texture2D()
|
||||
{
|
||||
Name = asset.Name,
|
||||
Name = asset.Name(),
|
||||
Height = asset.GetInt32("m_Height"),
|
||||
Width = asset.GetInt32("m_Width")
|
||||
};
|
||||
@@ -83,40 +111,43 @@ internal static class Program
|
||||
{
|
||||
obj = new Mesh()
|
||||
{
|
||||
Name = asset.Name,
|
||||
VertexCount = asset.BaseField.Get("m_VertexData").Get("m_VertexCount").AsInt,
|
||||
SubMeshCount = asset.BaseField.Get("m_SubMeshes").Get("Array").Children.Count
|
||||
Name = asset.Name(),
|
||||
VertexCount = asset.ReleaseFields.ContainsField("m_VertexData")
|
||||
? asset.ReleaseFields["m_VertexData"]["m_VertexCount"].AsInt32
|
||||
: asset.ReleaseFields["m_CompressedMesh"]["m_Vertices"]["m_NumItems"].AsInt32,
|
||||
SubMeshCount = asset.ReleaseFields["m_SubMeshes"].AsAssetArray.Length,
|
||||
LocalAABB = asset.ReleaseFields["m_LocalAABB"].AsAxisAlignedBoundingBox(),
|
||||
};
|
||||
}
|
||||
break;
|
||||
case 48://Shader
|
||||
{
|
||||
string[] propertyNames;
|
||||
AssetTypeValueField serializedShader = asset.BaseField.Get("m_ParsedForm");
|
||||
if (serializedShader.IsDummy)
|
||||
SerializableStructure? serializedShader = asset.ReleaseFields.TryGetField("m_ParsedForm")?.AsStructure;
|
||||
if (serializedShader is null)
|
||||
{
|
||||
propertyNames = Array.Empty<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<AssetTypeValueField> propsList = serializedShader.Get("m_PropInfo").Get("m_Props").Get("Array").Children;
|
||||
if (propsList.Count == 0)
|
||||
IUnityAssetBase[] propsList = serializedShader["m_PropInfo"]["m_Props"].AsAssetArray;
|
||||
if (propsList.Length == 0)
|
||||
{
|
||||
propertyNames = Array.Empty<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyNames = new string[propsList.Count];
|
||||
for (int i = 0; i < propsList.Count; i++)
|
||||
propertyNames = new string[propsList.Length];
|
||||
for (int i = 0; i < propsList.Length; i++)
|
||||
{
|
||||
propertyNames[i] = propsList[i].Get("m_Name").AsString ?? "";
|
||||
propertyNames[i] = ((SerializableStructure)propsList[i])["m_Name"].AsString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
obj = new Shader()
|
||||
{
|
||||
Name = asset.Name,
|
||||
Name = asset.Name(),
|
||||
PropertyNames = propertyNames
|
||||
};
|
||||
}
|
||||
@@ -127,7 +158,7 @@ internal static class Program
|
||||
{
|
||||
obj = new Cubemap()
|
||||
{
|
||||
Name = asset.Name,
|
||||
Name = asset.Name(),
|
||||
Height = asset.GetInt32("m_Height"),
|
||||
Width = asset.GetInt32("m_Width")
|
||||
};
|
||||
@@ -135,14 +166,14 @@ internal static class Program
|
||||
break;
|
||||
case 114://MonoBehaviour
|
||||
{
|
||||
UnityAsset? script = asset.TryGetAsset("m_Script");
|
||||
TypeTreeObject? script = asset.TryGetAsset("m_Script");
|
||||
obj = new MonoBehaviour()
|
||||
{
|
||||
Name = asset.Name,
|
||||
AssemblyName = script?.GetString("m_AssemblyName") ?? "",
|
||||
Name = asset.Name(),
|
||||
AssemblyName = script?.TryGetString("m_AssemblyName") ?? "",
|
||||
Namespace = script?.GetString("m_Namespace") ?? "",
|
||||
ClassName = script?.GetString("m_ClassName") ?? "",
|
||||
GameObject = asset.TryGetAsset("m_GameObject")?.Name,
|
||||
GameObject = asset.TryGetAsset("m_GameObject")?.Name(),
|
||||
Enabled = asset.GetBoolean("m_Enabled")
|
||||
};
|
||||
}
|
||||
@@ -151,7 +182,7 @@ internal static class Program
|
||||
{
|
||||
obj = new MonoScript()
|
||||
{
|
||||
AssemblyName = asset.GetString("m_AssemblyName"),
|
||||
AssemblyName = asset.TryGetString("m_AssemblyName") ?? "",
|
||||
Namespace = asset.GetString("m_Namespace"),
|
||||
ClassName = asset.GetString("m_ClassName")
|
||||
};
|
||||
@@ -163,8 +194,8 @@ internal static class Program
|
||||
{
|
||||
obj = new Sprite()
|
||||
{
|
||||
Name = asset.Name,
|
||||
Texture = asset.ResolveAsset(asset.BaseField.Get("m_RD").Get("texture"))?.Name,
|
||||
Name = asset.Name(),
|
||||
Texture = asset.ResolveAsset(asset.ReleaseFields["m_RD"]["texture"].AsPPtr)?.Name(),
|
||||
};
|
||||
}
|
||||
break;
|
||||
@@ -173,86 +204,12 @@ internal static class Program
|
||||
default:
|
||||
obj = new GenericNamedObject()
|
||||
{
|
||||
TypeID = asset.TypeID,
|
||||
Name = asset.Name
|
||||
TypeID = asset.ClassID,
|
||||
Name = asset.Name()
|
||||
};
|
||||
break;
|
||||
}
|
||||
yield return new KeyValuePair<long, Object>(asset.PathID, obj);
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
|
||||
private readonly struct UnityAsset
|
||||
{
|
||||
private readonly AssetsManager manager;
|
||||
private readonly AssetsFileInstance file;
|
||||
private readonly AssetFileInfo info;
|
||||
|
||||
public UnityAsset(AssetsManager manager, AssetsFileInstance file, AssetFileInfo info)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.file = file;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public int TypeID
|
||||
{
|
||||
get
|
||||
{
|
||||
int result = info.TypeId;
|
||||
return result < 0 ? 114 : result;
|
||||
}
|
||||
}
|
||||
|
||||
public long PathID => info.PathId;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
AssetTypeValueField baseField = BaseField;
|
||||
string? name = baseField.TryGet("m_Name")?.AsString;
|
||||
if (string.IsNullOrEmpty(name) && TypeID == 48)//Shader
|
||||
{
|
||||
name = baseField.TryGet("m_ParsedForm")?.TryGet("m_Name")?.AsString //5.5 and later
|
||||
?? baseField.TryGet("m_PathName")?.AsString; //Earlier than 5.5
|
||||
|
||||
if (string.IsNullOrEmpty(name)
|
||||
&& (baseField.TryGet("m_Script")?.AsString?.StartsWith("Shader \"Standard\"", StringComparison.Ordinal) ?? false))
|
||||
{
|
||||
//A regex could be used to generalize, but as far as I know, Standard is the only one like this.
|
||||
name = "Standard";
|
||||
}
|
||||
}
|
||||
return name ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
public string GetString(string fieldName) => BaseField.TryGet(fieldName)?.AsString ?? "";
|
||||
|
||||
public int GetInt32(string fieldName) => BaseField.Get(fieldName).AsInt;
|
||||
|
||||
public bool GetBoolean(string fieldName) => BaseField.Get(fieldName).AsBool;
|
||||
|
||||
public UnityAsset? TryGetAsset(string fieldName)
|
||||
{
|
||||
return ResolveAsset(BaseField.Get(fieldName));
|
||||
}
|
||||
|
||||
public UnityAsset? ResolveAsset(AssetTypeValueField pptrField)
|
||||
{
|
||||
AssetExternal assetExternal = manager.GetExtAsset(file, pptrField);
|
||||
return assetExternal.file is null || assetExternal.info is null
|
||||
? null
|
||||
: new UnityAsset(manager, assetExternal.file, assetExternal.info);
|
||||
}
|
||||
|
||||
public AssetTypeValueField BaseField => manager.GetBaseField(file, info);
|
||||
|
||||
private string GetDebuggerDisplay()
|
||||
{
|
||||
return $"{TypeID} : {Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using AssetRipper.Import.Structure.Assembly.Serializable;
|
||||
using AssetRipper.Mining.PredefinedAssets;
|
||||
using System.Numerics;
|
||||
|
||||
namespace AssetRipper.Mining.EngineFileExtractor;
|
||||
|
||||
internal static class SerializableValueExtensions
|
||||
{
|
||||
public static Vector3 AsVector3(this SerializableValue value)
|
||||
{
|
||||
return new Vector3(value["x"].AsSingle, value["y"].AsSingle, value["z"].AsSingle);
|
||||
}
|
||||
|
||||
public static AxisAlignedBoundingBox AsAxisAlignedBoundingBox(this SerializableValue value)
|
||||
{
|
||||
return new AxisAlignedBoundingBox(value["m_Center"].AsVector3(), value["m_Extent"].AsVector3());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.Import.AssetCreation;
|
||||
using AssetRipper.Import.Structure.Assembly.Serializable;
|
||||
|
||||
namespace AssetRipper.Mining.EngineFileExtractor;
|
||||
|
||||
internal static class TypeTreeObjectExtensions
|
||||
{
|
||||
public static string Name(this TypeTreeObject asset)
|
||||
{
|
||||
SerializableStructure baseField = asset.ReleaseFields;
|
||||
string? name = baseField.TryGetField("m_Name")?.AsString;
|
||||
if (string.IsNullOrEmpty(name) && asset.ClassID == 48)//Shader
|
||||
{
|
||||
name = baseField.TryGetField("m_ParsedForm")?.AsStructure.TryGetField("m_Name")?.AsString //5.5 and later
|
||||
?? baseField.TryGetField("m_PathName")?.AsString; //Earlier than 5.5
|
||||
|
||||
if (string.IsNullOrEmpty(name)
|
||||
&& (baseField.TryGetField("m_Script")?.AsString?.StartsWith("Shader \"Standard\"", StringComparison.Ordinal) ?? false))
|
||||
{
|
||||
//A regex could be used to generalize, but as far as I know, Standard is the only one like this.
|
||||
name = "Standard";
|
||||
}
|
||||
}
|
||||
return name ?? "";
|
||||
}
|
||||
|
||||
public static TypeTreeObject? TryGetAsset(this TypeTreeObject asset, string fieldName)
|
||||
{
|
||||
return asset.ReleaseFields.TryGetField(fieldName)?.AsAsset is IPPtr pptr
|
||||
? asset.ResolveAsset(pptr)
|
||||
: null;
|
||||
}
|
||||
|
||||
public static bool GetBoolean(this TypeTreeObject asset, string fieldName)
|
||||
{
|
||||
return asset.ReleaseFields[fieldName].AsBoolean;
|
||||
}
|
||||
|
||||
public static int GetInt32(this TypeTreeObject asset, string fieldName)
|
||||
{
|
||||
return asset.ReleaseFields[fieldName].AsInt32;
|
||||
}
|
||||
|
||||
public static string GetString(this TypeTreeObject asset, string fieldName)
|
||||
{
|
||||
return asset.ReleaseFields[fieldName].AsString;
|
||||
}
|
||||
|
||||
public static string? TryGetString(this TypeTreeObject asset, string fieldName)
|
||||
{
|
||||
return asset.ReleaseFields.TryGetField(fieldName)?.AsString;
|
||||
}
|
||||
|
||||
public static TypeTreeObject? ResolveAsset(this TypeTreeObject asset, IPPtr pptr)
|
||||
{
|
||||
return asset.Collection.TryGetAsset(new PPtr<TypeTreeObject>(pptr.FileID, pptr.PathID));
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net7.0;net8.0</TargetFrameworks>
|
||||
<TargetFrameworks>net4.8;net7.0;net8.0</TargetFrameworks>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -11,14 +11,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NUnit" Version="3.14.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
|
||||
<PackageReference Include="NUnit" Version="4.2.1" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets.Tests;
|
||||
|
||||
public class Tests
|
||||
@@ -40,4 +43,43 @@ public class Tests
|
||||
return package.ToJson();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Vector3Serialization()
|
||||
{
|
||||
string result = """
|
||||
{
|
||||
"X": 1,
|
||||
"Y": 2,
|
||||
"Z": 3
|
||||
}
|
||||
""".Replace("\r", null);
|
||||
Vector3 vector = new Vector3(1.0f, 2.0f, 3.0f);
|
||||
Assert.That(JsonSerializer.Serialize(vector, MiningSerializerContext.Default.Vector3).Replace("\r", null), Is.EqualTo(result));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Vector3Deserialization()
|
||||
{
|
||||
string json = """{ "X": 1.0, "Y": 2.0, "Z": 3.0 }""";
|
||||
Vector3 result = new Vector3(1.0f, 2.0f, 3.0f);
|
||||
Assert.That(JsonSerializer.Deserialize(json, MiningSerializerContext.Default.Vector3), Is.EqualTo(result));
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase("{}")]
|
||||
public void EmptyEngineResourceDataDeserialization(string json)
|
||||
{
|
||||
EngineResourceData result = EngineResourceData.FromJson(json);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result.DefaultResources, Is.Not.Null);
|
||||
Assert.That(result.ExtraResources, Is.Not.Null);
|
||||
});
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result.DefaultResources, Is.Empty);
|
||||
Assert.That(result.ExtraResources, Is.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using AssetRipper.Primitives;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
@@ -32,6 +31,23 @@ public readonly struct AssetDictionary : IReadOnlyCollection<KeyValuePair<Object
|
||||
return _dictionary.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool TryAdd(Object key, PPtr value)
|
||||
{
|
||||
#if NETSTANDARD
|
||||
if (_dictionary.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dictionary.Add(key, value);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return _dictionary.TryAdd(key, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool TryGetValue(Object key, out PPtr value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<Authors>ds5678</Authors>
|
||||
<Company>AssetRipper</Company>
|
||||
<Version>1.2.0</Version>
|
||||
<Version>1.4.0</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<PackageId>AssetRipper.Mining.PredefinedAssets</PackageId>
|
||||
<PackageTags>C# Unity</PackageTags>
|
||||
@@ -26,7 +26,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.Primitives" Version="2.1.1" />
|
||||
<PackageReference Include="AssetRipper.Primitives" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -35,7 +35,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.1" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
public record struct AxisAlignedBoundingBox(Vector3 Center, Vector3 Extent);
|
||||
@@ -1,20 +1,35 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
public readonly record struct EngineResourceData(Dictionary<long, Object> DefaultResources, Dictionary<long, Object> ExtraResources)
|
||||
public readonly record struct EngineResourceData
|
||||
{
|
||||
public EngineResourceData() : this(new(), new())
|
||||
{
|
||||
public Dictionary<long, Object> DefaultResources { get; }
|
||||
public Dictionary<long, Object> ExtraResources { get; }
|
||||
|
||||
public EngineResourceData()
|
||||
{
|
||||
DefaultResources = new();
|
||||
ExtraResources = new();
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public EngineResourceData(Dictionary<long, Object>? defaultResources, Dictionary<long, Object>? extraResources)
|
||||
{
|
||||
DefaultResources = defaultResources ?? new();
|
||||
ExtraResources = extraResources ?? new();
|
||||
}
|
||||
|
||||
public readonly string ToJson()
|
||||
{
|
||||
return JsonSerializer.Serialize(this, InternalSerializerContext.Default.EngineResourceData);
|
||||
return JsonSerializer.Serialize(this, MiningSerializerContext.Default.EngineResourceData);
|
||||
}
|
||||
|
||||
public static EngineResourceData FromJson(string text)
|
||||
{
|
||||
return JsonSerializer.Deserialize(text, InternalSerializerContext.Default.EngineResourceData);
|
||||
return string.IsNullOrEmpty(text)
|
||||
? new()
|
||||
: JsonSerializer.Deserialize(text, MiningSerializerContext.Default.EngineResourceData);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(EngineResourceData))]
|
||||
[JsonSerializable(typeof(UnityPackageData))]
|
||||
internal sealed partial class InternalSerializerContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
@@ -4,15 +4,17 @@ public sealed record class Mesh : NamedObject
|
||||
{
|
||||
public required int VertexCount { get; init; }
|
||||
public required int SubMeshCount { get; init; }
|
||||
public required AxisAlignedBoundingBox LocalAABB { get; init; }
|
||||
|
||||
public Mesh()
|
||||
{
|
||||
}
|
||||
|
||||
[SetsRequiredMembers]
|
||||
public Mesh(string name, int vertexCount, int subMeshCount) : base(name)
|
||||
public Mesh(string name, int vertexCount, int subMeshCount, AxisAlignedBoundingBox localAabb) : base(name)
|
||||
{
|
||||
VertexCount = vertexCount;
|
||||
SubMeshCount = subMeshCount;
|
||||
LocalAABB = localAabb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, IncludeFields = true)]
|
||||
[JsonSerializable(typeof(EngineResourceData))]
|
||||
[JsonSerializable(typeof(UnityPackageData))]
|
||||
[JsonSerializable(typeof(ReferenceAssemblyData))]
|
||||
public sealed partial class MiningSerializerContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
@@ -20,6 +20,6 @@ public sealed record class MonoScript : Object
|
||||
|
||||
public static MonoScript FromType(Type type)
|
||||
{
|
||||
return new MonoScript(type.Assembly.GetName().Name, type.Namespace, type.Name);
|
||||
return new MonoScript(type.Assembly.GetName().Name ?? "", type.Namespace ?? "", type.Name);
|
||||
}
|
||||
}
|
||||
@@ -59,11 +59,11 @@ public abstract record class Object
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonSerializer.Serialize(this, InternalSerializerContext.Default.Object);
|
||||
return JsonSerializer.Serialize(this, MiningSerializerContext.Default.Object);
|
||||
}
|
||||
|
||||
public static Object? FromJson(string text)
|
||||
{
|
||||
return JsonSerializer.Deserialize(text, InternalSerializerContext.Default.Object);
|
||||
return JsonSerializer.Deserialize(text, MiningSerializerContext.Default.Object);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using AssetRipper.Primitives;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
/// <summary>
|
||||
/// A data structure representing a reference to an asset.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
public readonly record struct ReferenceAssemblyData(List<string> Unity, List<string>? Mono2, List<string>? Mono4, List<string>? CoreCLR)
|
||||
{
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonSerializer.Serialize(this, MiningSerializerContext.Default.ReferenceAssemblyData);
|
||||
}
|
||||
|
||||
public static ReferenceAssemblyData FromJson(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<ReferenceAssemblyData>(json, MiningSerializerContext.Default.ReferenceAssemblyData);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using AssetRipper.Primitives;
|
||||
using System.Collections;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace AssetRipper.Mining.PredefinedAssets;
|
||||
|
||||
@@ -32,11 +30,11 @@ public readonly record struct UnityPackageData(
|
||||
|
||||
public readonly string ToJson()
|
||||
{
|
||||
return JsonSerializer.Serialize(this, InternalSerializerContext.Default.UnityPackageData);
|
||||
return JsonSerializer.Serialize(this, MiningSerializerContext.Default.UnityPackageData);
|
||||
}
|
||||
|
||||
public static UnityPackageData FromJson(string text)
|
||||
{
|
||||
return JsonSerializer.Deserialize(text, InternalSerializerContext.Default.UnityPackageData);
|
||||
return JsonSerializer.Deserialize(text, MiningSerializerContext.Default.UnityPackageData);
|
||||
}
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
global using System.Diagnostics.CodeAnalysis;
|
||||
#if NET5_0_OR_GREATER
|
||||
global using UnityGuid = AssetRipper.Primitives.UnityGuid;
|
||||
#else
|
||||
global using UnityGuid = string;
|
||||
#endif
|
||||
+37
-1
@@ -14,7 +14,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Mining.Predefin
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Mining.EngineFileExtractor", "AssetRipper.Mining.EngineFileExtractor\AssetRipper.Mining.EngineFileExtractor.csproj", "{DAD9BA2F-8A03-43D8-A3E5-73493A10AF0B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetRipper.Mining.PredefinedAssets.Tests", "AssetRipper.Mining.PredefinedAssets.Tests\AssetRipper.Mining.PredefinedAssets.Tests.csproj", "{C3E8E9EA-1710-4346-B96A-EA757FB13301}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Mining.PredefinedAssets.Tests", "AssetRipper.Mining.PredefinedAssets.Tests\AssetRipper.Mining.PredefinedAssets.Tests.csproj", "{C3E8E9EA-1710-4346-B96A-EA757FB13301}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Import", "..\AssetRipper\Source\AssetRipper.Import\AssetRipper.Import.csproj", "{44876B0D-F234-46E7-9A94-BE35CA29049F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.SourceGenerated.Extensions", "..\AssetRipper\Source\AssetRipper.SourceGenerated.Extensions\AssetRipper.SourceGenerated.Extensions.csproj", "{B5094214-6FC3-4F55-B448-D83E114BC1BC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Numerics", "..\AssetRipper\Source\AssetRipper.Numerics\AssetRipper.Numerics.csproj", "{BDE02D36-76D0-4A73-A30C-6CD015FA5A99}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.Assets", "..\AssetRipper\Source\AssetRipper.Assets\AssetRipper.Assets.csproj", "{98EE060B-FFE4-4D52-B361-69D42D2C00A4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.IO.Files", "..\AssetRipper\Source\AssetRipper.IO.Files\AssetRipper.IO.Files.csproj", "{6F14FBBA-B839-4023-8C92-138A57F30673}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.SerializationLogic", "..\AssetRipper\Source\AssetRipper.SerializationLogic\AssetRipper.SerializationLogic.csproj", "{A24296F8-A10F-43B5-8190-4406C75882D3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -34,6 +46,30 @@ Global
|
||||
{C3E8E9EA-1710-4346-B96A-EA757FB13301}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3E8E9EA-1710-4346-B96A-EA757FB13301}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3E8E9EA-1710-4346-B96A-EA757FB13301}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{44876B0D-F234-46E7-9A94-BE35CA29049F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{44876B0D-F234-46E7-9A94-BE35CA29049F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{44876B0D-F234-46E7-9A94-BE35CA29049F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{44876B0D-F234-46E7-9A94-BE35CA29049F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B5094214-6FC3-4F55-B448-D83E114BC1BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B5094214-6FC3-4F55-B448-D83E114BC1BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B5094214-6FC3-4F55-B448-D83E114BC1BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B5094214-6FC3-4F55-B448-D83E114BC1BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BDE02D36-76D0-4A73-A30C-6CD015FA5A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDE02D36-76D0-4A73-A30C-6CD015FA5A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDE02D36-76D0-4A73-A30C-6CD015FA5A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDE02D36-76D0-4A73-A30C-6CD015FA5A99}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{98EE060B-FFE4-4D52-B361-69D42D2C00A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{98EE060B-FFE4-4D52-B361-69D42D2C00A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98EE060B-FFE4-4D52-B361-69D42D2C00A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98EE060B-FFE4-4D52-B361-69D42D2C00A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6F14FBBA-B839-4023-8C92-138A57F30673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6F14FBBA-B839-4023-8C92-138A57F30673}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6F14FBBA-B839-4023-8C92-138A57F30673}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6F14FBBA-B839-4023-8C92-138A57F30673}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A24296F8-A10F-43B5-8190-4406C75882D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A24296F8-A10F-43B5-8190-4406C75882D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A24296F8-A10F-43B5-8190-4406C75882D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A24296F8-A10F-43B5-8190-4406C75882D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in new issue
Block a user