Shared => s_shared;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/BrotliRuntimeException.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Unchecked exception used internally.
9 | [System.Serializable]
10 | internal class BrotliRuntimeException : System.Exception
11 | {
12 | internal BrotliRuntimeException(string message)
13 | : base(message)
14 | {
15 | }
16 |
17 | internal BrotliRuntimeException(string message, System.Exception cause)
18 | : base(message, cause)
19 | {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/HuffmanTreeGroup.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Contains a collection of huffman trees with the same alphabet size.
9 | internal sealed class HuffmanTreeGroup
10 | {
11 | /// The maximal alphabet size in this group.
12 | private int alphabetSize;
13 |
14 | /// Storage for Huffman lookup tables.
15 | internal int[] codes;
16 |
17 | ///
18 | /// Offsets of distinct lookup tables in
19 | ///
20 | /// storage.
21 | ///
22 | internal int[] trees;
23 |
24 | /// Initializes the Huffman tree group.
25 | /// POJO to be initialised
26 | /// the maximal alphabet size in this group
27 | /// number of Huffman codes
28 | internal static void Init(Org.Brotli.Dec.HuffmanTreeGroup group, int alphabetSize, int n)
29 | {
30 | group.alphabetSize = alphabetSize;
31 | group.codes = new int[n * Org.Brotli.Dec.Huffman.HuffmanMaxTableSize];
32 | group.trees = new int[n];
33 | }
34 |
35 | /// Decodes Huffman trees from input stream and constructs lookup tables.
36 | /// target POJO
37 | /// data source
38 | internal static void Decode(Org.Brotli.Dec.HuffmanTreeGroup group, Org.Brotli.Dec.BitReader br)
39 | {
40 | int next = 0;
41 | int n = group.trees.Length;
42 | for (int i = 0; i < n; i++)
43 | {
44 | group.trees[i] = next;
45 | Org.Brotli.Dec.Decode.ReadHuffmanCode(group.alphabetSize, group.codes, next, br);
46 | next += Org.Brotli.Dec.Huffman.HuffmanMaxTableSize;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/IntReader.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2017 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Byte-to-int conversion magic.
9 | internal sealed class IntReader
10 | {
11 | private byte[] byteBuffer;
12 |
13 | private int[] intBuffer;
14 |
15 | internal static void Init(Org.Brotli.Dec.IntReader ir, byte[] byteBuffer, int[] intBuffer)
16 | {
17 | ir.byteBuffer = byteBuffer;
18 | ir.intBuffer = intBuffer;
19 | }
20 |
21 | /// Translates bytes to ints.
22 | ///
23 | /// Translates bytes to ints.
24 | /// NB: intLen == 4 * byteSize!
25 | /// NB: intLen should be less or equal to intBuffer length.
26 | ///
27 | internal static void Convert(Org.Brotli.Dec.IntReader ir, int intLen)
28 | {
29 | for (int i = 0; i < intLen; ++i)
30 | {
31 | ir.intBuffer[i] = ((ir.byteBuffer[i * 4] & unchecked((int)(0xFF)))) | ((ir.byteBuffer[(i * 4) + 1] & unchecked((int)(0xFF))) << 8) | ((ir.byteBuffer[(i * 4) + 2] & unchecked((int)(0xFF))) << 16) | ((ir.byteBuffer[(i * 4) + 3] & unchecked((int
32 | )(0xFF))) << 24);
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/Prefix.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Lookup tables to map prefix codes to value ranges.
9 | ///
10 | /// Lookup tables to map prefix codes to value ranges.
11 | /// This is used during decoding of the block lengths, literal insertion lengths and copy
12 | /// lengths.
13 | ///
Range represents values: [offset, offset + 2 ^ n_bits)
14 | ///
15 | internal sealed class Prefix
16 | {
17 | internal static readonly int[] BlockLengthOffset = new int[] { 1, 5, 9, 13, 17, 25, 33, 41, 49, 65, 81, 97, 113, 145, 177, 209, 241, 305, 369, 497, 753, 1265, 2289, 4337, 8433, 16625 };
18 |
19 | internal static readonly int[] BlockLengthNBits = new int[] { 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 24 };
20 |
21 | internal static readonly int[] InsertLengthOffset = new int[] { 0, 1, 2, 3, 4, 5, 6, 8, 10, 14, 18, 26, 34, 50, 66, 98, 130, 194, 322, 578, 1090, 2114, 6210, 22594 };
22 |
23 | internal static readonly int[] InsertLengthNBits = new int[] { 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24 };
24 |
25 | internal static readonly int[] CopyLengthOffset = new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 2118 };
26 |
27 | internal static readonly int[] CopyLengthNBits = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24 };
28 |
29 | internal static readonly int[] InsertRangeLut = new int[] { 0, 0, 8, 8, 0, 16, 8, 16, 16 };
30 |
31 | internal static readonly int[] CopyRangeLut = new int[] { 0, 8, 0, 8, 16, 0, 16, 8, 16 };
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/RunningState.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Enumeration of decoding state-machine.
9 | internal sealed class RunningState
10 | {
11 | internal const int Uninitialized = 0;
12 |
13 | internal const int BlockStart = 1;
14 |
15 | internal const int CompressedBlockStart = 2;
16 |
17 | internal const int MainLoop = 3;
18 |
19 | internal const int ReadMetadata = 4;
20 |
21 | internal const int CopyUncompressed = 5;
22 |
23 | internal const int InsertLoop = 6;
24 |
25 | internal const int CopyLoop = 7;
26 |
27 | internal const int CopyWrapBuffer = 8;
28 |
29 | internal const int Transform = 9;
30 |
31 | internal const int Finished = 10;
32 |
33 | internal const int Closed = 11;
34 |
35 | internal const int Write = 12;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/Utils.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// A set of utility methods.
9 | internal sealed class Utils
10 | {
11 | private static readonly byte[] ByteZeroes = new byte[1024];
12 |
13 | private static readonly int[] IntZeroes = new int[1024];
14 |
15 | /// Fills byte array with zeroes.
16 | ///
17 | /// Fills byte array with zeroes.
18 | /// Current implementation uses
19 | ///
20 | /// , so it should be used for length not
21 | /// less than 16.
22 | ///
23 | /// array to fill with zeroes
24 | /// the first byte to fill
25 | /// number of bytes to change
26 | internal static void FillWithZeroes(byte[] dest, int offset, int length)
27 | {
28 | int cursor = 0;
29 | while (cursor < length)
30 | {
31 | int step = System.Math.Min(cursor + 1024, length) - cursor;
32 | System.Array.Copy(ByteZeroes, 0, dest, offset + cursor, step);
33 | cursor += step;
34 | }
35 | }
36 |
37 | /// Fills int array with zeroes.
38 | ///
39 | /// Fills int array with zeroes.
40 | /// Current implementation uses
41 | ///
42 | /// , so it should be used for length not
43 | /// less than 16.
44 | ///
45 | /// array to fill with zeroes
46 | /// the first item to fill
47 | /// number of item to change
48 | internal static void FillWithZeroes(int[] dest, int offset, int length)
49 | {
50 | int cursor = 0;
51 | while (cursor < length)
52 | {
53 | int step = System.Math.Min(cursor + 1024, length) - cursor;
54 | System.Array.Copy(IntZeroes, 0, dest, offset + cursor, step);
55 | cursor += step;
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/AssetStudio/Brotli/WordTransformType.cs:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 |
3 | Distributed under MIT license.
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 | */
6 | namespace Org.Brotli.Dec
7 | {
8 | /// Enumeration of all possible word transformations.
9 | ///
10 | /// Enumeration of all possible word transformations.
11 | /// There are two simple types of transforms: omit X first/last symbols, two character-case
12 | /// transforms and the identity transform.
13 | ///
14 | internal sealed class WordTransformType
15 | {
16 | internal const int Identity = 0;
17 |
18 | internal const int OmitLast1 = 1;
19 |
20 | internal const int OmitLast2 = 2;
21 |
22 | internal const int OmitLast3 = 3;
23 |
24 | internal const int OmitLast4 = 4;
25 |
26 | internal const int OmitLast5 = 5;
27 |
28 | internal const int OmitLast6 = 6;
29 |
30 | internal const int OmitLast7 = 7;
31 |
32 | internal const int OmitLast8 = 8;
33 |
34 | internal const int OmitLast9 = 9;
35 |
36 | internal const int UppercaseFirst = 10;
37 |
38 | internal const int UppercaseAll = 11;
39 |
40 | internal const int OmitFirst1 = 12;
41 |
42 | internal const int OmitFirst2 = 13;
43 |
44 | internal const int OmitFirst3 = 14;
45 |
46 | internal const int OmitFirst4 = 15;
47 |
48 | internal const int OmitFirst5 = 16;
49 |
50 | internal const int OmitFirst6 = 17;
51 |
52 | internal const int OmitFirst7 = 18;
53 |
54 | internal const int OmitFirst8 = 19;
55 |
56 | internal const int OmitFirst9 = 20;
57 |
58 | internal static int GetOmitFirst(int type)
59 | {
60 | return type >= OmitFirst1 ? (type - OmitFirst1 + 1) : 0;
61 | }
62 |
63 | internal static int GetOmitLast(int type)
64 | {
65 | return type <= OmitLast9 ? (type - OmitLast1 + 1) : 0;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/AssetStudio/BuildTarget.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public enum BuildTarget
9 | {
10 | NoTarget = -2,
11 | AnyPlayer = -1,
12 | ValidPlayer = 1,
13 | StandaloneOSX = 2,
14 | StandaloneOSXPPC = 3,
15 | StandaloneOSXIntel = 4,
16 | StandaloneWindows,
17 | WebPlayer,
18 | WebPlayerStreamed,
19 | Wii = 8,
20 | iOS = 9,
21 | PS3,
22 | XBOX360,
23 | Broadcom = 12,
24 | Android = 13,
25 | StandaloneGLESEmu = 14,
26 | StandaloneGLES20Emu = 15,
27 | NaCl = 16,
28 | StandaloneLinux = 17,
29 | FlashPlayer = 18,
30 | StandaloneWindows64 = 19,
31 | WebGL,
32 | WSAPlayer,
33 | StandaloneLinux64 = 24,
34 | StandaloneLinuxUniversal,
35 | WP8Player,
36 | StandaloneOSXIntel64,
37 | BlackBerry,
38 | Tizen,
39 | PSP2,
40 | PS4,
41 | PSM,
42 | XboxOne,
43 | SamsungTV,
44 | N3DS,
45 | WiiU,
46 | tvOS,
47 | Switch,
48 | Lumin,
49 | Stadia,
50 | CloudRendering,
51 | GameCoreXboxSeries,
52 | GameCoreXboxOne,
53 | PS5,
54 | EmbeddedLinux,
55 | QNX,
56 | UnknownPlatform = 9999
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AssetStudio/BuildType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class BuildType
9 | {
10 | private string buildType;
11 |
12 | public BuildType(string type)
13 | {
14 | buildType = type;
15 | }
16 |
17 | public bool IsAlpha => buildType == "a";
18 | public bool IsPatch => buildType == "p";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Animation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class Animation : Behaviour
9 | {
10 | public PPtr[] m_Animations;
11 |
12 | public Animation(ObjectReader reader) : base(reader)
13 | {
14 | var m_Animation = new PPtr(reader);
15 | int numAnimations = reader.ReadInt32();
16 | m_Animations = new PPtr[numAnimations];
17 | for (int i = 0; i < numAnimations; i++)
18 | {
19 | m_Animations[i] = new PPtr(reader);
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Animator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class Animator : Behaviour
9 | {
10 | public PPtr m_Avatar;
11 | public PPtr m_Controller;
12 | public bool m_HasTransformHierarchy = true;
13 |
14 | public Animator(ObjectReader reader) : base(reader)
15 | {
16 | m_Avatar = new PPtr(reader);
17 | m_Controller = new PPtr(reader);
18 | var m_CullingMode = reader.ReadInt32();
19 |
20 | if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
21 | {
22 | var m_UpdateMode = reader.ReadInt32();
23 | }
24 |
25 | var m_ApplyRootMotion = reader.ReadBoolean();
26 | if (version[0] == 4 && version[1] >= 5) //4.5 and up - 5.0 down
27 | {
28 | reader.AlignStream();
29 | }
30 |
31 | if (version[0] >= 5) //5.0 and up
32 | {
33 | var m_LinearVelocityBlending = reader.ReadBoolean();
34 | if (version[0] > 2021 || (version[0] == 2021 && version[1] >= 2)) //2021.2 and up
35 | {
36 | var m_StabilizeFeet = reader.ReadBoolean();
37 | }
38 | reader.AlignStream();
39 | }
40 |
41 | if (version[0] < 4 || (version[0] == 4 && version[1] < 5)) //4.5 down
42 | {
43 | var m_AnimatePhysics = reader.ReadBoolean();
44 | }
45 |
46 | if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
47 | {
48 | m_HasTransformHierarchy = reader.ReadBoolean();
49 | }
50 |
51 | if (version[0] > 4 || (version[0] == 4 && version[1] >= 5)) //4.5 and up
52 | {
53 | var m_AllowConstantClipSamplingOptimization = reader.ReadBoolean();
54 | }
55 | if (version[0] >= 5 && version[0] < 2018) //5.0 and up - 2018 down
56 | {
57 | reader.AlignStream();
58 | }
59 |
60 | if (version[0] >= 2018) //2018 and up
61 | {
62 | var m_KeepAnimatorControllerStateOnDisable = reader.ReadBoolean();
63 | reader.AlignStream();
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/AnimatorOverrideController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class AnimationClipOverride
9 | {
10 | public PPtr m_OriginalClip;
11 | public PPtr m_OverrideClip;
12 |
13 | public AnimationClipOverride(ObjectReader reader)
14 | {
15 | m_OriginalClip = new PPtr(reader);
16 | m_OverrideClip = new PPtr(reader);
17 | }
18 | }
19 |
20 | public sealed class AnimatorOverrideController : RuntimeAnimatorController
21 | {
22 | public PPtr m_Controller;
23 | public AnimationClipOverride[] m_Clips;
24 |
25 | public AnimatorOverrideController(ObjectReader reader) : base(reader)
26 | {
27 | m_Controller = new PPtr(reader);
28 |
29 | int numOverrides = reader.ReadInt32();
30 | m_Clips = new AnimationClipOverride[numOverrides];
31 | for (int i = 0; i < numOverrides; i++)
32 | {
33 | m_Clips[i] = new AnimationClipOverride(reader);
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/AssetBundle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class AssetInfo
9 | {
10 | public int preloadIndex;
11 | public int preloadSize;
12 | public PPtr asset;
13 |
14 | public AssetInfo(ObjectReader reader)
15 | {
16 | preloadIndex = reader.ReadInt32();
17 | preloadSize = reader.ReadInt32();
18 | asset = new PPtr(reader);
19 | }
20 | }
21 |
22 | public sealed class AssetBundle : NamedObject
23 | {
24 | public PPtr[] m_PreloadTable;
25 | public KeyValuePair[] m_Container;
26 |
27 | public AssetBundle(ObjectReader reader) : base(reader)
28 | {
29 | var m_PreloadTableSize = reader.ReadInt32();
30 | m_PreloadTable = new PPtr[m_PreloadTableSize];
31 | for (int i = 0; i < m_PreloadTableSize; i++)
32 | {
33 | m_PreloadTable[i] = new PPtr(reader);
34 | }
35 |
36 | var m_ContainerSize = reader.ReadInt32();
37 | m_Container = new KeyValuePair[m_ContainerSize];
38 | for (int i = 0; i < m_ContainerSize; i++)
39 | {
40 | m_Container[i] = new KeyValuePair(reader.ReadAlignedString(), new AssetInfo(reader));
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Behaviour.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public abstract class Behaviour : Component
9 | {
10 | public byte m_Enabled;
11 |
12 | protected Behaviour(ObjectReader reader) : base(reader)
13 | {
14 | m_Enabled = reader.ReadByte();
15 | reader.AlignStream();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/BuildSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class BuildSettings : Object
9 | {
10 | public string m_Version;
11 |
12 | public BuildSettings(ObjectReader reader) : base(reader)
13 | {
14 | var levels = reader.ReadStringArray();
15 |
16 | var hasRenderTexture = reader.ReadBoolean();
17 | var hasPROVersion = reader.ReadBoolean();
18 | var hasPublishingRights = reader.ReadBoolean();
19 | var hasShadows = reader.ReadBoolean();
20 |
21 | m_Version = reader.ReadAlignedString();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Component.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public abstract class Component : EditorExtension
9 | {
10 | public PPtr m_GameObject;
11 |
12 | protected Component(ObjectReader reader) : base(reader)
13 | {
14 | m_GameObject = new PPtr(reader);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/EditorExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public abstract class EditorExtension : Object
9 | {
10 | protected EditorExtension(ObjectReader reader) : base(reader)
11 | {
12 | if (platform == BuildTarget.NoTarget)
13 | {
14 | var m_PrefabParentObject = new PPtr(reader);
15 | var m_PrefabInternal = new PPtr(reader); //PPtr
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/GameObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class GameObject : EditorExtension
9 | {
10 | public PPtr[] m_Components;
11 | public string m_Name;
12 |
13 | public Transform m_Transform;
14 | public MeshRenderer m_MeshRenderer;
15 | public MeshFilter m_MeshFilter;
16 | public SkinnedMeshRenderer m_SkinnedMeshRenderer;
17 | public Animator m_Animator;
18 | public Animation m_Animation;
19 |
20 | public GameObject(ObjectReader reader) : base(reader)
21 | {
22 | int m_Component_size = reader.ReadInt32();
23 | m_Components = new PPtr[m_Component_size];
24 | for (int i = 0; i < m_Component_size; i++)
25 | {
26 | if ((version[0] == 5 && version[1] < 5) || version[0] < 5) //5.5 down
27 | {
28 | int first = reader.ReadInt32();
29 | }
30 | m_Components[i] = new PPtr(reader);
31 | }
32 |
33 | var m_Layer = reader.ReadInt32();
34 | m_Name = reader.ReadAlignedString();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/MeshFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class MeshFilter : Component
9 | {
10 | public PPtr m_Mesh;
11 |
12 | public MeshFilter(ObjectReader reader) : base(reader)
13 | {
14 | m_Mesh = new PPtr(reader);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/MeshRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class MeshRenderer : Renderer
9 | {
10 | public MeshRenderer(ObjectReader reader) : base(reader)
11 | {
12 |
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/MonoBehaviour.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class MonoBehaviour : Behaviour
9 | {
10 | public PPtr m_Script;
11 | public string m_Name;
12 |
13 | public MonoBehaviour(ObjectReader reader) : base(reader)
14 | {
15 | m_Script = new PPtr(reader);
16 | m_Name = reader.ReadAlignedString();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/MonoScript.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class MonoScript : NamedObject
9 | {
10 | public string m_ClassName;
11 | public string m_Namespace;
12 | public string m_AssemblyName;
13 |
14 | public MonoScript(ObjectReader reader) : base(reader)
15 | {
16 | if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) //3.4 and up
17 | {
18 | var m_ExecutionOrder = reader.ReadInt32();
19 | }
20 | if (version[0] < 5) //5.0 down
21 | {
22 | var m_PropertiesHash = reader.ReadUInt32();
23 | }
24 | else
25 | {
26 | var m_PropertiesHash = reader.ReadBytes(16);
27 | }
28 | if (version[0] < 3) //3.0 down
29 | {
30 | var m_PathName = reader.ReadAlignedString();
31 | }
32 | m_ClassName = reader.ReadAlignedString();
33 | if (version[0] >= 3) //3.0 and up
34 | {
35 | m_Namespace = reader.ReadAlignedString();
36 | }
37 | m_AssemblyName = reader.ReadAlignedString();
38 | if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down
39 | {
40 | var m_IsEditorScript = reader.ReadBoolean();
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/MovieTexture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class MovieTexture : Texture
9 | {
10 | public byte[] m_MovieData;
11 | public PPtr m_AudioClip;
12 |
13 | public MovieTexture(ObjectReader reader) : base(reader)
14 | {
15 | var m_Loop = reader.ReadBoolean();
16 | reader.AlignStream();
17 | m_AudioClip = new PPtr(reader);
18 | m_MovieData = reader.ReadUInt8Array();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/NamedObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class NamedObject : EditorExtension
9 | {
10 | public string m_Name;
11 |
12 | protected NamedObject(ObjectReader reader) : base(reader)
13 | {
14 | m_Name = reader.ReadAlignedString();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Object.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Specialized;
2 |
3 | namespace AssetStudio
4 | {
5 | public class Object
6 | {
7 | public SerializedFile assetsFile;
8 | public ObjectReader reader;
9 | public long m_PathID;
10 | public int[] version;
11 | protected BuildType buildType;
12 | public BuildTarget platform;
13 | public ClassIDType type;
14 | public SerializedType serializedType;
15 | public uint byteSize;
16 |
17 | public Object(ObjectReader reader)
18 | {
19 | this.reader = reader;
20 | reader.Reset();
21 | assetsFile = reader.assetsFile;
22 | type = reader.type;
23 | m_PathID = reader.m_PathID;
24 | version = reader.version;
25 | buildType = reader.buildType;
26 | platform = reader.platform;
27 | serializedType = reader.serializedType;
28 | byteSize = reader.byteSize;
29 |
30 | if (platform == BuildTarget.NoTarget)
31 | {
32 | var m_ObjectHideFlags = reader.ReadUInt32();
33 | }
34 | }
35 |
36 | public string Dump()
37 | {
38 | if (serializedType?.m_Type != null)
39 | {
40 | return TypeTreeHelper.ReadTypeString(serializedType.m_Type, reader);
41 | }
42 | return null;
43 | }
44 |
45 | public string Dump(TypeTree m_Type)
46 | {
47 | if (m_Type != null)
48 | {
49 | return TypeTreeHelper.ReadTypeString(m_Type, reader);
50 | }
51 | return null;
52 | }
53 |
54 | public OrderedDictionary ToType()
55 | {
56 | if (serializedType?.m_Type != null)
57 | {
58 | return TypeTreeHelper.ReadType(serializedType.m_Type, reader);
59 | }
60 | return null;
61 | }
62 |
63 | public OrderedDictionary ToType(TypeTree m_Type)
64 | {
65 | if (m_Type != null)
66 | {
67 | return TypeTreeHelper.ReadType(m_Type, reader);
68 | }
69 | return null;
70 | }
71 |
72 | public byte[] GetRawData()
73 | {
74 | reader.Reset();
75 | return reader.ReadBytes((int)byteSize);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/PlayerSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class PlayerSettings : Object
9 | {
10 | public string companyName;
11 | public string productName;
12 |
13 | public PlayerSettings(ObjectReader reader) : base(reader)
14 | {
15 | if (version[0] > 5 || (version[0] == 5 && version[1] >= 4)) //5.4.0 nad up
16 | {
17 | var productGUID = reader.ReadBytes(16);
18 | }
19 |
20 | var AndroidProfiler = reader.ReadBoolean();
21 | //bool AndroidFilterTouchesWhenObscured 2017.2 and up
22 | //bool AndroidEnableSustainedPerformanceMode 2018 and up
23 | reader.AlignStream();
24 | int defaultScreenOrientation = reader.ReadInt32();
25 | int targetDevice = reader.ReadInt32();
26 | if (version[0] < 5 || (version[0] == 5 && version[1] < 3)) //5.3 down
27 | {
28 | if (version[0] < 5) //5.0 down
29 | {
30 | int targetPlatform = reader.ReadInt32(); //4.0 and up targetGlesGraphics
31 | if (version[0] > 4 || (version[0] == 4 && version[1] >= 6)) //4.6 and up
32 | {
33 | var targetIOSGraphics = reader.ReadInt32();
34 | }
35 | }
36 | int targetResolution = reader.ReadInt32();
37 | }
38 | else
39 | {
40 | var useOnDemandResources = reader.ReadBoolean();
41 | reader.AlignStream();
42 | }
43 | if (version[0] > 3 || (version[0] == 3 && version[1] >= 5)) //3.5 and up
44 | {
45 | var accelerometerFrequency = reader.ReadInt32();
46 | }
47 | companyName = reader.ReadAlignedString();
48 | productName = reader.ReadAlignedString();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/RectTransform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class RectTransform : Transform
9 | {
10 | public RectTransform(ObjectReader reader) : base(reader)
11 | {
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/ResourceManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AssetStudio
4 | {
5 | public class ResourceManager : Object
6 | {
7 | public KeyValuePair>[] m_Container;
8 |
9 | public ResourceManager(ObjectReader reader) : base(reader)
10 | {
11 | var m_ContainerSize = reader.ReadInt32();
12 | m_Container = new KeyValuePair>[m_ContainerSize];
13 | for (int i = 0; i < m_ContainerSize; i++)
14 | {
15 | m_Container[i] = new KeyValuePair>(reader.ReadAlignedString(), new PPtr(reader));
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/RuntimeAnimatorController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public abstract class RuntimeAnimatorController : NamedObject
9 | {
10 | protected RuntimeAnimatorController(ObjectReader reader) : base(reader)
11 | {
12 |
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/SkinnedMeshRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public sealed class SkinnedMeshRenderer : Renderer
9 | {
10 | public PPtr m_Mesh;
11 | public PPtr[] m_Bones;
12 | public float[] m_BlendShapeWeights;
13 |
14 | public SkinnedMeshRenderer(ObjectReader reader) : base(reader)
15 | {
16 | int m_Quality = reader.ReadInt32();
17 | var m_UpdateWhenOffscreen = reader.ReadBoolean();
18 | var m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below
19 | reader.AlignStream();
20 |
21 | if (version[0] == 2 && version[1] < 6) //2.6 down
22 | {
23 | var m_DisableAnimationWhenOffscreen = new PPtr(reader);
24 | }
25 |
26 | m_Mesh = new PPtr(reader);
27 |
28 | m_Bones = new PPtr[reader.ReadInt32()];
29 | for (int b = 0; b < m_Bones.Length; b++)
30 | {
31 | m_Bones[b] = new PPtr(reader);
32 | }
33 |
34 | if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up
35 | {
36 | m_BlendShapeWeights = reader.ReadSingleArray();
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/SpriteAtlas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace AssetStudio
5 | {
6 | public class SpriteAtlasData
7 | {
8 | public PPtr texture;
9 | public PPtr alphaTexture;
10 | public Rectf textureRect;
11 | public Vector2 textureRectOffset;
12 | public Vector2 atlasRectOffset;
13 | public Vector4 uvTransform;
14 | public float downscaleMultiplier;
15 | public SpriteSettings settingsRaw;
16 | public SecondarySpriteTexture[] secondaryTextures;
17 |
18 | public SpriteAtlasData(ObjectReader reader)
19 | {
20 | var version = reader.version;
21 | texture = new PPtr(reader);
22 | alphaTexture = new PPtr(reader);
23 | textureRect = new Rectf(reader);
24 | textureRectOffset = reader.ReadVector2();
25 | if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
26 | {
27 | atlasRectOffset = reader.ReadVector2();
28 | }
29 | uvTransform = reader.ReadVector4();
30 | downscaleMultiplier = reader.ReadSingle();
31 | settingsRaw = new SpriteSettings(reader);
32 | if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
33 | {
34 | var secondaryTexturesSize = reader.ReadInt32();
35 | secondaryTextures = new SecondarySpriteTexture[secondaryTexturesSize];
36 | for (int i = 0; i < secondaryTexturesSize; i++)
37 | {
38 | secondaryTextures[i] = new SecondarySpriteTexture(reader);
39 | }
40 | reader.AlignStream();
41 | }
42 | }
43 | }
44 |
45 | public sealed class SpriteAtlas : NamedObject
46 | {
47 | public PPtr[] m_PackedSprites;
48 | public Dictionary, SpriteAtlasData> m_RenderDataMap;
49 | public bool m_IsVariant;
50 |
51 | public SpriteAtlas(ObjectReader reader) : base(reader)
52 | {
53 | var m_PackedSpritesSize = reader.ReadInt32();
54 | m_PackedSprites = new PPtr[m_PackedSpritesSize];
55 | for (int i = 0; i < m_PackedSpritesSize; i++)
56 | {
57 | m_PackedSprites[i] = new PPtr(reader);
58 | }
59 |
60 | var m_PackedSpriteNamesToIndex = reader.ReadStringArray();
61 |
62 | var m_RenderDataMapSize = reader.ReadInt32();
63 | m_RenderDataMap = new Dictionary, SpriteAtlasData>(m_RenderDataMapSize);
64 | for (int i = 0; i < m_RenderDataMapSize; i++)
65 | {
66 | var first = new Guid(reader.ReadBytes(16));
67 | var second = reader.ReadInt64();
68 | var value = new SpriteAtlasData(reader);
69 | m_RenderDataMap.Add(new KeyValuePair(first, second), value);
70 | }
71 | var m_Tag = reader.ReadAlignedString();
72 | m_IsVariant = reader.ReadBoolean();
73 | reader.AlignStream();
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/TextAsset.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using System.Text;
6 |
7 | namespace AssetStudio
8 | {
9 | public sealed class TextAsset : NamedObject
10 | {
11 | public byte[] m_Script;
12 |
13 | public TextAsset(ObjectReader reader) : base(reader)
14 | {
15 | m_Script = reader.ReadUInt8Array();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Texture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public abstract class Texture : NamedObject
9 | {
10 | protected Texture(ObjectReader reader) : base(reader)
11 | {
12 | if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up
13 | {
14 | var m_ForcedFallbackFormat = reader.ReadInt32();
15 | var m_DownscaleFallback = reader.ReadBoolean();
16 | if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up
17 | {
18 | var m_IsAlphaChannelOptional = reader.ReadBoolean();
19 | }
20 | reader.AlignStream();
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/Transform.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class Transform : Component
9 | {
10 | public Quaternion m_LocalRotation;
11 | public Vector3 m_LocalPosition;
12 | public Vector3 m_LocalScale;
13 | public PPtr[] m_Children;
14 | public PPtr m_Father;
15 |
16 | public Transform(ObjectReader reader) : base(reader)
17 | {
18 | m_LocalRotation = reader.ReadQuaternion();
19 | m_LocalPosition = reader.ReadVector3();
20 | m_LocalScale = reader.ReadVector3();
21 |
22 | int m_ChildrenCount = reader.ReadInt32();
23 | m_Children = new PPtr[m_ChildrenCount];
24 | for (int i = 0; i < m_ChildrenCount; i++)
25 | {
26 | m_Children[i] = new PPtr(reader);
27 | }
28 | m_Father = new PPtr(reader);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AssetStudio/Classes/VideoClip.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace AssetStudio
4 | {
5 | public class StreamedResource
6 | {
7 | public string m_Source;
8 | public long m_Offset; //ulong
9 | public long m_Size; //ulong
10 |
11 | public StreamedResource(BinaryReader reader)
12 | {
13 | m_Source = reader.ReadAlignedString();
14 | m_Offset = reader.ReadInt64();
15 | m_Size = reader.ReadInt64();
16 | }
17 | }
18 |
19 | public sealed class VideoClip : NamedObject
20 | {
21 | public ResourceReader m_VideoData;
22 | public string m_OriginalPath;
23 | public StreamedResource m_ExternalResources;
24 |
25 | public VideoClip(ObjectReader reader) : base(reader)
26 | {
27 | m_OriginalPath = reader.ReadAlignedString();
28 | var m_ProxyWidth = reader.ReadUInt32();
29 | var m_ProxyHeight = reader.ReadUInt32();
30 | var Width = reader.ReadUInt32();
31 | var Height = reader.ReadUInt32();
32 | if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
33 | {
34 | var m_PixelAspecRatioNum = reader.ReadUInt32();
35 | var m_PixelAspecRatioDen = reader.ReadUInt32();
36 | }
37 | var m_FrameRate = reader.ReadDouble();
38 | var m_FrameCount = reader.ReadUInt64();
39 | var m_Format = reader.ReadInt32();
40 | var m_AudioChannelCount = reader.ReadUInt16Array();
41 | reader.AlignStream();
42 | var m_AudioSampleRate = reader.ReadUInt32Array();
43 | var m_AudioLanguage = reader.ReadStringArray();
44 | if (version[0] >= 2020) //2020.1 and up
45 | {
46 | var m_VideoShadersSize = reader.ReadInt32();
47 | var m_VideoShaders = new PPtr[m_VideoShadersSize];
48 | for (int i = 0; i < m_VideoShadersSize; i++)
49 | {
50 | m_VideoShaders[i] = new PPtr(reader);
51 | }
52 | }
53 | m_ExternalResources = new StreamedResource(reader);
54 | var m_HasSplitAlpha = reader.ReadBoolean();
55 | if (version[0] >= 2020) //2020.1 and up
56 | {
57 | var m_sRGB = reader.ReadBoolean();
58 | }
59 |
60 | ResourceReader resourceReader;
61 | if (!string.IsNullOrEmpty(m_ExternalResources.m_Source))
62 | {
63 | resourceReader = new ResourceReader(m_ExternalResources.m_Source, assetsFile, m_ExternalResources.m_Offset, m_ExternalResources.m_Size);
64 | }
65 | else
66 | {
67 | resourceReader = new ResourceReader(reader, reader.BaseStream.Position, m_ExternalResources.m_Size);
68 | }
69 | m_VideoData = resourceReader;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/AssetStudio/CommonString.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AssetStudio
4 | {
5 | public static class CommonString
6 | {
7 | public static readonly Dictionary StringBuffer = new Dictionary
8 | {
9 | {0, "AABB"},
10 | {5, "AnimationClip"},
11 | {19, "AnimationCurve"},
12 | {34, "AnimationState"},
13 | {49, "Array"},
14 | {55, "Base"},
15 | {60, "BitField"},
16 | {69, "bitset"},
17 | {76, "bool"},
18 | {81, "char"},
19 | {86, "ColorRGBA"},
20 | {96, "Component"},
21 | {106, "data"},
22 | {111, "deque"},
23 | {117, "double"},
24 | {124, "dynamic_array"},
25 | {138, "FastPropertyName"},
26 | {155, "first"},
27 | {161, "float"},
28 | {167, "Font"},
29 | {172, "GameObject"},
30 | {183, "Generic Mono"},
31 | {196, "GradientNEW"},
32 | {208, "GUID"},
33 | {213, "GUIStyle"},
34 | {222, "int"},
35 | {226, "list"},
36 | {231, "long long"},
37 | {241, "map"},
38 | {245, "Matrix4x4f"},
39 | {256, "MdFour"},
40 | {263, "MonoBehaviour"},
41 | {277, "MonoScript"},
42 | {288, "m_ByteSize"},
43 | {299, "m_Curve"},
44 | {307, "m_EditorClassIdentifier"},
45 | {331, "m_EditorHideFlags"},
46 | {349, "m_Enabled"},
47 | {359, "m_ExtensionPtr"},
48 | {374, "m_GameObject"},
49 | {387, "m_Index"},
50 | {395, "m_IsArray"},
51 | {405, "m_IsStatic"},
52 | {416, "m_MetaFlag"},
53 | {427, "m_Name"},
54 | {434, "m_ObjectHideFlags"},
55 | {452, "m_PrefabInternal"},
56 | {469, "m_PrefabParentObject"},
57 | {490, "m_Script"},
58 | {499, "m_StaticEditorFlags"},
59 | {519, "m_Type"},
60 | {526, "m_Version"},
61 | {536, "Object"},
62 | {543, "pair"},
63 | {548, "PPtr"},
64 | {564, "PPtr"},
65 | {581, "PPtr"},
66 | {596, "PPtr"},
67 | {616, "PPtr"},
68 | {633, "PPtr"},
69 | {646, "PPtr"},
70 | {659, "PPtr"},
71 | {672, "PPtr"},
72 | {688, "PPtr"},
73 | {702, "PPtr"},
74 | {718, "PPtr"},
75 | {734, "Prefab"},
76 | {741, "Quaternionf"},
77 | {753, "Rectf"},
78 | {759, "RectInt"},
79 | {767, "RectOffset"},
80 | {778, "second"},
81 | {785, "set"},
82 | {789, "short"},
83 | {795, "size"},
84 | {800, "SInt16"},
85 | {807, "SInt32"},
86 | {814, "SInt64"},
87 | {821, "SInt8"},
88 | {827, "staticvector"},
89 | {840, "string"},
90 | {847, "TextAsset"},
91 | {857, "TextMesh"},
92 | {866, "Texture"},
93 | {874, "Texture2D"},
94 | {884, "Transform"},
95 | {894, "TypelessData"},
96 | {907, "UInt16"},
97 | {914, "UInt32"},
98 | {921, "UInt64"},
99 | {928, "UInt8"},
100 | {934, "unsigned int"},
101 | {947, "unsigned long long"},
102 | {966, "unsigned short"},
103 | {981, "vector"},
104 | {988, "Vector2f"},
105 | {997, "Vector3f"},
106 | {1006, "Vector4f"},
107 | {1015, "m_ScriptingClassIdentifier"},
108 | {1042, "Gradient"},
109 | {1051, "Type*"},
110 | {1057, "int2_storage"},
111 | {1070, "int3_storage"},
112 | {1083, "BoundsInt"},
113 | {1093, "m_CorrespondingSourceObject"},
114 | {1121, "m_PrefabInstance"},
115 | {1138, "m_PrefabAsset"},
116 | {1152, "FileSize"},
117 | {1161, "Hash128"}
118 | };
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/AssetStudio/EndianBinaryReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Buffers.Binary;
3 | using System.IO;
4 |
5 | namespace AssetStudio
6 | {
7 | public class EndianBinaryReader : BinaryReader
8 | {
9 | private readonly byte[] buffer;
10 |
11 | public EndianType Endian;
12 |
13 | public EndianBinaryReader(Stream stream, EndianType endian = EndianType.BigEndian) : base(stream)
14 | {
15 | Endian = endian;
16 | buffer = new byte[8];
17 | }
18 |
19 | public long Position
20 | {
21 | get => BaseStream.Position;
22 | set => BaseStream.Position = value;
23 | }
24 |
25 | public override short ReadInt16()
26 | {
27 | if (Endian == EndianType.BigEndian)
28 | {
29 | Read(buffer, 0, 2);
30 | return BinaryPrimitives.ReadInt16BigEndian(buffer);
31 | }
32 | return base.ReadInt16();
33 | }
34 |
35 | public override int ReadInt32()
36 | {
37 | if (Endian == EndianType.BigEndian)
38 | {
39 | Read(buffer, 0, 4);
40 | return BinaryPrimitives.ReadInt32BigEndian(buffer);
41 | }
42 | return base.ReadInt32();
43 | }
44 |
45 | public override long ReadInt64()
46 | {
47 | if (Endian == EndianType.BigEndian)
48 | {
49 | Read(buffer, 0, 8);
50 | return BinaryPrimitives.ReadInt64BigEndian(buffer);
51 | }
52 | return base.ReadInt64();
53 | }
54 |
55 | public override ushort ReadUInt16()
56 | {
57 | if (Endian == EndianType.BigEndian)
58 | {
59 | Read(buffer, 0, 2);
60 | return BinaryPrimitives.ReadUInt16BigEndian(buffer);
61 | }
62 | return base.ReadUInt16();
63 | }
64 |
65 | public override uint ReadUInt32()
66 | {
67 | if (Endian == EndianType.BigEndian)
68 | {
69 | Read(buffer, 0, 4);
70 | return BinaryPrimitives.ReadUInt32BigEndian(buffer);
71 | }
72 | return base.ReadUInt32();
73 | }
74 |
75 | public override ulong ReadUInt64()
76 | {
77 | if (Endian == EndianType.BigEndian)
78 | {
79 | Read(buffer, 0, 8);
80 | return BinaryPrimitives.ReadUInt64BigEndian(buffer);
81 | }
82 | return base.ReadUInt64();
83 | }
84 |
85 | public override float ReadSingle()
86 | {
87 | if (Endian == EndianType.BigEndian)
88 | {
89 | Read(buffer, 0, 4);
90 | Array.Reverse(buffer, 0, 4);
91 | return BitConverter.ToSingle(buffer, 0);
92 | }
93 | return base.ReadSingle();
94 | }
95 |
96 | public override double ReadDouble()
97 | {
98 | if (Endian == EndianType.BigEndian)
99 | {
100 | Read(buffer, 0, 8);
101 | Array.Reverse(buffer);
102 | return BitConverter.ToDouble(buffer, 0);
103 | }
104 | return base.ReadDouble();
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/AssetStudio/EndianType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AssetStudio
8 | {
9 | public enum EndianType
10 | {
11 | LittleEndian,
12 | BigEndian
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/AssetStudio/Extensions/BinaryWriterExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace AssetStudio
6 | {
7 | public static class BinaryWriterExtensions
8 | {
9 | public static void AlignStream(this BinaryWriter writer, int alignment)
10 | {
11 | var pos = writer.BaseStream.Position;
12 | var mod = pos % alignment;
13 | if (mod != 0)
14 | {
15 | writer.Write(new byte[alignment - mod]);
16 | }
17 | }
18 |
19 | public static void WriteAlignedString(this BinaryWriter writer, string str)
20 | {
21 | var bytes = Encoding.UTF8.GetBytes(str);
22 | writer.Write(bytes.Length);
23 | writer.Write(bytes);
24 | writer.AlignStream(4);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AssetStudio/Extensions/StreamExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace AssetStudio
4 | {
5 | public static class StreamExtensions
6 | {
7 | private const int BufferSize = 81920;
8 |
9 | public static void CopyTo(this Stream source, Stream destination, long size)
10 | {
11 | var buffer = new byte[BufferSize];
12 | for (var left = size; left > 0; left -= BufferSize)
13 | {
14 | int toRead = BufferSize < left ? BufferSize : (int)left;
15 | int read = source.Read(buffer, 0, toRead);
16 | destination.Write(buffer, 0, read);
17 | if (read != toRead)
18 | {
19 | return;
20 | }
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AssetStudio/FileIdentifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class FileIdentifier
9 | {
10 | public Guid guid;
11 | public int type; //enum { kNonAssetType = 0, kDeprecatedCachedAssetType = 1, kSerializedAssetType = 2, kMetaAssetType = 3 };
12 | public string pathName;
13 |
14 | //custom
15 | public string fileName;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudio/FileReader.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Linq;
3 |
4 | namespace AssetStudio
5 | {
6 | public class FileReader : EndianBinaryReader
7 | {
8 | public string FullPath;
9 | public string FileName;
10 | public FileType FileType;
11 |
12 | private static readonly byte[] gzipMagic = { 0x1f, 0x8b };
13 | private static readonly byte[] brotliMagic = { 0x62, 0x72, 0x6F, 0x74, 0x6C, 0x69 };
14 | private static readonly byte[] zipMagic = { 0x50, 0x4B, 0x03, 0x04 };
15 | private static readonly byte[] zipSpannedMagic = { 0x50, 0x4B, 0x07, 0x08 };
16 |
17 | public FileReader(string path) : this(path, File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { }
18 |
19 | public FileReader(string path, Stream stream) : base(stream, EndianType.BigEndian)
20 | {
21 | FullPath = Path.GetFullPath(path);
22 | FileName = Path.GetFileName(path);
23 | FileType = CheckFileType();
24 | }
25 |
26 | private FileType CheckFileType()
27 | {
28 | var signature = this.ReadStringToNull(20);
29 | Position = 0;
30 | switch (signature)
31 | {
32 | case "UnityWeb":
33 | case "UnityRaw":
34 | case "UnityArchive":
35 | case "UnityFS":
36 | return FileType.BundleFile;
37 | case "UnityWebData1.0":
38 | return FileType.WebFile;
39 | default:
40 | {
41 | byte[] magic = ReadBytes(2);
42 | Position = 0;
43 | if (gzipMagic.SequenceEqual(magic))
44 | {
45 | return FileType.GZipFile;
46 | }
47 | Position = 0x20;
48 | magic = ReadBytes(6);
49 | Position = 0;
50 | if (brotliMagic.SequenceEqual(magic))
51 | {
52 | return FileType.BrotliFile;
53 | }
54 | if (IsSerializedFile())
55 | {
56 | return FileType.AssetsFile;
57 | }
58 | magic = ReadBytes(4);
59 | Position = 0;
60 | if (zipMagic.SequenceEqual(magic) || zipSpannedMagic.SequenceEqual(magic))
61 | return FileType.ZipFile;
62 | return FileType.ResourceFile;
63 | }
64 | }
65 | }
66 |
67 | private bool IsSerializedFile()
68 | {
69 | var fileSize = BaseStream.Length;
70 | if (fileSize < 20)
71 | {
72 | return false;
73 | }
74 | var m_MetadataSize = ReadUInt32();
75 | long m_FileSize = ReadUInt32();
76 | var m_Version = ReadUInt32();
77 | long m_DataOffset = ReadUInt32();
78 | var m_Endianess = ReadByte();
79 | var m_Reserved = ReadBytes(3);
80 | if (m_Version >= 22)
81 | {
82 | if (fileSize < 48)
83 | {
84 | Position = 0;
85 | return false;
86 | }
87 | m_MetadataSize = ReadUInt32();
88 | m_FileSize = ReadInt64();
89 | m_DataOffset = ReadInt64();
90 | }
91 | Position = 0;
92 | if (m_FileSize != fileSize)
93 | {
94 | return false;
95 | }
96 | if (m_DataOffset > fileSize)
97 | {
98 | return false;
99 | }
100 | return true;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/AssetStudio/FileType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AssetStudio
8 | {
9 | public enum FileType
10 | {
11 | AssetsFile,
12 | BundleFile,
13 | WebFile,
14 | ResourceFile,
15 | GZipFile,
16 | BrotliFile,
17 | ZipFile
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/AssetStudio/ILogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public enum LoggerEvent
9 | {
10 | Verbose,
11 | Debug,
12 | Info,
13 | Warning,
14 | Error,
15 | }
16 |
17 | public interface ILogger
18 | {
19 | void Log(LoggerEvent loggerEvent, string message);
20 | }
21 |
22 | public sealed class DummyLogger : ILogger
23 | {
24 | public void Log(LoggerEvent loggerEvent, string message) { }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AssetStudio/ImportHelper.cs:
--------------------------------------------------------------------------------
1 | using Org.Brotli.Dec;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using System.Linq;
6 |
7 | namespace AssetStudio
8 | {
9 | public static class ImportHelper
10 | {
11 | public static void MergeSplitAssets(string path, bool allDirectories = false)
12 | {
13 | var splitFiles = Directory.GetFiles(path, "*.split0", allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
14 | foreach (var splitFile in splitFiles)
15 | {
16 | var destFile = Path.GetFileNameWithoutExtension(splitFile);
17 | var destPath = Path.GetDirectoryName(splitFile);
18 | var destFull = Path.Combine(destPath, destFile);
19 | if (!File.Exists(destFull))
20 | {
21 | var splitParts = Directory.GetFiles(destPath, destFile + ".split*");
22 | using (var destStream = File.Create(destFull))
23 | {
24 | for (int i = 0; i < splitParts.Length; i++)
25 | {
26 | var splitPart = destFull + ".split" + i;
27 | using (var sourceStream = File.OpenRead(splitPart))
28 | {
29 | sourceStream.CopyTo(destStream);
30 | }
31 | }
32 | }
33 | }
34 | }
35 | }
36 |
37 | public static string[] ProcessingSplitFiles(List selectFile)
38 | {
39 | var splitFiles = selectFile.Where(x => x.Contains(".split"))
40 | .Select(x => Path.Combine(Path.GetDirectoryName(x), Path.GetFileNameWithoutExtension(x)))
41 | .Distinct()
42 | .ToList();
43 | selectFile.RemoveAll(x => x.Contains(".split"));
44 | foreach (var file in splitFiles)
45 | {
46 | if (File.Exists(file))
47 | {
48 | selectFile.Add(file);
49 | }
50 | }
51 | return selectFile.Distinct().ToArray();
52 | }
53 |
54 | public static FileReader DecompressGZip(FileReader reader)
55 | {
56 | using (reader)
57 | {
58 | var stream = new MemoryStream();
59 | using (var gs = new GZipStream(reader.BaseStream, CompressionMode.Decompress))
60 | {
61 | gs.CopyTo(stream);
62 | }
63 | stream.Position = 0;
64 | return new FileReader(reader.FullPath, stream);
65 | }
66 | }
67 |
68 | public static FileReader DecompressBrotli(FileReader reader)
69 | {
70 | using (reader)
71 | {
72 | var stream = new MemoryStream();
73 | using (var brotliStream = new BrotliInputStream(reader.BaseStream))
74 | {
75 | brotliStream.CopyTo(stream);
76 | }
77 | stream.Position = 0;
78 | return new FileReader(reader.FullPath, stream);
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/AssetStudio/LocalSerializedObjectIdentifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class LocalSerializedObjectIdentifier
9 | {
10 | public int localSerializedFileIndex;
11 | public long localIdentifierInFile;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AssetStudio/Logger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public static class Logger
9 | {
10 | public static ILogger Default = new DummyLogger();
11 |
12 | public static void Verbose(string message) => Default.Log(LoggerEvent.Verbose, message);
13 | public static void Debug(string message) => Default.Log(LoggerEvent.Debug, message);
14 | public static void Info(string message) => Default.Log(LoggerEvent.Info, message);
15 | public static void Warning(string message) => Default.Log(LoggerEvent.Warning, message);
16 | public static void Error(string message) => Default.Log(LoggerEvent.Error, message);
17 |
18 | public static void Error(string message, Exception e)
19 | {
20 | var sb = new StringBuilder();
21 | sb.AppendLine(message);
22 | sb.AppendLine(e.ToString());
23 | Default.Log(LoggerEvent.Error, sb.ToString());
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AssetStudio/Math/Color.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace AssetStudio
5 | {
6 | [StructLayout(LayoutKind.Sequential, Pack = 4)]
7 | public struct Color : IEquatable
8 | {
9 | public float R;
10 | public float G;
11 | public float B;
12 | public float A;
13 |
14 | public Color(float r, float g, float b, float a)
15 | {
16 | R = r;
17 | G = g;
18 | B = b;
19 | A = a;
20 | }
21 |
22 | public override int GetHashCode()
23 | {
24 | return ((Vector4)this).GetHashCode();
25 | }
26 |
27 | public override bool Equals(object other)
28 | {
29 | if (!(other is Color))
30 | return false;
31 | return Equals((Color)other);
32 | }
33 |
34 | public bool Equals(Color other)
35 | {
36 | return R.Equals(other.R) && G.Equals(other.G) && B.Equals(other.B) && A.Equals(other.A);
37 | }
38 |
39 | public static Color operator +(Color a, Color b)
40 | {
41 | return new Color(a.R + b.R, a.G + b.G, a.B + b.B, a.A + b.A);
42 | }
43 |
44 | public static Color operator -(Color a, Color b)
45 | {
46 | return new Color(a.R - b.R, a.G - b.G, a.B - b.B, a.A - b.A);
47 | }
48 |
49 | public static Color operator *(Color a, Color b)
50 | {
51 | return new Color(a.R * b.R, a.G * b.G, a.B * b.B, a.A * b.A);
52 | }
53 |
54 | public static Color operator *(Color a, float b)
55 | {
56 | return new Color(a.R * b, a.G * b, a.B * b, a.A * b);
57 | }
58 |
59 | public static Color operator *(float b, Color a)
60 | {
61 | return new Color(a.R * b, a.G * b, a.B * b, a.A * b);
62 | }
63 |
64 | public static Color operator /(Color a, float b)
65 | {
66 | return new Color(a.R / b, a.G / b, a.B / b, a.A / b);
67 | }
68 |
69 | public static bool operator ==(Color lhs, Color rhs)
70 | {
71 | return (Vector4)lhs == (Vector4)rhs;
72 | }
73 |
74 | public static bool operator !=(Color lhs, Color rhs)
75 | {
76 | return !(lhs == rhs);
77 | }
78 |
79 | public static implicit operator Vector4(Color c)
80 | {
81 | return new Vector4(c.R, c.G, c.B, c.A);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/AssetStudio/Math/Quaternion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace AssetStudio
5 | {
6 | [StructLayout(LayoutKind.Sequential, Pack = 4)]
7 | public struct Quaternion : IEquatable
8 | {
9 | public float X;
10 | public float Y;
11 | public float Z;
12 | public float W;
13 |
14 | public Quaternion(float x, float y, float z, float w)
15 | {
16 | X = x;
17 | Y = y;
18 | Z = z;
19 | W = w;
20 | }
21 |
22 | public float this[int index]
23 | {
24 | get
25 | {
26 | switch (index)
27 | {
28 | case 0: return X;
29 | case 1: return Y;
30 | case 2: return Z;
31 | case 3: return W;
32 | default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Quaternion index!");
33 | }
34 | }
35 |
36 | set
37 | {
38 | switch (index)
39 | {
40 | case 0: X = value; break;
41 | case 1: Y = value; break;
42 | case 2: Z = value; break;
43 | case 3: W = value; break;
44 | default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Quaternion index!");
45 | }
46 | }
47 | }
48 |
49 | public override int GetHashCode()
50 | {
51 | return X.GetHashCode() ^ (Y.GetHashCode() << 2) ^ (Z.GetHashCode() >> 2) ^ (W.GetHashCode() >> 1);
52 | }
53 |
54 | public override bool Equals(object other)
55 | {
56 | if (!(other is Quaternion))
57 | return false;
58 | return Equals((Quaternion)other);
59 | }
60 |
61 | public bool Equals(Quaternion other)
62 | {
63 | return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W);
64 | }
65 |
66 | public static float Dot(Quaternion a, Quaternion b)
67 | {
68 | return a.X * b.X + a.Y * b.Y + a.Z * b.Z + a.W * b.W;
69 | }
70 |
71 | private static bool IsEqualUsingDot(float dot)
72 | {
73 | return dot > 1.0f - kEpsilon;
74 | }
75 |
76 | public static bool operator ==(Quaternion lhs, Quaternion rhs)
77 | {
78 | return IsEqualUsingDot(Dot(lhs, rhs));
79 | }
80 |
81 | public static bool operator !=(Quaternion lhs, Quaternion rhs)
82 | {
83 | return !(lhs == rhs);
84 | }
85 |
86 | private const float kEpsilon = 0.000001F;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/AssetStudio/Math/Vector2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace AssetStudio
5 | {
6 | [StructLayout(LayoutKind.Sequential, Pack = 4)]
7 | public struct Vector2 : IEquatable
8 | {
9 | public float X;
10 | public float Y;
11 |
12 | public Vector2(float x, float y)
13 | {
14 | X = x;
15 | Y = y;
16 | }
17 |
18 | public float this[int index]
19 | {
20 | get
21 | {
22 | switch (index)
23 | {
24 | case 0: return X;
25 | case 1: return Y;
26 | default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector2 index!");
27 | }
28 | }
29 |
30 | set
31 | {
32 | switch (index)
33 | {
34 | case 0: X = value; break;
35 | case 1: Y = value; break;
36 | default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector2 index!");
37 | }
38 | }
39 | }
40 |
41 | public override int GetHashCode()
42 | {
43 | return X.GetHashCode() ^ (Y.GetHashCode() << 2);
44 | }
45 |
46 | public override bool Equals(object other)
47 | {
48 | if (!(other is Vector2))
49 | return false;
50 | return Equals((Vector2)other);
51 | }
52 |
53 | public bool Equals(Vector2 other)
54 | {
55 | return X.Equals(other.X) && Y.Equals(other.Y);
56 | }
57 |
58 | public void Normalize()
59 | {
60 | var length = Length();
61 | if (length > kEpsilon)
62 | {
63 | var invNorm = 1.0f / length;
64 | X *= invNorm;
65 | Y *= invNorm;
66 | }
67 | else
68 | {
69 | X = 0;
70 | Y = 0;
71 | }
72 | }
73 |
74 | public float Length()
75 | {
76 | return (float)Math.Sqrt(LengthSquared());
77 | }
78 |
79 | public float LengthSquared()
80 | {
81 | return X * X + Y * Y;
82 | }
83 |
84 | public static Vector2 Zero => new Vector2();
85 |
86 | public static Vector2 operator +(Vector2 a, Vector2 b)
87 | {
88 | return new Vector2(a.X + b.X, a.Y + b.Y);
89 | }
90 |
91 | public static Vector2 operator -(Vector2 a, Vector2 b)
92 | {
93 | return new Vector2(a.X - b.X, a.Y - b.Y);
94 | }
95 |
96 | public static Vector2 operator *(Vector2 a, Vector2 b)
97 | {
98 | return new Vector2(a.X * b.X, a.Y * b.Y);
99 | }
100 |
101 | public static Vector2 operator /(Vector2 a, Vector2 b)
102 | {
103 | return new Vector2(a.X / b.X, a.Y / b.Y);
104 | }
105 |
106 | public static Vector2 operator -(Vector2 a)
107 | {
108 | return new Vector2(-a.X, -a.Y);
109 | }
110 |
111 | public static Vector2 operator *(Vector2 a, float d)
112 | {
113 | return new Vector2(a.X * d, a.Y * d);
114 | }
115 |
116 | public static Vector2 operator *(float d, Vector2 a)
117 | {
118 | return new Vector2(a.X * d, a.Y * d);
119 | }
120 |
121 | public static Vector2 operator /(Vector2 a, float d)
122 | {
123 | return new Vector2(a.X / d, a.Y / d);
124 | }
125 |
126 | public static bool operator ==(Vector2 lhs, Vector2 rhs)
127 | {
128 | return (lhs - rhs).LengthSquared() < kEpsilon * kEpsilon;
129 | }
130 |
131 | public static bool operator !=(Vector2 lhs, Vector2 rhs)
132 | {
133 | return !(lhs == rhs);
134 | }
135 |
136 | public static implicit operator Vector3(Vector2 v)
137 | {
138 | return new Vector3(v.X, v.Y, 0);
139 | }
140 |
141 | public static implicit operator Vector4(Vector2 v)
142 | {
143 | return new Vector4(v.X, v.Y, 0.0F, 0.0F);
144 | }
145 |
146 | private const float kEpsilon = 0.00001F;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/AssetStudio/ObjectInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class ObjectInfo
9 | {
10 | public long byteStart;
11 | public uint byteSize;
12 | public int typeID;
13 | public int classID;
14 | public ushort isDestroyed;
15 | public byte stripped;
16 |
17 | public long m_PathID;
18 | public SerializedType serializedType;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/AssetStudio/ObjectReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace AssetStudio
8 | {
9 | public class ObjectReader : EndianBinaryReader
10 | {
11 | public SerializedFile assetsFile;
12 | public long m_PathID;
13 | public long byteStart;
14 | public uint byteSize;
15 | public ClassIDType type;
16 | public SerializedType serializedType;
17 | public BuildTarget platform;
18 | public SerializedFileFormatVersion m_Version;
19 |
20 | public int[] version => assetsFile.version;
21 | public BuildType buildType => assetsFile.buildType;
22 |
23 | public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian)
24 | {
25 | this.assetsFile = assetsFile;
26 | m_PathID = objectInfo.m_PathID;
27 | byteStart = objectInfo.byteStart;
28 | byteSize = objectInfo.byteSize;
29 | if (Enum.IsDefined(typeof(ClassIDType), objectInfo.classID))
30 | {
31 | type = (ClassIDType)objectInfo.classID;
32 | }
33 | else
34 | {
35 | type = ClassIDType.UnknownType;
36 | }
37 | serializedType = objectInfo.serializedType;
38 | platform = assetsFile.m_TargetPlatform;
39 | m_Version = assetsFile.header.m_Version;
40 | }
41 |
42 | public void Reset()
43 | {
44 | Position = byteStart;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AssetStudio/Progress.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AssetStudio
4 | {
5 | public static class Progress
6 | {
7 | public static IProgress Default = new Progress();
8 | private static int preValue;
9 |
10 | public static void Reset()
11 | {
12 | preValue = 0;
13 | Default.Report(0);
14 | }
15 |
16 | public static void Report(int current, int total)
17 | {
18 | var value = (int)(current * 100f / total);
19 | Report(value);
20 | }
21 |
22 | private static void Report(int value)
23 | {
24 | if (value > preValue)
25 | {
26 | preValue = value;
27 | Default.Report(value);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AssetStudio/ResourceReader.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace AssetStudio
4 | {
5 | public class ResourceReader
6 | {
7 | private bool needSearch;
8 | private string path;
9 | private SerializedFile assetsFile;
10 | private long offset;
11 | private long size;
12 | private BinaryReader reader;
13 |
14 | public int Size { get => (int)size; }
15 |
16 | public ResourceReader(string path, SerializedFile assetsFile, long offset, long size)
17 | {
18 | needSearch = true;
19 | this.path = path;
20 | this.assetsFile = assetsFile;
21 | this.offset = offset;
22 | this.size = size;
23 | }
24 |
25 | public ResourceReader(BinaryReader reader, long offset, long size)
26 | {
27 | this.reader = reader;
28 | this.offset = offset;
29 | this.size = size;
30 | }
31 |
32 | private BinaryReader GetReader()
33 | {
34 | if (needSearch)
35 | {
36 | var resourceFileName = Path.GetFileName(path);
37 | if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader))
38 | {
39 | needSearch = false;
40 | return reader;
41 | }
42 | var assetsFileDirectory = Path.GetDirectoryName(assetsFile.fullName);
43 | var resourceFilePath = Path.Combine(assetsFileDirectory, resourceFileName);
44 | if (!File.Exists(resourceFilePath))
45 | {
46 | var findFiles = Directory.GetFiles(assetsFileDirectory, resourceFileName, SearchOption.AllDirectories);
47 | if (findFiles.Length > 0)
48 | {
49 | resourceFilePath = findFiles[0];
50 | }
51 | }
52 | if (File.Exists(resourceFilePath))
53 | {
54 | needSearch = false;
55 | reader = new BinaryReader(File.OpenRead(resourceFilePath));
56 | assetsFile.assetsManager.resourceFileReaders.Add(resourceFileName, reader);
57 | return reader;
58 | }
59 | throw new FileNotFoundException($"Can't find the resource file {resourceFileName}");
60 | }
61 | else
62 | {
63 | return reader;
64 | }
65 | }
66 |
67 | public byte[] GetData()
68 | {
69 | var binaryReader = GetReader();
70 | binaryReader.BaseStream.Position = offset;
71 | return binaryReader.ReadBytes((int)size);
72 | }
73 |
74 | public void GetData(byte[] buff)
75 | {
76 | var binaryReader = GetReader();
77 | binaryReader.BaseStream.Position = offset;
78 | binaryReader.Read(buff, 0, (int)size);
79 | }
80 |
81 | public void WriteData(string path)
82 | {
83 | var binaryReader = GetReader();
84 | binaryReader.BaseStream.Position = offset;
85 | using (var writer = File.OpenWrite(path))
86 | {
87 | binaryReader.BaseStream.CopyTo(writer, size);
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/AssetStudio/SerializedFileFormatVersion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AssetStudio
8 | {
9 | public enum SerializedFileFormatVersion
10 | {
11 | Unsupported = 1,
12 | Unknown_2 = 2,
13 | Unknown_3 = 3,
14 | ///
15 | /// 1.2.0 to 2.0.0
16 | ///
17 | Unknown_5 = 5,
18 | ///
19 | /// 2.1.0 to 2.6.1
20 | ///
21 | Unknown_6 = 6,
22 | ///
23 | /// 3.0.0b
24 | ///
25 | Unknown_7 = 7,
26 | ///
27 | /// 3.0.0 to 3.4.2
28 | ///
29 | Unknown_8 = 8,
30 | ///
31 | /// 3.5.0 to 4.7.2
32 | ///
33 | Unknown_9 = 9,
34 | ///
35 | /// 5.0.0aunk1
36 | ///
37 | Unknown_10 = 10,
38 | ///
39 | /// 5.0.0aunk2
40 | ///
41 | HasScriptTypeIndex = 11,
42 | ///
43 | /// 5.0.0aunk3
44 | ///
45 | Unknown_12 = 12,
46 | ///
47 | /// 5.0.0aunk4
48 | ///
49 | HasTypeTreeHashes = 13,
50 | ///
51 | /// 5.0.0unk
52 | ///
53 | Unknown_14 = 14,
54 | ///
55 | /// 5.0.1 to 5.4.0
56 | ///
57 | SupportsStrippedObject = 15,
58 | ///
59 | /// 5.5.0a
60 | ///
61 | RefactoredClassId = 16,
62 | ///
63 | /// 5.5.0unk to 2018.4
64 | ///
65 | RefactorTypeData = 17,
66 | ///
67 | /// 2019.1a
68 | ///
69 | RefactorShareableTypeTreeData = 18,
70 | ///
71 | /// 2019.1unk
72 | ///
73 | TypeTreeNodeWithTypeFlags = 19,
74 | ///
75 | /// 2019.2
76 | ///
77 | SupportsRefObject = 20,
78 | ///
79 | /// 2019.3 to 2019.4
80 | ///
81 | StoresTypeDependencies = 21,
82 | ///
83 | /// 2020.1 to x
84 | ///
85 | LargeFilesSupport = 22
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/AssetStudio/SerializedFileHeader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class SerializedFileHeader
9 | {
10 | public uint m_MetadataSize;
11 | public long m_FileSize;
12 | public SerializedFileFormatVersion m_Version;
13 | public long m_DataOffset;
14 | public byte m_Endianess;
15 | public byte[] m_Reserved;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudio/SerializedType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class SerializedType
9 | {
10 | public int classID;
11 | public bool m_IsStrippedType;
12 | public short m_ScriptTypeIndex = -1;
13 | public TypeTree m_Type;
14 | public byte[] m_ScriptID; //Hash128
15 | public byte[] m_OldTypeHash; //Hash128
16 | public int[] m_TypeDependencies;
17 | public string m_KlassName;
18 | public string m_NameSpace;
19 | public string m_AsmName;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AssetStudio/SevenZipHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using SevenZip.Compression.LZMA;
4 |
5 |
6 | namespace AssetStudio
7 | {
8 | public static class SevenZipHelper
9 | {
10 | public static MemoryStream StreamDecompress(MemoryStream inStream)
11 | {
12 | var decoder = new Decoder();
13 |
14 | inStream.Seek(0, SeekOrigin.Begin);
15 | var newOutStream = new MemoryStream();
16 |
17 | var properties = new byte[5];
18 | if (inStream.Read(properties, 0, 5) != 5)
19 | throw new Exception("input .lzma is too short");
20 | long outSize = 0;
21 | for (var i = 0; i < 8; i++)
22 | {
23 | var v = inStream.ReadByte();
24 | if (v < 0)
25 | throw new Exception("Can't Read 1");
26 | outSize |= ((long)(byte)v) << (8 * i);
27 | }
28 | decoder.SetDecoderProperties(properties);
29 |
30 | var compressedSize = inStream.Length - inStream.Position;
31 | decoder.Code(inStream, newOutStream, compressedSize, outSize, null);
32 |
33 | newOutStream.Position = 0;
34 | return newOutStream;
35 | }
36 |
37 | public static void StreamDecompress(Stream compressedStream, Stream decompressedStream, long compressedSize, long decompressedSize)
38 | {
39 | var basePosition = compressedStream.Position;
40 | var decoder = new Decoder();
41 | var properties = new byte[5];
42 | if (compressedStream.Read(properties, 0, 5) != 5)
43 | throw new Exception("input .lzma is too short");
44 | decoder.SetDecoderProperties(properties);
45 | decoder.Code(compressedStream, decompressedStream, compressedSize - 5, decompressedSize, null);
46 | compressedStream.Position = basePosition + compressedSize;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/AssetStudio/StreamFile.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace AssetStudio
4 | {
5 | public class StreamFile
6 | {
7 | public string path;
8 | public string fileName;
9 | public Stream stream;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AssetStudio/TypeTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AssetStudio
8 | {
9 | public class TypeTree
10 | {
11 | public List m_Nodes;
12 | public byte[] m_StringBuffer;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/AssetStudio/TypeTreeNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace AssetStudio
7 | {
8 | public class TypeTreeNode
9 | {
10 | public string m_Type;
11 | public string m_Name;
12 | public int m_ByteSize;
13 | public int m_Index;
14 | public int m_TypeFlags; //m_IsArray
15 | public int m_Version;
16 | public int m_MetaFlag;
17 | public int m_Level;
18 | public uint m_TypeStrOffset;
19 | public uint m_NameStrOffset;
20 | public ulong m_RefTypeHash;
21 |
22 | public TypeTreeNode() { }
23 |
24 | public TypeTreeNode(string type, string name, int level, bool align)
25 | {
26 | m_Type = type;
27 | m_Name = name;
28 | m_Level = level;
29 | m_MetaFlag = align ? 0x4000 : 0;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/AssetStudio/WebFile.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace AssetStudio
6 | {
7 | public class WebFile
8 | {
9 | public StreamFile[] fileList;
10 |
11 | private class WebData
12 | {
13 | public int dataOffset;
14 | public int dataLength;
15 | public string path;
16 | }
17 |
18 | public WebFile(EndianBinaryReader reader)
19 | {
20 | reader.Endian = EndianType.LittleEndian;
21 | var signature = reader.ReadStringToNull();
22 | var headLength = reader.ReadInt32();
23 | var dataList = new List();
24 | while (reader.BaseStream.Position < headLength)
25 | {
26 | var data = new WebData();
27 | data.dataOffset = reader.ReadInt32();
28 | data.dataLength = reader.ReadInt32();
29 | var pathLength = reader.ReadInt32();
30 | data.path = Encoding.UTF8.GetString(reader.ReadBytes(pathLength));
31 | dataList.Add(data);
32 | }
33 | fileList = new StreamFile[dataList.Count];
34 | for (int i = 0; i < dataList.Count; i++)
35 | {
36 | var data = dataList[i];
37 | var file = new StreamFile();
38 | file.path = data.path;
39 | file.fileName = Path.GetFileName(data.path);
40 | reader.BaseStream.Position = data.dataOffset;
41 | file.stream = new MemoryStream(reader.ReadBytes(data.dataLength));
42 | fileList[i] = file;
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/AssetStudioFBXNative.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "winres.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // Language neutral resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
19 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
20 | #pragma code_page(65001)
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Version
51 | //
52 |
53 | VS_VERSION_INFO VERSIONINFO
54 | FILEVERSION 1,0,0,1
55 | PRODUCTVERSION 1,0,0,1
56 | FILEFLAGSMASK 0x3fL
57 | #ifdef _DEBUG
58 | FILEFLAGS 0x1L
59 | #else
60 | FILEFLAGS 0x0L
61 | #endif
62 | FILEOS 0x40004L
63 | FILETYPE 0x2L
64 | FILESUBTYPE 0x0L
65 | BEGIN
66 | BLOCK "StringFileInfo"
67 | BEGIN
68 | BLOCK "000004b0"
69 | BEGIN
70 | VALUE "FileDescription", "AssetStudioFBXNative"
71 | VALUE "FileVersion", "1.0.0.1"
72 | VALUE "InternalName", "AssetStudioFBXNative.dll"
73 | VALUE "LegalCopyright", "Copyright (C) Perfare 2018-2020; Copyright (C) hozuki 2020"
74 | VALUE "OriginalFilename", "AssetStudioFBXNative.dll"
75 | VALUE "ProductName", "AssetStudioFBXNative"
76 | VALUE "ProductVersion", "1.0.0.1"
77 | END
78 | END
79 | BLOCK "VarFileInfo"
80 | BEGIN
81 | VALUE "Translation", 0x0, 1200
82 | END
83 | END
84 |
85 | #endif // Language neutral resources
86 | /////////////////////////////////////////////////////////////////////////////
87 |
88 |
89 |
90 | #ifndef APSTUDIO_INVOKED
91 | /////////////////////////////////////////////////////////////////////////////
92 | //
93 | // Generated from the TEXTINCLUDE 3 resource.
94 | //
95 |
96 |
97 | /////////////////////////////////////////////////////////////////////////////
98 | #endif // not APSTUDIO_INVOKED
99 |
100 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/AssetStudioFBXNative.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 | 源文件
23 |
24 |
25 | 源文件
26 |
27 |
28 | 源文件
29 |
30 |
31 | 源文件
32 |
33 |
34 | 源文件
35 |
36 |
37 |
38 |
39 | 头文件
40 |
41 |
42 | 头文件
43 |
44 |
45 | 头文件
46 |
47 |
48 | 头文件
49 |
50 |
51 | 头文件
52 |
53 |
54 | 头文件
55 |
56 |
57 | 头文件
58 |
59 |
60 | 头文件
61 |
62 |
63 | 头文件
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | 资源文件
72 |
73 |
74 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_anim_context.cpp:
--------------------------------------------------------------------------------
1 | #include "asfbx_anim_context.h"
2 |
3 | AsFbxAnimContext::AsFbxAnimContext(bool32_t eulerFilter)
4 | : lFilter(nullptr)
5 | {
6 | if (eulerFilter)
7 | {
8 | lFilter = new FbxAnimCurveFilterUnroll();
9 | }
10 |
11 | lAnimStack = nullptr;
12 | lAnimLayer = nullptr;
13 |
14 | lCurveSX = nullptr;
15 | lCurveSY = nullptr;
16 | lCurveSZ = nullptr;
17 | lCurveRX = nullptr;
18 | lCurveRY = nullptr;
19 | lCurveRZ = nullptr;
20 | lCurveTX = nullptr;
21 | lCurveTY = nullptr;
22 | lCurveTZ = nullptr;
23 |
24 | pMesh = nullptr;
25 | lBlendShape = nullptr;
26 | lAnimCurve = nullptr;
27 | }
28 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_anim_context.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #include "bool32_t.h"
6 |
7 | struct AsFbxAnimContext
8 | {
9 |
10 | FbxAnimCurveFilterUnroll* lFilter;
11 |
12 | FbxAnimStack* lAnimStack;
13 | FbxAnimLayer* lAnimLayer;
14 |
15 | FbxAnimCurve* lCurveSX;
16 | FbxAnimCurve* lCurveSY;
17 | FbxAnimCurve* lCurveSZ;
18 | FbxAnimCurve* lCurveRX;
19 | FbxAnimCurve* lCurveRY;
20 | FbxAnimCurve* lCurveRZ;
21 | FbxAnimCurve* lCurveTX;
22 | FbxAnimCurve* lCurveTY;
23 | FbxAnimCurve* lCurveTZ;
24 |
25 | FbxMesh* pMesh;
26 | FbxBlendShape* lBlendShape;
27 | FbxAnimCurve* lAnimCurve;
28 |
29 | AsFbxAnimContext(bool32_t eulerFilter);
30 | ~AsFbxAnimContext() = default;
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_context.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "asfbx_context.h"
4 |
5 | AsFbxContext::AsFbxContext()
6 | {
7 | pSdkManager = nullptr;
8 | pScene = nullptr;
9 | pTextures = nullptr;
10 | pMaterials = nullptr;
11 | pExporter = nullptr;
12 | pBindPose = nullptr;
13 | }
14 |
15 | AsFbxContext::~AsFbxContext()
16 | {
17 | framePaths.clear();
18 |
19 | delete pMaterials;
20 | delete pTextures;
21 |
22 | if (pExporter != nullptr) {
23 | pExporter->Destroy();
24 | }
25 |
26 | if (pScene != nullptr) {
27 | pScene->Destroy();
28 | }
29 |
30 | if (pSdkManager != nullptr) {
31 | pSdkManager->Destroy();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_context.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | struct AsFbxContext
8 | {
9 |
10 | fbxsdk::FbxManager* pSdkManager;
11 | fbxsdk::FbxScene* pScene;
12 | fbxsdk::FbxArray* pTextures;
13 | fbxsdk::FbxArray* pMaterials;
14 | fbxsdk::FbxExporter* pExporter;
15 | fbxsdk::FbxPose* pBindPose;
16 |
17 | std::unordered_set framePaths;
18 |
19 | AsFbxContext();
20 | ~AsFbxContext();
21 | };
22 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_morph_context.cpp:
--------------------------------------------------------------------------------
1 | #include "asfbx_morph_context.h"
2 |
3 | AsFbxMorphContext::AsFbxMorphContext()
4 | {
5 | pMesh = nullptr;
6 | lBlendShape = nullptr;
7 | lBlendShapeChannel = nullptr;
8 | lShape = nullptr;
9 | }
10 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_morph_context.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | struct AsFbxMorphContext
6 | {
7 |
8 | FbxMesh* pMesh;
9 | FbxBlendShape* lBlendShape;
10 | FbxBlendShapeChannel* lBlendShapeChannel;
11 | FbxShape* lShape;
12 |
13 | AsFbxMorphContext();
14 | ~AsFbxMorphContext() = default;
15 |
16 | };
17 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_skin_context.cpp:
--------------------------------------------------------------------------------
1 | #include "asfbx_skin_context.h"
2 | #include "asfbx_context.h"
3 |
4 | AsFbxSkinContext::AsFbxSkinContext(AsFbxContext* pContext, FbxNode* pFrameNode)
5 | : pSkin(nullptr)
6 | {
7 | if (pContext != nullptr && pContext->pScene != nullptr)
8 | {
9 | pSkin = FbxSkin::Create(pContext->pScene, "");
10 | }
11 |
12 | if (pFrameNode != nullptr)
13 | {
14 | lMeshMatrix = pFrameNode->EvaluateGlobalTransform();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/asfbx_skin_context.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | struct AsFbxContext;
6 |
7 | struct AsFbxSkinContext
8 | {
9 |
10 | FbxSkin* pSkin;
11 | FbxAMatrix lMeshMatrix;
12 |
13 | AsFbxSkinContext(AsFbxContext* pContext, FbxNode* pFrameNode);
14 | ~AsFbxSkinContext() = default;
15 |
16 | };
17 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/bool32_t.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | typedef uint32_t bool32_t;
6 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/cpp.hint:
--------------------------------------------------------------------------------
1 | #define AS_API(ret_type)
2 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/dllexport.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #if defined(_MSC_VER)
4 | #if _MSC_VER < 1910 // MSVC 2017-
5 | #error MSVC 2017 or later is required.
6 | #endif
7 | #endif
8 |
9 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__)
10 | #ifdef _AS_DLL
11 | #ifdef __GNUC__
12 | #define _AS_EXPORT __attribute__ ((dllexport))
13 | #else
14 | #define _AS_EXPORT __declspec(dllexport)
15 | #endif
16 | #else
17 | #ifdef __GNUC__
18 | #define _AS_EXPORT __attribute__ ((dllimport))
19 | #else
20 | #define _AS_EXPORT __declspec(dllimport)
21 | #endif
22 | #endif
23 | #define _AS_LOCAL
24 | #else
25 | #if __GNUC__ >= 4
26 | #define _AS_EXPORT __attribute__ ((visibility ("default")))
27 | #define _AS_LOCAL __attribute__ ((visibility ("hidden")))
28 | #else
29 | #define _AS_EXPORT
30 | #define _AS_LOCAL
31 | #endif
32 | #endif
33 |
34 | #ifdef __cplusplus
35 | #ifndef _EXTERN_C_STMT
36 | #define _EXTERN_C_STMT extern "C"
37 | #endif
38 | #else
39 | #ifndef _EXTERN_C_STMT
40 | #define _EXTERN_C_STMT
41 | #endif
42 | #endif
43 |
44 | #ifndef _AS_CALL
45 | #if defined(WIN32) || defined(_WIN32)
46 | #define _AS_CALL __stdcall
47 | #else
48 | #define _AS_CALL /* __cdecl */
49 | #endif
50 | #endif
51 |
52 | #if defined(_MSC_VER)
53 | #define AS_API(ret_type) _EXTERN_C_STMT _AS_EXPORT ret_type _AS_CALL
54 | #else
55 | #define AS_API(ret_type) _EXTERN_C_STMT _AS_EXPORT _AS_CALL ret_type
56 | #endif
57 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioFBXNative/resource.h
--------------------------------------------------------------------------------
/AssetStudioFBXNative/utils.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "utils.h"
5 |
6 | Vector3::Vector3()
7 | : X(0), Y(0), Z(0)
8 | {
9 | }
10 |
11 | Vector3::Vector3(float x, float y, float z)
12 | : X(x), Y(y), Z(z)
13 | {
14 | }
15 |
16 | Quaternion::Quaternion()
17 | : X(0), Y(0), Z(0), W(1)
18 | {
19 | }
20 |
21 | Quaternion::Quaternion(float x, float y, float z)
22 | : X(x), Y(y), Z(z), W(1)
23 | {
24 | }
25 |
26 | Quaternion::Quaternion(float x, float y, float z, float w)
27 | : X(x), Y(y), Z(z), W(w)
28 | {
29 | }
30 |
31 | Vector3 QuaternionToEuler(Quaternion q) {
32 | FbxAMatrix lMatrixRot;
33 | lMatrixRot.SetQ(FbxQuaternion(q.X, q.Y, q.Z, q.W));
34 | FbxVector4 lEuler = lMatrixRot.GetR();
35 | return Vector3((float)lEuler[0], (float)lEuler[1], (float)lEuler[2]);
36 | }
37 |
38 | Quaternion EulerToQuaternion(Vector3 v) {
39 | FbxAMatrix lMatrixRot;
40 | lMatrixRot.SetR(FbxVector4(v.X, v.Y, v.Z));
41 | FbxQuaternion lQuaternion = lMatrixRot.GetQ();
42 | return Quaternion((float)lQuaternion[0], (float)lQuaternion[1], (float)lQuaternion[2], (float)lQuaternion[3]);
43 | }
44 |
--------------------------------------------------------------------------------
/AssetStudioFBXNative/utils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | struct Vector3 {
4 |
5 | float X;
6 | float Y;
7 | float Z;
8 |
9 | Vector3();
10 | Vector3(float x, float y, float z);
11 |
12 | };
13 |
14 | struct Quaternion {
15 |
16 | float X;
17 | float Y;
18 | float Z;
19 | float W;
20 |
21 | Quaternion();
22 | Quaternion(float x, float y, float z);
23 | Quaternion(float x, float y, float z, float w);
24 |
25 | };
26 |
27 | Vector3 QuaternionToEuler(Quaternion q);
28 |
29 | Quaternion EulerToQuaternion(Vector3 v);
30 |
--------------------------------------------------------------------------------
/AssetStudioFBXWrapper/AssetStudioFBXWrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;netstandard2.0;net5.0;net6.0
5 | true
6 | 0.16.0.0
7 | 0.16.0.0
8 | 0.16.0.0
9 | Copyright © Perfare 2018-2022; Copyright © hozuki 2020
10 | embedded
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/AssetStudioFBXWrapper/Fbx.PInvoke.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using AssetStudio.FbxInterop;
3 |
4 | namespace AssetStudio
5 | {
6 | partial class Fbx
7 | {
8 |
9 | [DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Winapi)]
10 | private static extern void AsUtilQuaternionToEuler(float qx, float qy, float qz, float qw, out float vx, out float vy, out float vz);
11 |
12 | [DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Winapi)]
13 | private static extern void AsUtilEulerToQuaternion(float vx, float vy, float vz, out float qx, out float qy, out float qz, out float qw);
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AssetStudioFBXWrapper/Fbx.cs:
--------------------------------------------------------------------------------
1 | using AssetStudio.FbxInterop;
2 | using AssetStudio.PInvoke;
3 | using System.IO;
4 |
5 | namespace AssetStudio
6 | {
7 | public static partial class Fbx
8 | {
9 |
10 | static Fbx()
11 | {
12 | DllLoader.PreloadDll(FbxDll.DllName);
13 | }
14 |
15 | public static Vector3 QuaternionToEuler(Quaternion q)
16 | {
17 | AsUtilQuaternionToEuler(q.X, q.Y, q.Z, q.W, out var x, out var y, out var z);
18 | return new Vector3(x, y, z);
19 | }
20 |
21 | public static Quaternion EulerToQuaternion(Vector3 v)
22 | {
23 | AsUtilEulerToQuaternion(v.X, v.Y, v.Z, out var x, out var y, out var z, out var w);
24 | return new Quaternion(x, y, z, w);
25 | }
26 |
27 | public static class Exporter
28 | {
29 |
30 | public static void Export(string path, IImported imported, bool eulerFilter, float filterPrecision,
31 | bool allNodes, bool skins, bool animation, bool blendShape, bool castToBone, float boneSize, bool exportAllUvsAsDiffuseMaps, float scaleFactor, int versionIndex, bool isAscii)
32 | {
33 | var file = new FileInfo(path);
34 | var dir = file.Directory;
35 |
36 | if (!dir.Exists)
37 | {
38 | dir.Create();
39 | }
40 |
41 | var currentDir = Directory.GetCurrentDirectory();
42 | Directory.SetCurrentDirectory(dir.FullName);
43 |
44 | var name = Path.GetFileName(path);
45 |
46 | using (var exporter = new FbxExporter(name, imported, allNodes, skins, castToBone, boneSize, exportAllUvsAsDiffuseMaps, scaleFactor, versionIndex, isAscii))
47 | {
48 | exporter.Initialize();
49 | exporter.ExportAll(blendShape, animation, eulerFilter, filterPrecision);
50 | }
51 |
52 | Directory.SetCurrentDirectory(currentDir);
53 | }
54 |
55 | }
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AssetStudioFBXWrapper/FbxDll.cs:
--------------------------------------------------------------------------------
1 | namespace AssetStudio.FbxInterop
2 | {
3 | internal static class FbxDll
4 | {
5 |
6 | internal const string DllName = "AssetStudioFBXNative";
7 | internal const string FbxsdkDllName = "libfbxsdk";
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AssetStudioGUI/AssetStudioGUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net472;net5.0-windows;net6.0-windows
6 | true
7 | Resources\as.ico
8 | 0.16.0.0
9 | 0.16.0.0
10 | 0.16.0.0
11 | Copyright © Perfare 2018-2022
12 | embedded
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | SettingsSingleFileGenerator
23 | Settings.Designer.cs
24 |
25 |
26 | True
27 | Settings.settings
28 | True
29 |
30 |
31 |
32 |
33 |
34 | ResXFileCodeGenerator
35 | Resources.Designer.cs
36 |
37 |
38 | True
39 | Resources.resx
40 | True
41 |
42 |
43 |
44 |
45 |
46 | PreserveNewest
47 | x86\fmod.dll
48 |
49 |
50 | PreserveNewest
51 | x64\fmod.dll
52 |
53 |
54 |
55 |
56 |
57 |
58 | Libraries\OpenTK.WinForms.dll
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Components/AssetItem.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using AssetStudio;
3 |
4 | namespace AssetStudioGUI
5 | {
6 | internal class AssetItem : ListViewItem
7 | {
8 | public Object Asset;
9 | public SerializedFile SourceFile;
10 | public string Container = string.Empty;
11 | public string TypeString;
12 | public long m_PathID;
13 | public long FullSize;
14 | public ClassIDType Type;
15 | public string InfoText;
16 | public string UniqueID;
17 | public GameObjectTreeNode TreeNode;
18 |
19 | public AssetItem(Object asset)
20 | {
21 | Asset = asset;
22 | SourceFile = asset.assetsFile;
23 | Type = asset.type;
24 | TypeString = Type.ToString();
25 | m_PathID = asset.m_PathID;
26 | FullSize = asset.byteSize;
27 | }
28 |
29 | public void SetSubItems()
30 | {
31 | SubItems.AddRange(new[]
32 | {
33 | Container, //Container
34 | TypeString, //Type
35 | m_PathID.ToString(), //PathID
36 | FullSize.ToString(), //Size
37 | });
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Components/GOHierarchy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace AssetStudioGUI
8 | {
9 | internal class GOHierarchy : TreeView
10 | {
11 | protected override void WndProc(ref Message m)
12 | {
13 | // Filter WM_LBUTTONDBLCLK
14 | if (m.Msg != 0x203) base.WndProc(ref m);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Components/GameObjectTreeNode.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using AssetStudio;
3 |
4 | namespace AssetStudioGUI
5 | {
6 | internal class GameObjectTreeNode : TreeNode
7 | {
8 | public GameObject gameObject;
9 |
10 | public GameObjectTreeNode(GameObject gameObject)
11 | {
12 | this.gameObject = gameObject;
13 | Text = gameObject.m_Name;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Components/TypeTreeItem.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 | using System.Windows.Forms;
4 | using AssetStudio;
5 |
6 | namespace AssetStudioGUI
7 | {
8 | internal class TypeTreeItem : ListViewItem
9 | {
10 | private TypeTree m_Type;
11 |
12 | public TypeTreeItem(int typeID, TypeTree m_Type)
13 | {
14 | this.m_Type = m_Type;
15 | Text = m_Type.m_Nodes[0].m_Type + " " + m_Type.m_Nodes[0].m_Name;
16 | SubItems.Add(typeID.ToString());
17 | }
18 |
19 | public override string ToString()
20 | {
21 | var sb = new StringBuilder();
22 | foreach (var i in m_Type.m_Nodes)
23 | {
24 | sb.AppendFormat("{0}{1} {2} {3} {4}\r\n", new string('\t', i.m_Level), i.m_Type, i.m_Name, i.m_ByteSize, (i.m_MetaFlag & 0x4000) != 0);
25 | }
26 | return sb.ToString();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/AssetStudioGUI/DirectBitmap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Drawing.Imaging;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace AssetStudioGUI
7 | {
8 | public sealed class DirectBitmap : IDisposable
9 | {
10 | public DirectBitmap(byte[] buff, int width, int height)
11 | {
12 | Width = width;
13 | Height = height;
14 | Bits = buff;
15 | m_handle = GCHandle.Alloc(Bits, GCHandleType.Pinned);
16 | m_bitmap = new Bitmap(Width, Height, Stride, PixelFormat.Format32bppArgb, m_handle.AddrOfPinnedObject());
17 | }
18 |
19 | private void Dispose(bool disposing)
20 | {
21 | if (disposing)
22 | {
23 | m_bitmap.Dispose();
24 | m_handle.Free();
25 | }
26 | m_bitmap = null;
27 | }
28 |
29 | public void Dispose()
30 | {
31 | Dispose(true);
32 | }
33 |
34 | public int Height { get; }
35 | public int Width { get; }
36 | public int Stride => Width * 4;
37 | public byte[] Bits { get; }
38 | public Bitmap Bitmap => m_bitmap;
39 |
40 | private Bitmap m_bitmap;
41 | private readonly GCHandle m_handle;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/AssetStudioGUI/ExportOptions.cs:
--------------------------------------------------------------------------------
1 | using AssetStudio;
2 | using System;
3 | using System.Windows.Forms;
4 |
5 | namespace AssetStudioGUI
6 | {
7 | public partial class ExportOptions : Form
8 | {
9 | public ExportOptions()
10 | {
11 | InitializeComponent();
12 | assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption;
13 | restoreExtensionName.Checked = Properties.Settings.Default.restoreExtensionName;
14 | converttexture.Checked = Properties.Settings.Default.convertTexture;
15 | convertAudio.Checked = Properties.Settings.Default.convertAudio;
16 | var str = Properties.Settings.Default.convertType.ToString();
17 | foreach (Control c in panel1.Controls)
18 | {
19 | if (c.Text == str)
20 | {
21 | ((RadioButton)c).Checked = true;
22 | break;
23 | }
24 | }
25 | openAfterExport.Checked = Properties.Settings.Default.openAfterExport;
26 | eulerFilter.Checked = Properties.Settings.Default.eulerFilter;
27 | filterPrecision.Value = Properties.Settings.Default.filterPrecision;
28 | exportAllNodes.Checked = Properties.Settings.Default.exportAllNodes;
29 | exportSkins.Checked = Properties.Settings.Default.exportSkins;
30 | exportAnimations.Checked = Properties.Settings.Default.exportAnimations;
31 | exportBlendShape.Checked = Properties.Settings.Default.exportBlendShape;
32 | castToBone.Checked = Properties.Settings.Default.castToBone;
33 | exportAllUvsAsDiffuseMaps.Checked = Properties.Settings.Default.exportAllUvsAsDiffuseMaps;
34 | boneSize.Value = Properties.Settings.Default.boneSize;
35 | scaleFactor.Value = Properties.Settings.Default.scaleFactor;
36 | fbxVersion.SelectedIndex = Properties.Settings.Default.fbxVersion;
37 | fbxFormat.SelectedIndex = Properties.Settings.Default.fbxFormat;
38 |
39 | }
40 |
41 | private void OKbutton_Click(object sender, EventArgs e)
42 | {
43 | Properties.Settings.Default.assetGroupOption = assetGroupOptions.SelectedIndex;
44 | Properties.Settings.Default.restoreExtensionName = restoreExtensionName.Checked;
45 | Properties.Settings.Default.convertTexture = converttexture.Checked;
46 | Properties.Settings.Default.convertAudio = convertAudio.Checked;
47 | foreach (Control c in panel1.Controls)
48 | {
49 | if (((RadioButton)c).Checked)
50 | {
51 | Properties.Settings.Default.convertType = (ImageFormat)Enum.Parse(typeof(ImageFormat), c.Text);
52 | break;
53 | }
54 | }
55 | Properties.Settings.Default.openAfterExport = openAfterExport.Checked;
56 | Properties.Settings.Default.eulerFilter = eulerFilter.Checked;
57 | Properties.Settings.Default.filterPrecision = filterPrecision.Value;
58 | Properties.Settings.Default.exportAllNodes = exportAllNodes.Checked;
59 | Properties.Settings.Default.exportSkins = exportSkins.Checked;
60 | Properties.Settings.Default.exportAnimations = exportAnimations.Checked;
61 | Properties.Settings.Default.exportBlendShape = exportBlendShape.Checked;
62 | Properties.Settings.Default.castToBone = castToBone.Checked;
63 | Properties.Settings.Default.exportAllUvsAsDiffuseMaps = exportAllUvsAsDiffuseMaps.Checked;
64 | Properties.Settings.Default.boneSize = boneSize.Value;
65 | Properties.Settings.Default.scaleFactor = scaleFactor.Value;
66 | Properties.Settings.Default.fbxVersion = fbxVersion.SelectedIndex;
67 | Properties.Settings.Default.fbxFormat = fbxFormat.SelectedIndex;
68 | Properties.Settings.Default.Save();
69 | DialogResult = DialogResult.OK;
70 | Close();
71 | }
72 |
73 | private void Cancel_Click(object sender, EventArgs e)
74 | {
75 | DialogResult = DialogResult.Cancel;
76 | Close();
77 | }
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/AssetStudioGUI/GUILogger.cs:
--------------------------------------------------------------------------------
1 | using AssetStudio;
2 | using System;
3 | using System.Windows.Forms;
4 |
5 | namespace AssetStudioGUI
6 | {
7 | class GUILogger : ILogger
8 | {
9 | public bool ShowErrorMessage = true;
10 | private Action action;
11 |
12 | public GUILogger(Action action)
13 | {
14 | this.action = action;
15 | }
16 |
17 | public void Log(LoggerEvent loggerEvent, string message)
18 | {
19 | switch (loggerEvent)
20 | {
21 | case LoggerEvent.Error:
22 | if (ShowErrorMessage)
23 | {
24 | MessageBox.Show(message);
25 | }
26 | break;
27 | default:
28 | action(message);
29 | break;
30 | }
31 |
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Libraries/OpenTK.WinForms.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioGUI/Libraries/OpenTK.WinForms.dll
--------------------------------------------------------------------------------
/AssetStudioGUI/Libraries/x64/fmod.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioGUI/Libraries/x64/fmod.dll
--------------------------------------------------------------------------------
/AssetStudioGUI/Libraries/x86/fmod.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioGUI/Libraries/x86/fmod.dll
--------------------------------------------------------------------------------
/AssetStudioGUI/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace AssetStudioGUI
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | #if !NETFRAMEWORK
18 | Application.SetHighDpiMode(HighDpiMode.SystemAware);
19 | #endif
20 | Application.EnableVisualStyles();
21 | Application.SetCompatibleTextRenderingDefault(false);
22 | Application.Run(new AssetStudioGUIForm());
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 |
8 |
9 | True
10 |
11 |
12 | True
13 |
14 |
15 | True
16 |
17 |
18 | 0
19 |
20 |
21 | True
22 |
23 |
24 | True
25 |
26 |
27 | Png
28 |
29 |
30 | True
31 |
32 |
33 | 0.25
34 |
35 |
36 | True
37 |
38 |
39 | True
40 |
41 |
42 | True
43 |
44 |
45 | 10
46 |
47 |
48 | 3
49 |
50 |
51 | 0
52 |
53 |
54 | 1
55 |
56 |
57 | True
58 |
59 |
60 | False
61 |
62 |
63 | True
64 |
65 |
66 | False
67 |
68 |
69 |
--------------------------------------------------------------------------------
/AssetStudioGUI/Resources/as.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioGUI/Resources/as.ico
--------------------------------------------------------------------------------
/AssetStudioGUI/Resources/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/AssetStudioGUI/Resources/preview.png
--------------------------------------------------------------------------------
/AssetStudioUtility/AssemblyLoader.cs:
--------------------------------------------------------------------------------
1 | using Mono.Cecil;
2 | using System.Collections.Generic;
3 | using System.IO;
4 |
5 | namespace AssetStudio
6 | {
7 | public class AssemblyLoader
8 | {
9 | public bool Loaded;
10 | private Dictionary moduleDic = new Dictionary();
11 |
12 | public void Load(string path)
13 | {
14 | var files = Directory.GetFiles(path, "*.dll");
15 | var resolver = new MyAssemblyResolver();
16 | var readerParameters = new ReaderParameters();
17 | readerParameters.AssemblyResolver = resolver;
18 | foreach (var file in files)
19 | {
20 | try
21 | {
22 | var assembly = AssemblyDefinition.ReadAssembly(file, readerParameters);
23 | resolver.Register(assembly);
24 | moduleDic.Add(assembly.MainModule.Name, assembly.MainModule);
25 | }
26 | catch
27 | {
28 | // ignored
29 | }
30 | }
31 | Loaded = true;
32 | }
33 |
34 | public TypeDefinition GetTypeDefinition(string assemblyName, string fullName)
35 | {
36 | if (moduleDic.TryGetValue(assemblyName, out var module))
37 | {
38 | var typeDef = module.GetType(fullName);
39 | if (typeDef == null && assemblyName == "UnityEngine.dll")
40 | {
41 | foreach (var pair in moduleDic)
42 | {
43 | typeDef = pair.Value.GetType(fullName);
44 | if (typeDef != null)
45 | {
46 | break;
47 | }
48 | }
49 | }
50 | return typeDef;
51 | }
52 | return null;
53 | }
54 |
55 | public void Clear()
56 | {
57 | foreach (var pair in moduleDic)
58 | {
59 | pair.Value.Dispose();
60 | }
61 | moduleDic.Clear();
62 | Loaded = false;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/AssetStudioUtility/AssetStudioUtility.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;netstandard2.0;net5.0;net6.0
5 | 0.16.0.0
6 | 0.16.0.0
7 | 0.16.0.0
8 | Copyright © Perfare 2018-2022
9 | embedded
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/AssetStudioUtility/CSspv/EnumValuesExtensions.cs:
--------------------------------------------------------------------------------
1 | #if NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6
2 | using System;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace SpirV
7 | {
8 | public static class EnumValuesExtensions
9 | {
10 | public static Array GetEnumValues(this System.Type _this)
11 | {
12 | TypeInfo typeInfo = _this.GetTypeInfo ();
13 | if (!typeInfo.IsEnum) {
14 | throw new ArgumentException ("GetEnumValues: Type '" + _this.Name + "' is not an enum");
15 | }
16 |
17 | return
18 | (
19 | from field in typeInfo.DeclaredFields
20 | where field.IsLiteral
21 | select field.GetValue (null)
22 | )
23 | .ToArray();
24 | }
25 |
26 | public static string GetEnumName(this System.Type _this, object value)
27 | {
28 | TypeInfo typeInfo = _this.GetTypeInfo ();
29 | if (!typeInfo.IsEnum) {
30 | throw new ArgumentException ("GetEnumName: Type '" + _this.Name + "' is not an enum");
31 | }
32 | return
33 | (
34 | from field in typeInfo.DeclaredFields
35 | where field.IsLiteral && (uint)field.GetValue(null) == (uint)value
36 | select field.Name
37 | )
38 | .First();
39 | }
40 | }
41 | }
42 | #endif
--------------------------------------------------------------------------------
/AssetStudioUtility/CSspv/Instruction.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SpirV
4 | {
5 | public enum OperandQuantifier
6 | {
7 | ///
8 | /// 1
9 | ///
10 | Default,
11 | ///
12 | /// 0 or 1
13 | ///
14 | Optional,
15 | ///
16 | /// 0+
17 | ///
18 | Varying
19 | }
20 |
21 | public class Operand
22 | {
23 | public Operand(OperandType kind, string name, OperandQuantifier quantifier)
24 | {
25 | Name = name;
26 | Type = kind;
27 | Quantifier = quantifier;
28 | }
29 |
30 | public string Name { get; }
31 | public OperandType Type { get; }
32 | public OperandQuantifier Quantifier { get; }
33 | }
34 |
35 | public class Instruction
36 | {
37 | public Instruction (string name)
38 | : this (name, new List ())
39 | {
40 | }
41 |
42 | public Instruction (string name, IReadOnlyList operands)
43 | {
44 | Operands = operands;
45 | Name = name;
46 | }
47 |
48 | public string Name { get; }
49 | public IReadOnlyList Operands { get; }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/AssetStudioUtility/CSspv/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2017, Matthäus G. Chajdas
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/AssetStudioUtility/CSspv/Reader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.CompilerServices;
4 |
5 | namespace SpirV
6 | {
7 | internal sealed class Reader
8 | {
9 | public Reader(BinaryReader reader)
10 | {
11 | reader_ = reader;
12 | uint magicNumber = reader_.ReadUInt32();
13 | if (magicNumber == Meta.MagicNumber)
14 | {
15 | littleEndian_ = true;
16 | }
17 | else if (Reverse(magicNumber) == Meta.MagicNumber)
18 | {
19 | littleEndian_ = false;
20 | }
21 | else
22 | {
23 | throw new Exception("Invalid magic number");
24 | }
25 | }
26 |
27 | public uint ReadDWord()
28 | {
29 | if (littleEndian_)
30 | {
31 | return reader_.ReadUInt32 ();
32 | }
33 | else
34 | {
35 | return Reverse(reader_.ReadUInt32());
36 | }
37 | }
38 |
39 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
40 | private static uint Reverse(uint u)
41 | {
42 | return (u << 24) | (u & 0xFF00U) << 8 | (u >> 8) & 0xFF00U | (u >> 24);
43 | }
44 |
45 | public bool EndOfStream => reader_.BaseStream.Position == reader_.BaseStream.Length;
46 |
47 | private readonly BinaryReader reader_;
48 | private readonly bool littleEndian_;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AssetStudioUtility/CSspv/SpirV.Meta.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SpirV
4 | {
5 | internal class Meta
6 | {
7 | public class ToolInfo
8 | {
9 | public ToolInfo(string vendor)
10 | {
11 | Vendor = vendor;
12 | }
13 |
14 | public ToolInfo(string vendor, string name)
15 | {
16 | Vendor = vendor;
17 | Name = name;
18 | }
19 |
20 | public string Name { get; }
21 | public string Vendor { get; }
22 | }
23 |
24 | public static uint MagicNumber => 119734787U;
25 | public static uint Version => 66048U;
26 | public static uint Revision => 2U;
27 | public static uint OpCodeMask => 65535U;
28 | public static uint WordCountShift => 16U;
29 |
30 | public static IReadOnlyDictionary Tools => toolInfos_;
31 |
32 | private readonly static Dictionary toolInfos_ = new Dictionary
33 | {
34 | { 0, new ToolInfo("Khronos") },
35 | { 1, new ToolInfo("LunarG") },
36 | { 2, new ToolInfo("Valve") },
37 | { 3, new ToolInfo("Codeplay") },
38 | { 4, new ToolInfo("NVIDIA") },
39 | { 5, new ToolInfo("ARM") },
40 | { 6, new ToolInfo("Khronos", "LLVM/SPIR-V Translator") },
41 | { 7, new ToolInfo("Khronos", "SPIR-V Tools Assembler") },
42 | { 8, new ToolInfo("Khronos", "Glslang Reference Front End") },
43 | { 9, new ToolInfo("Qualcomm") },
44 | { 10, new ToolInfo("AMD") },
45 | { 11, new ToolInfo("Intel") },
46 | { 12, new ToolInfo("Imagination") },
47 | { 13, new ToolInfo("Google", "Shaderc over Glslang") },
48 | { 14, new ToolInfo("Google", "spiregg") },
49 | { 15, new ToolInfo("Google", "rspirv") },
50 | { 16, new ToolInfo("X-LEGEND", "Mesa-IR/SPIR-V Translator") },
51 | { 17, new ToolInfo("Khronos", "SPIR-V Tools Linker") },
52 | };
53 | }
54 | }
--------------------------------------------------------------------------------
/AssetStudioUtility/ImageExtensions.cs:
--------------------------------------------------------------------------------
1 | using SixLabors.ImageSharp;
2 | using SixLabors.ImageSharp.Formats.Bmp;
3 | using SixLabors.ImageSharp.Formats.Tga;
4 | using SixLabors.ImageSharp.PixelFormats;
5 | using System.IO;
6 | using System.Runtime.InteropServices;
7 |
8 | namespace AssetStudio
9 | {
10 | public static class ImageExtensions
11 | {
12 | public static void WriteToStream(this Image image, Stream stream, ImageFormat imageFormat)
13 | {
14 | switch (imageFormat)
15 | {
16 | case ImageFormat.Jpeg:
17 | image.SaveAsJpeg(stream);
18 | break;
19 | case ImageFormat.Png:
20 | image.SaveAsPng(stream);
21 | break;
22 | case ImageFormat.Bmp:
23 | image.Save(stream, new BmpEncoder
24 | {
25 | BitsPerPixel = BmpBitsPerPixel.Pixel32,
26 | SupportTransparency = true
27 | });
28 | break;
29 | case ImageFormat.Tga:
30 | image.Save(stream, new TgaEncoder
31 | {
32 | BitsPerPixel = TgaBitsPerPixel.Pixel32,
33 | Compression = TgaCompression.None
34 | });
35 | break;
36 | }
37 | }
38 |
39 | public static MemoryStream ConvertToStream(this Image image, ImageFormat imageFormat)
40 | {
41 | var stream = new MemoryStream();
42 | image.WriteToStream(stream, imageFormat);
43 | return stream;
44 | }
45 |
46 | public static byte[] ConvertToBytes(this Image image) where TPixel : unmanaged, IPixel
47 | {
48 | if (image.TryGetSinglePixelSpan(out var pixelSpan))
49 | {
50 | return MemoryMarshal.AsBytes(pixelSpan).ToArray();
51 | }
52 | return null;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/AssetStudioUtility/ImageFormat.cs:
--------------------------------------------------------------------------------
1 | namespace AssetStudio
2 | {
3 | public enum ImageFormat
4 | {
5 | Jpeg,
6 | Png,
7 | Bmp,
8 | Tga
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/AssetStudioUtility/ModelExporter.cs:
--------------------------------------------------------------------------------
1 | namespace AssetStudio
2 | {
3 | public static class ModelExporter
4 | {
5 | public static void ExportFbx(string path, IImported imported, bool eulerFilter, float filterPrecision,
6 | bool allNodes, bool skins, bool animation, bool blendShape, bool castToBone, float boneSize, bool exportAllUvsAsDiffuseMaps, float scaleFactor, int versionIndex, bool isAscii)
7 | {
8 | Fbx.Exporter.Export(path, imported, eulerFilter, filterPrecision, allNodes, skins, animation, blendShape, castToBone, boneSize, exportAllUvsAsDiffuseMaps, scaleFactor, versionIndex, isAscii);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AssetStudioUtility/MonoBehaviourConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AssetStudio
4 | {
5 | public static class MonoBehaviourConverter
6 | {
7 | public static TypeTree ConvertToTypeTree(this MonoBehaviour m_MonoBehaviour, AssemblyLoader assemblyLoader)
8 | {
9 | var m_Type = new TypeTree();
10 | m_Type.m_Nodes = new List();
11 | var helper = new SerializedTypeHelper(m_MonoBehaviour.version);
12 | helper.AddMonoBehaviour(m_Type.m_Nodes, 0);
13 | if (m_MonoBehaviour.m_Script.TryGet(out var m_Script))
14 | {
15 | var typeDef = assemblyLoader.GetTypeDefinition(m_Script.m_AssemblyName, string.IsNullOrEmpty(m_Script.m_Namespace) ? m_Script.m_ClassName : $"{m_Script.m_Namespace}.{m_Script.m_ClassName}");
16 | if (typeDef != null)
17 | {
18 | var typeDefinitionConverter = new TypeDefinitionConverter(typeDef, helper, 1);
19 | m_Type.m_Nodes.AddRange(typeDefinitionConverter.ConvertToTypeTreeNodes());
20 | }
21 | }
22 | return m_Type;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/AssetStudioUtility/MyAssemblyResolver.cs:
--------------------------------------------------------------------------------
1 | using Mono.Cecil;
2 |
3 | namespace AssetStudio
4 | {
5 | public class MyAssemblyResolver : DefaultAssemblyResolver
6 | {
7 | public void Register(AssemblyDefinition assembly)
8 | {
9 | RegisterAssembly(assembly);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AssetStudioUtility/SpirVShaderConverter.cs:
--------------------------------------------------------------------------------
1 | using Smolv;
2 | using SpirV;
3 | using System;
4 | using System.IO;
5 | using System.Text;
6 |
7 | namespace AssetStudio
8 | {
9 | public static class SpirVShaderConverter
10 | {
11 | public static string Convert(byte[] m_ProgramCode)
12 | {
13 | var sb = new StringBuilder();
14 | using (var ms = new MemoryStream(m_ProgramCode))
15 | {
16 | using (var reader = new BinaryReader(ms))
17 | {
18 | int requirements = reader.ReadInt32();
19 | int minOffset = m_ProgramCode.Length;
20 | int snippetCount = 5;
21 | /*if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
22 | {
23 | snippetCount = 6;
24 | }*/
25 | for (int i = 0; i < snippetCount; i++)
26 | {
27 | if (reader.BaseStream.Position >= minOffset)
28 | {
29 | break;
30 | }
31 |
32 | int offset = reader.ReadInt32();
33 | int size = reader.ReadInt32();
34 | if (size > 0)
35 | {
36 | if (offset < minOffset)
37 | {
38 | minOffset = offset;
39 | }
40 | var pos = ms.Position;
41 | sb.Append(ExportSnippet(ms, offset, size));
42 | ms.Position = pos;
43 | }
44 | }
45 | }
46 | }
47 | return sb.ToString();
48 | }
49 |
50 | private static string ExportSnippet(Stream stream, int offset, int size)
51 | {
52 | stream.Position = offset;
53 | int decodedSize = SmolvDecoder.GetDecodedBufferSize(stream);
54 | if (decodedSize == 0)
55 | {
56 | throw new Exception("Invalid SMOL-V shader header");
57 | }
58 | using (var decodedStream = new MemoryStream(new byte[decodedSize]))
59 | {
60 | if (SmolvDecoder.Decode(stream, size, decodedStream))
61 | {
62 | decodedStream.Position = 0;
63 | var module = Module.ReadFrom(decodedStream);
64 | var disassembler = new Disassembler();
65 | return disassembler.Disassemble(module, DisassemblyOptions.Default).Replace("\r\n", "\n");
66 | }
67 | else
68 | {
69 | throw new Exception("Unable to decode SMOL-V shader");
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Texture2DExtensions.cs:
--------------------------------------------------------------------------------
1 | using SixLabors.ImageSharp;
2 | using SixLabors.ImageSharp.PixelFormats;
3 | using SixLabors.ImageSharp.Processing;
4 | using System.IO;
5 |
6 | namespace AssetStudio
7 | {
8 | public static class Texture2DExtensions
9 | {
10 | public static Image ConvertToImage(this Texture2D m_Texture2D, bool flip)
11 | {
12 | var converter = new Texture2DConverter(m_Texture2D);
13 | var buff = BigArrayPool.Shared.Rent(m_Texture2D.m_Width * m_Texture2D.m_Height * 4);
14 | try
15 | {
16 | if (converter.DecodeTexture2D(buff))
17 | {
18 | var image = Image.LoadPixelData(buff, m_Texture2D.m_Width, m_Texture2D.m_Height);
19 | if (flip)
20 | {
21 | image.Mutate(x => x.Flip(FlipMode.Vertical));
22 | }
23 | return image;
24 | }
25 | return null;
26 | }
27 | finally
28 | {
29 | BigArrayPool.Shared.Return(buff);
30 | }
31 | }
32 |
33 | public static MemoryStream ConvertToStream(this Texture2D m_Texture2D, ImageFormat imageFormat, bool flip)
34 | {
35 | var image = ConvertToImage(m_Texture2D, flip);
36 | if (image != null)
37 | {
38 | using (image)
39 | {
40 | return image.ConvertToStream(imageFormat);
41 | }
42 | }
43 | return null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/CecilUtils.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using Mono.Cecil;
9 | using Unity.CecilTools.Extensions;
10 |
11 | namespace Unity.CecilTools
12 | {
13 | public static class CecilUtils
14 | {
15 | public static MethodDefinition FindInTypeExplicitImplementationFor(MethodDefinition interfaceMethod, TypeDefinition typeDefinition)
16 | {
17 | return typeDefinition.Methods.SingleOrDefault(m => m.Overrides.Any(o => o.CheckedResolve().SameAs(interfaceMethod)));
18 | }
19 |
20 | public static IEnumerable AllInterfacesImplementedBy(TypeDefinition typeDefinition)
21 | {
22 | return TypeAndBaseTypesOf(typeDefinition).SelectMany(t => t.Interfaces).Select(i => i.InterfaceType.CheckedResolve()).Distinct();
23 | }
24 |
25 | public static IEnumerable TypeAndBaseTypesOf(TypeReference typeReference)
26 | {
27 | while (typeReference != null)
28 | {
29 | var typeDefinition = typeReference.CheckedResolve();
30 | yield return typeDefinition;
31 | typeReference = typeDefinition.BaseType;
32 | }
33 | }
34 |
35 | public static IEnumerable BaseTypesOf(TypeReference typeReference)
36 | {
37 | return TypeAndBaseTypesOf(typeReference).Skip(1);
38 | }
39 |
40 | public static bool IsGenericList(TypeReference type)
41 | {
42 | return type.Name == "List`1" && type.SafeNamespace() == "System.Collections.Generic";
43 | }
44 |
45 | public static bool IsGenericDictionary(TypeReference type)
46 | {
47 | if (type is GenericInstanceType)
48 | type = ((GenericInstanceType)type).ElementType;
49 |
50 | return type.Name == "Dictionary`2" && type.SafeNamespace() == "System.Collections.Generic";
51 | }
52 |
53 | public static TypeReference ElementTypeOfCollection(TypeReference type)
54 | {
55 | var at = type as ArrayType;
56 | if (at != null)
57 | return at.ElementType;
58 |
59 | if (IsGenericList(type))
60 | return ((GenericInstanceType)type).GenericArguments.Single();
61 |
62 | throw new ArgumentException();
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/ElementType.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using System;
6 | using Mono.Cecil;
7 |
8 | namespace Unity.CecilTools
9 | {
10 | static public class ElementType
11 | {
12 | public static TypeReference For(TypeReference byRefType)
13 | {
14 | var refType = byRefType as TypeSpecification;
15 | if (refType != null)
16 | return refType.ElementType;
17 |
18 | throw new ArgumentException(string.Format("TypeReference isn't a TypeSpecification {0} ", byRefType));
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/Extensions/MethodDefinitionExtensions.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using Mono.Cecil;
6 |
7 | namespace Unity.CecilTools.Extensions
8 | {
9 | static class MethodDefinitionExtensions
10 | {
11 | public static bool SameAs(this MethodDefinition self, MethodDefinition other)
12 | {
13 | // FIXME: should be able to compare MethodDefinition references directly
14 | return self.FullName == other.FullName;
15 | }
16 |
17 | public static string PropertyName(this MethodDefinition self)
18 | {
19 | return self.Name.Substring(4);
20 | }
21 |
22 | public static bool IsConversionOperator(this MethodDefinition method)
23 | {
24 | if (!method.IsSpecialName)
25 | return false;
26 |
27 | return method.Name == "op_Implicit" || method.Name == "op_Explicit";
28 | }
29 |
30 | public static bool IsSimpleSetter(this MethodDefinition original)
31 | {
32 | return original.IsSetter && original.Parameters.Count == 1;
33 | }
34 |
35 | public static bool IsSimpleGetter(this MethodDefinition original)
36 | {
37 | return original.IsGetter && original.Parameters.Count == 0;
38 | }
39 |
40 | public static bool IsSimplePropertyAccessor(this MethodDefinition method)
41 | {
42 | return method.IsSimpleGetter() || method.IsSimpleSetter();
43 | }
44 |
45 | public static bool IsDefaultConstructor(MethodDefinition m)
46 | {
47 | return m.IsConstructor && !m.IsStatic && m.Parameters.Count == 0;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/Extensions/ResolutionExtensions.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using System;
6 | using Mono.Cecil;
7 |
8 | namespace Unity.CecilTools.Extensions
9 | {
10 | public static class ResolutionExtensions
11 | {
12 | public static TypeDefinition CheckedResolve(this TypeReference type)
13 | {
14 | return Resolve(type, reference => reference.Resolve());
15 | }
16 |
17 | public static MethodDefinition CheckedResolve(this MethodReference method)
18 | {
19 | return Resolve(method, reference => reference.Resolve());
20 | }
21 |
22 | private static TDefinition Resolve(TReference reference, Func resolve)
23 | where TReference : MemberReference
24 | where TDefinition : class, IMemberDefinition
25 | {
26 | if (reference.Module == null)
27 | throw new ResolutionException(reference);
28 |
29 | var definition = resolve(reference);
30 | if (definition == null)
31 | throw new ResolutionException(reference);
32 |
33 | return definition;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/Extensions/TypeDefinitionExtensions.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using Mono.Cecil;
10 |
11 | namespace Unity.CecilTools.Extensions
12 | {
13 | public static class TypeDefinitionExtensions
14 | {
15 | public static bool IsSubclassOf(this TypeDefinition type, string baseTypeName)
16 | {
17 | var baseType = type.BaseType;
18 | if (baseType == null)
19 | return false;
20 | if (baseType.FullName == baseTypeName)
21 | return true;
22 |
23 | var baseTypeDef = baseType.Resolve();
24 | if (baseTypeDef == null)
25 | return false;
26 |
27 | return IsSubclassOf(baseTypeDef, baseTypeName);
28 | }
29 |
30 | public static bool IsSubclassOf(this TypeDefinition type, params string[] baseTypeNames)
31 | {
32 | var baseType = type.BaseType;
33 | if (baseType == null)
34 | return false;
35 |
36 | for (int i = 0; i < baseTypeNames.Length; i++)
37 | if (baseType.FullName == baseTypeNames[i])
38 | return true;
39 |
40 | var baseTypeDef = baseType.Resolve();
41 | if (baseTypeDef == null)
42 | return false;
43 |
44 | return IsSubclassOf(baseTypeDef, baseTypeNames);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AssetStudioUtility/Unity.CecilTools/Extensions/TypeReferenceExtensions.cs:
--------------------------------------------------------------------------------
1 | // Unity C# reference source
2 | // Copyright (c) Unity Technologies. For terms of use, see
3 | // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4 |
5 | using Mono.Cecil;
6 |
7 | namespace Unity.CecilTools.Extensions
8 | {
9 | public static class TypeReferenceExtensions
10 | {
11 | public static string SafeNamespace(this TypeReference type)
12 | {
13 | if (type.IsGenericInstance)
14 | return ((GenericInstanceType)type).ElementType.SafeNamespace();
15 | if (type.IsNested)
16 | return type.DeclaringType.SafeNamespace();
17 | return type.Namespace;
18 | }
19 |
20 | public static bool IsAssignableTo(this TypeReference typeRef, string typeName)
21 | {
22 | try
23 | {
24 | if (typeRef.IsGenericInstance)
25 | return ElementType.For(typeRef).IsAssignableTo(typeName);
26 |
27 | if (typeRef.FullName == typeName)
28 | return true;
29 |
30 | return typeRef.CheckedResolve().IsSubclassOf(typeName);
31 | }
32 | catch (AssemblyResolutionException) // If we can't resolve our typeref or one of its base types,
33 | { // let's assume it is not assignable to our target type
34 | return false;
35 | }
36 | }
37 |
38 | public static bool IsEnum(this TypeReference type)
39 | {
40 | return type.IsValueType && !type.IsPrimitive && type.CheckedResolve().IsEnum;
41 | }
42 |
43 | public static bool IsStruct(this TypeReference type)
44 | {
45 | return type.IsValueType && !type.IsPrimitive && !type.IsEnum() && !IsSystemDecimal(type);
46 | }
47 |
48 | private static bool IsSystemDecimal(TypeReference type)
49 | {
50 | return type.FullName == "System.Decimal";
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Radu
4 | Copyright (c) 2016-2020 Perfare
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AssetStudio
2 | [](https://ci.appveyor.com/project/Perfare/assetstudio/branch/master/artifacts)
3 |
4 | **None of the repo, the tool, nor the repo owner is affiliated with, or sponsored or authorized by, Unity Technologies or its affiliates.**
5 |
6 | AssetStudio is a tool for exploring, extracting and exporting assets and assetbundles.
7 |
8 | ## Features
9 | * Support version:
10 | * 3.4 - 2022.1
11 | * Support asset types:
12 | * **Texture2D** : convert to png, tga, jpeg, bmp
13 | * **Sprite** : crop Texture2D to png, tga, jpeg, bmp
14 | * **AudioClip** : mp3, ogg, wav, m4a, fsb. support convert FSB file to WAV(PCM)
15 | * **Font** : ttf, otf
16 | * **Mesh** : obj
17 | * **TextAsset**
18 | * **Shader**
19 | * **MovieTexture**
20 | * **VideoClip**
21 | * **MonoBehaviour** : json
22 | * **Animator** : export to FBX file with bound AnimationClip
23 |
24 | ## Requirements
25 |
26 | - AssetStudio.net472
27 | - [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/net472)
28 | - AssetStudio.net5
29 | - [.NET Desktop Runtime 5.0](https://dotnet.microsoft.com/download/dotnet/5.0)
30 | - AssetStudio.net6
31 | - [.NET Desktop Runtime 6.0](https://dotnet.microsoft.com/download/dotnet/6.0)
32 |
33 |
34 | ## Usage
35 |
36 | ### Load Assets/AssetBundles
37 |
38 | Use **File-Load file** or **File-Load folder**.
39 |
40 | When AssetStudio loads AssetBundles, it decompresses and reads it directly in memory, which may cause a large amount of memory to be used. You can use **File-Extract file** or **File-Extract folder** to extract AssetBundles to another folder, and then read.
41 |
42 | ### Extract/Decompress AssetBundles
43 |
44 | Use **File-Extract file** or **File-Extract folder**.
45 |
46 | ### Export Assets
47 |
48 | use **Export** menu.
49 |
50 | ### Export Model
51 |
52 | Export model from "Scene Hierarchy" using the **Model** menu.
53 |
54 | Export Animator from "Asset List" using the **Export** menu.
55 |
56 | #### With AnimationClip
57 |
58 | Select model from "Scene Hierarchy" then select the AnimationClip from "Asset List", using **Model-Export selected objects with AnimationClip** to export.
59 |
60 | Export Animator will export bound AnimationClip or use **Ctrl** to select Animator and AnimationClip from "Asset List", using **Export-Export Animator with selected AnimationClip** to export.
61 |
62 | ### Export MonoBehaviour
63 |
64 | When you select an asset of the MonoBehaviour type for the first time, AssetStudio will ask you the directory where the assembly is located, please select the directory where the assembly is located, such as the `Managed` folder.
65 |
66 | #### For Il2Cpp
67 |
68 | First, use my another program [Il2CppDumper](https://github.com/Perfare/Il2CppDumper) to generate dummy dll, then when using AssetStudio to select the assembly directory, select the dummy dll folder.
69 |
70 | ## Build
71 |
72 | * Visual Studio 2022 or newer
73 | * **AssetStudioFBXNative** uses [FBX SDK 2020.2.1](https://www.autodesk.com/developer-network/platform-technologies/fbx-sdk-2020-2-1), before building, you need to install the FBX SDK and modify the project file, change include directory and library directory to point to the FBX SDK directory
74 |
75 | ## Open source libraries used
76 |
77 | ### Texture2DDecoder
78 | * [Ishotihadus/mikunyan](https://github.com/Ishotihadus/mikunyan)
79 | * [BinomialLLC/crunch](https://github.com/BinomialLLC/crunch)
80 | * [Unity-Technologies/crunch](https://github.com/Unity-Technologies/crunch/tree/unity)
81 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/Texture2DDecoderNative.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "winres.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // Language neutral resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
19 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
20 | #pragma code_page(65001)
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Version
51 | //
52 |
53 | VS_VERSION_INFO VERSIONINFO
54 | FILEVERSION 1,0,0,1
55 | PRODUCTVERSION 1,0,0,1
56 | FILEFLAGSMASK 0x3fL
57 | #ifdef _DEBUG
58 | FILEFLAGS 0x1L
59 | #else
60 | FILEFLAGS 0x0L
61 | #endif
62 | FILEOS 0x40004L
63 | FILETYPE 0x2L
64 | FILESUBTYPE 0x0L
65 | BEGIN
66 | BLOCK "StringFileInfo"
67 | BEGIN
68 | BLOCK "000004b0"
69 | BEGIN
70 | VALUE "FileDescription", "Texture2DDecoderNative"
71 | VALUE "FileVersion", "1.0.0.1"
72 | VALUE "InternalName", "Texture2DDecoderNative.dll"
73 | VALUE "LegalCopyright", "Copyright (C) Perfare 2020; Copyright (C) hozuki 2020"
74 | VALUE "OriginalFilename", "Texture2DDecoderNative.dll"
75 | VALUE "ProductName", "Texture2DDecoderNative"
76 | VALUE "ProductVersion", "1.0.0.1"
77 | END
78 | END
79 | BLOCK "VarFileInfo"
80 | BEGIN
81 | VALUE "Translation", 0x0, 1200
82 | END
83 | END
84 |
85 | #endif // Language neutral resources
86 | /////////////////////////////////////////////////////////////////////////////
87 |
88 |
89 |
90 | #ifndef APSTUDIO_INVOKED
91 | /////////////////////////////////////////////////////////////////////////////
92 | //
93 | // Generated from the TEXTINCLUDE 3 resource.
94 | //
95 |
96 |
97 | /////////////////////////////////////////////////////////////////////////////
98 | #endif // not APSTUDIO_INVOKED
99 |
100 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/Texture2DDecoderNative.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 头文件
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件
50 |
51 |
52 | 头文件
53 |
54 |
55 | 头文件
56 |
57 |
58 | 头文件
59 |
60 |
61 | 头文件
62 |
63 |
64 | 头文件
65 |
66 |
67 | 头文件
68 |
69 |
70 | 头文件
71 |
72 |
73 | 头文件
74 |
75 |
76 | 头文件
77 |
78 |
79 |
80 |
81 | 源文件
82 |
83 |
84 | 源文件
85 |
86 |
87 | 源文件
88 |
89 |
90 | 源文件
91 |
92 |
93 | 源文件
94 |
95 |
96 | 源文件
97 |
98 |
99 | 源文件
100 |
101 |
102 | 源文件
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | 资源文件
111 |
112 |
113 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/astc.h:
--------------------------------------------------------------------------------
1 | #ifndef ASTC_H
2 | #define ASTC_H
3 |
4 | #include
5 |
6 | int decode_astc(const uint8_t *, const long, const long, const int, const int, uint32_t *);
7 |
8 | #endif /* end of include guard: ASTC_H */
9 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/atc.cpp:
--------------------------------------------------------------------------------
1 | #include "bcn.h"
2 | #include "atc.h"
3 | #include "color.h"
4 | #include
5 |
6 | static uint8_t expand_quantized(uint8_t v, int bits) {
7 | v = v << (8 - bits);
8 | return v | (v >> bits);
9 | }
10 |
11 | void decode_atc_block(const uint8_t* _src, uint32_t* _dst)
12 | {
13 | uint8_t colors[4 * 4];
14 |
15 | uint32_t c0 = _src[0] | (_src[1] << 8);
16 | uint32_t c1 = _src[2] | (_src[3] << 8);
17 |
18 | if (0 == (c0 & 0x8000))
19 | {
20 | colors[0] = expand_quantized((c0 >> 0) & 0x1f, 5);
21 | colors[1] = expand_quantized((c0 >> 5) & 0x1f, 5);
22 | colors[2] = expand_quantized((c0 >> 10) & 0x1f, 5);
23 |
24 | colors[12] = expand_quantized((c1 >> 0) & 0x1f, 5);
25 | colors[13] = expand_quantized((c1 >> 5) & 0x3f, 6);
26 | colors[14] = expand_quantized((c1 >> 11) & 0x1f, 5);
27 |
28 | colors[4] = (5 * colors[0] + 3 * colors[12]) / 8;
29 | colors[5] = (5 * colors[1] + 3 * colors[13]) / 8;
30 | colors[6] = (5 * colors[2] + 3 * colors[14]) / 8;
31 |
32 | colors[8] = (3 * colors[0] + 5 * colors[12]) / 8;
33 | colors[9] = (3 * colors[1] + 5 * colors[13]) / 8;
34 | colors[10] = (3 * colors[2] + 5 * colors[14]) / 8;
35 | }
36 | else
37 | {
38 | colors[0] = 0;
39 | colors[1] = 0;
40 | colors[2] = 0;
41 |
42 | colors[8] = expand_quantized((c0 >> 0) & 0x1f, 5);
43 | colors[9] = expand_quantized((c0 >> 5) & 0x1f, 5);
44 | colors[10] = expand_quantized((c0 >> 10) & 0x1f, 5);
45 |
46 | colors[12] = expand_quantized((c1 >> 0) & 0x1f, 5);
47 | colors[13] = expand_quantized((c1 >> 5) & 0x3f, 6);
48 | colors[14] = expand_quantized((c1 >> 11) & 0x1f, 5);
49 |
50 | colors[4] = std::max(0, colors[8] - colors[12] / 4);
51 | colors[5] = std::max(0, colors[9] - colors[13] / 4);
52 | colors[6] = std::max(0, colors[10] - colors[14] / 4);
53 | }
54 |
55 | for (uint32_t i = 0, next = 8 * 4; i < 16; i += 1, next += 2)
56 | {
57 | int32_t idx = ((_src[next >> 3] >> (next & 7)) & 3) * 4;
58 | _dst[i] = color(colors[idx + 2], colors[idx + 1], colors[idx + 0], 255);
59 | }
60 | }
61 |
62 | int decode_atc_rgb4(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image) {
63 | uint32_t m_block_width = 4;
64 | uint32_t m_block_height = 4;
65 | uint32_t m_blocks_x = (m_width + m_block_width - 1) / m_block_width;
66 | uint32_t m_blocks_y = (m_height + m_block_height - 1) / m_block_height;
67 | uint32_t buffer[16];
68 | for (uint32_t by = 0; by < m_blocks_y; by++) {
69 | for (uint32_t bx = 0; bx < m_blocks_x; bx++, data += 8) {
70 | decode_atc_block(data, buffer);
71 | copy_block_buffer(bx, by, m_width, m_height, m_block_width, m_block_height, buffer, image);
72 | }
73 | }
74 | return 1;
75 | }
76 |
77 | int decode_atc_rgba8(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image) {
78 | uint32_t m_block_width = 4;
79 | uint32_t m_block_height = 4;
80 | uint32_t m_blocks_x = (m_width + m_block_width - 1) / m_block_width;
81 | uint32_t m_blocks_y = (m_height + m_block_height - 1) / m_block_height;
82 | uint32_t buffer[16];
83 | for (uint32_t by = 0; by < m_blocks_y; by++) {
84 | for (uint32_t bx = 0; bx < m_blocks_x; bx++, data += 16) {
85 | decode_atc_block(data + 8, buffer);
86 | decode_bc3_alpha(data, buffer, 3);
87 | copy_block_buffer(bx, by, m_width, m_height, m_block_width, m_block_height, buffer, image);
88 | }
89 | }
90 | return 1;
91 | }
--------------------------------------------------------------------------------
/Texture2DDecoderNative/atc.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | int decode_atc_rgb4(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
5 | int decode_atc_rgba8(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
--------------------------------------------------------------------------------
/Texture2DDecoderNative/bcn.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | struct color_bgra
5 | {
6 | uint8_t b;
7 | uint8_t g;
8 | uint8_t r;
9 | uint8_t a;
10 | };
11 |
12 | const color_bgra g_black_color{ 0, 0, 0, 255 };
13 |
14 | int decode_bc1(const uint8_t* data, const long w, const long h, uint32_t* image);
15 | void decode_bc3_alpha(const uint8_t* data, uint32_t* outbuf, int channel);
16 | int decode_bc3(const uint8_t* data, const long w, const long h, uint32_t* image);
17 | int decode_bc4(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
18 | int decode_bc5(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
19 | int decode_bc6(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
20 | int decode_bc7(const uint8_t* data, uint32_t m_width, uint32_t m_height, uint32_t* image);
--------------------------------------------------------------------------------
/Texture2DDecoderNative/bool32_t.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | typedef uint32_t bool32_t;
6 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/color.h:
--------------------------------------------------------------------------------
1 | #ifndef COLOR_H
2 | #define COLOR_H
3 |
4 | #include
5 | #include
6 | #include "endianness.h"
7 |
8 | #ifdef __LITTLE_ENDIAN__
9 | static const uint_fast32_t TRANSPARENT_MASK = 0x00ffffff;
10 | #else
11 | static const uint_fast32_t TRANSPARENT_MASK = 0xffffff00;
12 | #endif
13 |
14 | static inline uint_fast32_t color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
15 | #ifdef __LITTLE_ENDIAN__
16 | return b | g << 8 | r << 16 | a << 24;
17 | #else
18 | return a | r << 8 | g << 16 | b << 24;
19 | #endif
20 | }
21 |
22 | static inline uint_fast32_t alpha_mask(uint8_t a) {
23 | #ifdef __LITTLE_ENDIAN__
24 | return TRANSPARENT_MASK | a << 24;
25 | #else
26 | return TRANSPARENT_MASK | a;
27 | #endif
28 | }
29 |
30 | static inline void rgb565_le(const uint16_t d, uint8_t *r, uint8_t *g, uint8_t *b) {
31 | #ifdef __LITTLE_ENDIAN__
32 | *r = (d >> 8 & 0xf8) | (d >> 13);
33 | *g = (d >> 3 & 0xfc) | (d >> 9 & 3);
34 | *b = (d << 3) | (d >> 2 & 7);
35 | #else
36 | *r = (d & 0xf8) | (d >> 5 & 7);
37 | *g = (d << 5 & 0xe0) | (d >> 11 & 0x1c) | (d >> 1 & 3);
38 | *b = (d >> 5 & 0xf8) | (d >> 10 & 0x7);
39 | #endif
40 | }
41 |
42 | static inline void rgb565_be(const uint16_t d, uint8_t *r, uint8_t *g, uint8_t *b) {
43 | #ifdef __BIG_ENDIAN__
44 | *r = (d >> 8 & 0xf8) | (d >> 13);
45 | *g = (d >> 3 & 0xfc) | (d >> 9 & 3);
46 | *b = (d << 3) | (d >> 2 & 7);
47 | #else
48 | *r = (d & 0xf8) | (d >> 5 & 7);
49 | *g = (d << 5 & 0xe0) | (d >> 11 & 0x1c) | (d >> 1 & 3);
50 | *b = (d >> 5 & 0xf8) | (d >> 10 & 0x7);
51 | #endif
52 | }
53 |
54 | static inline void rgb565_lep(const uint16_t d, uint8_t *c) {
55 | #ifdef __LITTLE_ENDIAN__
56 | *(c++) = (d >> 8 & 0xf8) | (d >> 13);
57 | *(c++) = (d >> 3 & 0xfc) | (d >> 9 & 3);
58 | *(c++) = (d << 3) | (d >> 2 & 7);
59 | #else
60 | *(c++) = (d & 0xf8) | (d >> 5 & 7);
61 | *(c++) = (d << 5 & 0xe0) | (d >> 11 & 0x1c) | (d >> 1 & 3);
62 | *(c++) = (d >> 5 & 0xf8) | (d >> 10 & 0x7);
63 | #endif
64 | }
65 |
66 | static inline void rgb565_bep(const uint16_t d, uint8_t *c) {
67 | #ifdef __BIG_ENDIAN__
68 | *(c++) = (d >> 8 & 0xf8) | (d >> 13);
69 | *(c++) = (d >> 3 & 0xfc) | (d >> 9 & 3);
70 | *(c++) = (d << 3) | (d >> 2 & 7);
71 | #else
72 | *(c++) = (d & 0xf8) | (d >> 5 & 7);
73 | *(c++) = (d << 5 & 0xe0) | (d >> 11 & 0x1c) | (d >> 1 & 3);
74 | *(c++) = (d >> 5 & 0xf8) | (d >> 10 & 0x7);
75 | #endif
76 | }
77 |
78 | static inline void copy_block_buffer(const long bx, const long by, const long w, const long h, const long bw,
79 | const long bh, const uint32_t *buffer, uint32_t *image) {
80 | long x = bw * bx;
81 | long xl = (bw * (bx + 1) > w ? w - bw * bx : bw) * 4;
82 | const uint32_t *buffer_end = buffer + bw * bh;
83 | for (long y = by * bh; buffer < buffer_end && y < h; buffer += bw, y++)
84 | memcpy(image + y * w + x, buffer, xl);
85 | }
86 |
87 | #endif /* end of include guard: COLOR_H */
88 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/cpp.hint:
--------------------------------------------------------------------------------
1 | #define T2D_API(ret_type)
2 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/crunch.cpp:
--------------------------------------------------------------------------------
1 | #include "crunch.h"
2 | #include
3 | #include
4 | #include "crunch/crn_decomp.h"
5 |
6 | bool crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t level_index, void** ret, uint32_t* ret_size) {
7 | crnd::crn_texture_info tex_info;
8 | if (!crnd::crnd_get_texture_info(data, data_size, &tex_info))
9 | {
10 | return false;
11 | }
12 |
13 | crnd::crnd_unpack_context pContext = crnd::crnd_unpack_begin(data, data_size);
14 | if (!pContext)
15 | {
16 | return false;
17 | }
18 |
19 | const crn_uint32 width = std::max(1U, tex_info.m_width >> level_index);
20 | const crn_uint32 height = std::max(1U, tex_info.m_height >> level_index);
21 | const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
22 | const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
23 | const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
24 | const crn_uint32 total_face_size = row_pitch * blocks_y;
25 | *ret = new uint8_t[total_face_size];
26 | *ret_size = total_face_size;
27 | if (!crnd::crnd_unpack_level(pContext, ret, total_face_size, row_pitch, level_index))
28 | {
29 | crnd::crnd_unpack_end(pContext);
30 | return false;
31 | }
32 | crnd::crnd_unpack_end(pContext);
33 | return true;
34 | }
--------------------------------------------------------------------------------
/Texture2DDecoderNative/crunch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | bool crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t level_index, void** ret, uint32_t* ret_size);
--------------------------------------------------------------------------------
/Texture2DDecoderNative/dllexport.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #if defined(_MSC_VER)
4 | #if _MSC_VER < 1910 // MSVC 2017-
5 | #error MSVC 2017 or later is required.
6 | #endif
7 | #endif
8 |
9 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__)
10 | #ifdef _T2D_DLL
11 | #ifdef __GNUC__
12 | #define _T2D_EXPORT __attribute__ ((dllexport))
13 | #else
14 | #define _T2D_EXPORT __declspec(dllexport)
15 | #endif
16 | #else
17 | #ifdef __GNUC__
18 | #define _T2D_EXPORT __attribute__ ((dllimport))
19 | #else
20 | #define _T2D_EXPORT __declspec(dllimport)
21 | #endif
22 | #endif
23 | #define _T2D_LOCAL
24 | #else
25 | #if __GNUC__ >= 4
26 | #define _T2D_EXPORT __attribute__ ((visibility ("default")))
27 | #define _T2D_LOCAL __attribute__ ((visibility ("hidden")))
28 | #else
29 | #define _T2D_EXPORT
30 | #define _T2D_LOCAL
31 | #endif
32 | #endif
33 |
34 | #ifdef __cplusplus
35 | #ifndef _EXTERN_C_STMT
36 | #define _EXTERN_C_STMT extern "C"
37 | #endif
38 | #else
39 | #ifndef _EXTERN_C_STMT
40 | #define _EXTERN_C_STMT
41 | #endif
42 | #endif
43 |
44 | #ifndef _T2D_CALL
45 | #if defined(WIN32) || defined(_WIN32)
46 | #define _T2D_CALL __stdcall
47 | #else
48 | #define _T2D_CALL /* __cdecl */
49 | #endif
50 | #endif
51 |
52 | #if defined(_MSC_VER)
53 | #define T2D_API(ret_type) _EXTERN_C_STMT _T2D_EXPORT ret_type _T2D_CALL
54 | #else
55 | #define T2D_API(ret_type) _EXTERN_C_STMT _T2D_EXPORT _T2D_CALL ret_type
56 | #endif
57 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/etc.h:
--------------------------------------------------------------------------------
1 | #ifndef ETC_H
2 | #define ETC_H
3 |
4 | #include
5 |
6 | int decode_etc1(const uint8_t *, const long, const long, uint32_t *);
7 | int decode_etc2(const uint8_t *, const long, const long, uint32_t *);
8 | int decode_etc2a1(const uint8_t *, const long, const long, uint32_t *);
9 | int decode_etc2a8(const uint8_t *, const long, const long, uint32_t *);
10 | int decode_eacr(const uint8_t *, const long, const long, uint32_t *);
11 | int decode_eacr_signed(const uint8_t *, const long, const long, uint32_t *);
12 | int decode_eacrg(const uint8_t *, const long, const long, uint32_t *);
13 | int decode_eacrg_signed(const uint8_t *, const long, const long, uint32_t *);
14 |
15 | #endif /* end of include guard: ETC_H */
16 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/fp16.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef FP16_H
3 | #define FP16_H
4 |
5 | #include "fp16/fp16.h"
6 |
7 | #endif /* FP16_H */
8 |
9 | /*
10 | *
11 | * License Information
12 | *
13 | * FP16 library is derived from https://github.com/Maratyszcza/FP16.
14 | * The library is licensed under the MIT License shown below.
15 | *
16 | *
17 | * The MIT License (MIT)
18 | *
19 | * Copyright (c) 2017 Facebook Inc.
20 | * Copyright (c) 2017 Georgia Institute of Technology
21 | * Copyright 2019 Google LLC
22 | *
23 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
24 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
25 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
26 | * permit persons to whom the Software is furnished to do so, subject to the following conditions:
27 | *
28 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
29 | * Software.
30 | *
31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
32 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
33 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
34 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 | *
36 | */
37 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/fp16/bitcasts.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef FP16_BITCASTS_H
3 | #define FP16_BITCASTS_H
4 |
5 | #if defined(__cplusplus) && (__cplusplus >= 201103L)
6 | #include
7 | #elif !defined(__OPENCL_VERSION__)
8 | #include
9 | #endif
10 |
11 |
12 | static inline float fp32_from_bits(uint32_t w) {
13 | #if defined(__OPENCL_VERSION__)
14 | return as_float(w);
15 | #elif defined(__CUDA_ARCH__)
16 | return __uint_as_float((unsigned int) w);
17 | #elif defined(__INTEL_COMPILER)
18 | return _castu32_f32(w);
19 | #else
20 | union {
21 | uint32_t as_bits;
22 | float as_value;
23 | } fp32 = { w };
24 | return fp32.as_value;
25 | #endif
26 | }
27 |
28 | static inline uint32_t fp32_to_bits(float f) {
29 | #if defined(__OPENCL_VERSION__)
30 | return as_uint(f);
31 | #elif defined(__CUDA_ARCH__)
32 | return (uint32_t) __float_as_uint(f);
33 | #elif defined(__INTEL_COMPILER)
34 | return _castf32_u32(f);
35 | #else
36 | union {
37 | float as_value;
38 | uint32_t as_bits;
39 | } fp32 = { f };
40 | return fp32.as_bits;
41 | #endif
42 | }
43 |
44 | static inline double fp64_from_bits(uint64_t w) {
45 | #if defined(__OPENCL_VERSION__)
46 | return as_double(w);
47 | #elif defined(__CUDA_ARCH__)
48 | return __longlong_as_double((long long) w);
49 | #elif defined(__INTEL_COMPILER)
50 | return _castu64_f64(w);
51 | #else
52 | union {
53 | uint64_t as_bits;
54 | double as_value;
55 | } fp64 = { w };
56 | return fp64.as_value;
57 | #endif
58 | }
59 |
60 | static inline uint64_t fp64_to_bits(double f) {
61 | #if defined(__OPENCL_VERSION__)
62 | return as_ulong(f);
63 | #elif defined(__CUDA_ARCH__)
64 | return (uint64_t) __double_as_longlong(f);
65 | #elif defined(__INTEL_COMPILER)
66 | return _castf64_u64(f);
67 | #else
68 | union {
69 | double as_value;
70 | uint64_t as_bits;
71 | } fp64 = { f };
72 | return fp64.as_bits;
73 | #endif
74 | }
75 |
76 | #endif /* FP16_BITCASTS_H */
77 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/pvrtc.h:
--------------------------------------------------------------------------------
1 | #ifndef PVRTC_H
2 | #define PVRTC_H
3 |
4 | #include
5 |
6 | typedef struct {
7 | uint8_t r;
8 | uint8_t g;
9 | uint8_t b;
10 | uint8_t a;
11 | } PVRTCTexelColor;
12 |
13 | typedef struct {
14 | int r;
15 | int g;
16 | int b;
17 | int a;
18 | } PVRTCTexelColorInt;
19 |
20 | typedef struct {
21 | PVRTCTexelColor a;
22 | PVRTCTexelColor b;
23 | int8_t weight[32];
24 | uint32_t punch_through_flag;
25 | } PVRTCTexelInfo;
26 |
27 | int decode_pvrtc(const uint8_t *, const long, const long, uint32_t *, const int);
28 |
29 | #endif /* end of include guard: PVRTC_H */
30 |
--------------------------------------------------------------------------------
/Texture2DDecoderNative/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Perfare/AssetStudio/d158e864b556b5970709c2a52e47944d53aa98a2/Texture2DDecoderNative/resource.h
--------------------------------------------------------------------------------
/Texture2DDecoderNative/unitycrunch.cpp:
--------------------------------------------------------------------------------
1 | #include "unitycrunch.h"
2 | #include
3 | #include
4 | #include "unitycrunch/crn_decomp.h"
5 |
6 | bool unity_crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t level_index, void** ret, uint32_t* ret_size) {
7 | unitycrnd::crn_texture_info tex_info;
8 | if (!unitycrnd::crnd_get_texture_info(data, data_size, &tex_info))
9 | {
10 | return false;
11 | }
12 |
13 | unitycrnd::crnd_unpack_context pContext = unitycrnd::crnd_unpack_begin(data, data_size);
14 | if (!pContext)
15 | {
16 | return false;
17 | }
18 |
19 | const crn_uint32 width = std::max(1U, tex_info.m_width >> level_index);
20 | const crn_uint32 height = std::max(1U, tex_info.m_height >> level_index);
21 | const crn_uint32 blocks_x = std::max(1U, (width + 3) >> 2);
22 | const crn_uint32 blocks_y = std::max(1U, (height + 3) >> 2);
23 | const crn_uint32 row_pitch = blocks_x * unitycrnd::crnd_get_bytes_per_dxt_block(tex_info.m_format);
24 | const crn_uint32 total_face_size = row_pitch * blocks_y;
25 | *ret = new uint8_t[total_face_size];
26 | *ret_size = total_face_size;
27 | if (!unitycrnd::crnd_unpack_level(pContext, ret, total_face_size, row_pitch, level_index))
28 | {
29 | unitycrnd::crnd_unpack_end(pContext);
30 | return false;
31 | }
32 | unitycrnd::crnd_unpack_end(pContext);
33 | return true;
34 | }
--------------------------------------------------------------------------------
/Texture2DDecoderNative/unitycrunch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | bool unity_crunch_unpack_level(const uint8_t* data, uint32_t data_size, uint32_t level_index, void** ret, uint32_t* ret_size);
--------------------------------------------------------------------------------
/Texture2DDecoderWrapper/T2DDll.cs:
--------------------------------------------------------------------------------
1 | namespace Texture2DDecoder
2 | {
3 | internal static class T2DDll
4 | {
5 |
6 | internal const string DllName = "Texture2DDecoderNative";
7 |
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Texture2DDecoderWrapper/Texture2DDecoderWrapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;netstandard2.0;net5.0;net6.0
5 | true
6 | 0.16.0.0
7 | 0.16.0.0
8 | 0.16.0.0
9 | Copyright © Perfare 2020-2022; Copyright © hozuki 2020
10 | embedded
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------