mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
- export mesh deformers with dummies or bones
- FBX code re-arranged to get object count - changed the way FBX ASCII lines are split at every ~2000 chars - added option to export tangents - fixed a problem with treeview continuous search
This commit is contained in:
169
Unity Studio/Unity Classes/AudioClip.cs
Normal file
169
Unity Studio/Unity Classes/AudioClip.cs
Normal file
@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class AudioClip
|
||||
{
|
||||
public string m_Name;
|
||||
public int m_Format;
|
||||
public int m_Type = -1;
|
||||
public bool m_3D;
|
||||
public bool m_UseHardware;
|
||||
|
||||
//Unity 5
|
||||
public int m_LoadType;
|
||||
public int m_Channels;
|
||||
public int m_Frequency;
|
||||
public int m_BitsPerSample;
|
||||
public float m_Length;
|
||||
public bool m_IsTrackerFormat;
|
||||
public int m_SubsoundIndex;
|
||||
public bool m_PreloadAudioData;
|
||||
public bool m_LoadInBackground;
|
||||
public bool m_Legacy3D;
|
||||
public int m_CompressionFormat = -1;
|
||||
|
||||
public string m_Source;
|
||||
public long m_Offset;
|
||||
public long m_Size;
|
||||
public byte[] m_AudioData;
|
||||
|
||||
public string extension = "";
|
||||
|
||||
public AudioClip(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
|
||||
m_Format = a_Stream.ReadInt32(); //channels?
|
||||
m_Type = a_Stream.ReadInt32();
|
||||
m_3D = a_Stream.ReadBoolean();
|
||||
m_UseHardware = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 2; //4 byte alignment
|
||||
|
||||
if (sourceFile.version[0] >= 4 || (sourceFile.version[0] == 3 && sourceFile.version[1] >= 2)) //3.2.0 to 5
|
||||
{
|
||||
int m_Stream = a_Stream.ReadInt32();
|
||||
m_Size = a_Stream.ReadInt32();
|
||||
|
||||
if (m_Stream > 1)
|
||||
{
|
||||
m_Offset = a_Stream.ReadInt32();
|
||||
m_Source = sourceFile.filePath + ".resS";
|
||||
}
|
||||
}
|
||||
else { m_Size = a_Stream.ReadInt32(); }
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LoadType = a_Stream.ReadInt32();//Decompress on load, Compressed in memory, Streaming
|
||||
m_Channels = a_Stream.ReadInt32();
|
||||
m_Frequency = a_Stream.ReadInt32();
|
||||
m_BitsPerSample = a_Stream.ReadInt32();
|
||||
m_Length = a_Stream.ReadSingle();
|
||||
m_IsTrackerFormat = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3;
|
||||
m_SubsoundIndex = a_Stream.ReadInt32();
|
||||
m_PreloadAudioData = a_Stream.ReadBoolean();
|
||||
m_LoadInBackground = a_Stream.ReadBoolean();
|
||||
m_Legacy3D = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 1;
|
||||
m_3D = m_Legacy3D;
|
||||
|
||||
m_Source = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
//m_Source = Path.GetFileName(m_Source);
|
||||
m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), m_Source.Replace("archive:/",""));
|
||||
m_Offset = a_Stream.ReadInt64();
|
||||
m_Size = a_Stream.ReadInt64();
|
||||
m_CompressionFormat = a_Stream.ReadInt32();
|
||||
}
|
||||
|
||||
#region Info Text & extension
|
||||
preloadData.InfoText = "Compression format: ";
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
case 2:
|
||||
extension = ".aif";
|
||||
preloadData.InfoText += "AIFF";
|
||||
break;
|
||||
case 13:
|
||||
extension = ".mp3";
|
||||
preloadData.InfoText += "MP3";
|
||||
break;
|
||||
case 14:
|
||||
extension = ".ogg";
|
||||
preloadData.InfoText += "Ogg Vorbis";
|
||||
break;
|
||||
case 20:
|
||||
extension = ".wav";
|
||||
preloadData.InfoText += "WAV";
|
||||
break;
|
||||
case 22: //xbox encoding
|
||||
extension = ".wav";
|
||||
preloadData.InfoText += "Xbox360 WAV";
|
||||
break;
|
||||
}
|
||||
|
||||
switch (m_CompressionFormat)
|
||||
{
|
||||
case 0:
|
||||
extension = ".fsb";
|
||||
preloadData.InfoText += "PCM";
|
||||
break;
|
||||
case 1:
|
||||
extension = ".fsb";
|
||||
preloadData.InfoText += "Vorbis";
|
||||
break;
|
||||
case 2:
|
||||
extension = ".fsb";
|
||||
preloadData.InfoText += "ADPCM";
|
||||
break;
|
||||
case 3:
|
||||
extension = ".fsb";
|
||||
preloadData.InfoText += "MP3";//not sure
|
||||
break;
|
||||
}
|
||||
|
||||
if (extension == "") { preloadData.InfoText += "Unknown"; }
|
||||
preloadData.InfoText += "\n3D: " + m_3D.ToString();
|
||||
#endregion
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
m_AudioData = new byte[m_Size];
|
||||
|
||||
if (m_Source == null)
|
||||
{
|
||||
a_Stream.Read(m_AudioData, 0, (int)m_Size);
|
||||
}
|
||||
else if (File.Exists(m_Source))
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(m_Source)))
|
||||
{
|
||||
reader.BaseStream.Position = m_Offset;
|
||||
reader.Read(m_AudioData, 0, (int)m_Size);
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
Unity Studio/Unity Classes/BuildSettings.cs
Normal file
38
Unity Studio/Unity Classes/BuildSettings.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class BuildSettings
|
||||
{
|
||||
public string m_Version;
|
||||
|
||||
public BuildSettings(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
int levels = a_Stream.ReadInt32();
|
||||
for (int l = 0; l < levels; l++) { string level = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); }
|
||||
|
||||
if (sourceFile.version[0] == 5)
|
||||
{
|
||||
int preloadedPlugins = a_Stream.ReadInt32();
|
||||
for (int l = 0; l < preloadedPlugins; l++) { string preloadedPlugin = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); }
|
||||
}
|
||||
|
||||
a_Stream.Position += 4; //bool flags
|
||||
if (sourceFile.fileGen >= 8) { a_Stream.Position += 4; } //bool flags
|
||||
if (sourceFile.fileGen >= 9) { a_Stream.Position += 4; } //bool flags
|
||||
if (sourceFile.version[0] == 5 ||
|
||||
(sourceFile.version[0] == 4 && (sourceFile.version[1] >= 3 ||
|
||||
(sourceFile.version[1] == 2 && sourceFile.buildType[0] != "a"))))
|
||||
{ a_Stream.Position += 4; } //bool flags
|
||||
|
||||
m_Version = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
132
Unity Studio/Unity Classes/Font.cs
Normal file
132
Unity Studio/Unity Classes/Font.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class unityFont
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_FontData;
|
||||
public string extension;
|
||||
|
||||
public unityFont(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
|
||||
int m_AsciiStartOffset = a_Stream.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_FontCountX = a_Stream.ReadInt32();
|
||||
int m_FontCountY = a_Stream.ReadInt32();
|
||||
}
|
||||
|
||||
float m_Kerning = a_Stream.ReadSingle();
|
||||
float m_LineSpacing = a_Stream.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
int m_PerCharacterKerning_size = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < m_PerCharacterKerning_size; i++)
|
||||
{
|
||||
int first = a_Stream.ReadInt32();
|
||||
float second = a_Stream.ReadSingle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int m_CharacterSpacing = a_Stream.ReadInt32();
|
||||
int m_CharacterPadding = a_Stream.ReadInt32();
|
||||
}
|
||||
|
||||
int m_ConvertCase = a_Stream.ReadInt32();
|
||||
PPtr m_DefaultMaterial = sourceFile.ReadPPtr();
|
||||
|
||||
int m_CharacterRects_size = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < m_CharacterRects_size; i++)
|
||||
{
|
||||
int index = a_Stream.ReadInt32();
|
||||
//Rectf uv
|
||||
float uvx = a_Stream.ReadSingle();
|
||||
float uvy = a_Stream.ReadSingle();
|
||||
float uvwidth = a_Stream.ReadSingle();
|
||||
float uvheight = a_Stream.ReadSingle();
|
||||
//Rectf vert
|
||||
float vertx = a_Stream.ReadSingle();
|
||||
float verty = a_Stream.ReadSingle();
|
||||
float vertwidth = a_Stream.ReadSingle();
|
||||
float vertheight = a_Stream.ReadSingle();
|
||||
float width = a_Stream.ReadSingle();
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
bool flipped = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3;
|
||||
}
|
||||
}
|
||||
|
||||
PPtr m_Texture = sourceFile.ReadPPtr();
|
||||
|
||||
int m_KerningValues_size = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < m_KerningValues_size; i++)
|
||||
{
|
||||
int pairfirst = a_Stream.ReadInt16();
|
||||
int pairsecond = a_Stream.ReadInt16();
|
||||
float second = a_Stream.ReadSingle();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] <= 3)
|
||||
{
|
||||
bool m_GridFont = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3; //4 byte alignment
|
||||
}
|
||||
else { float m_PixelScale = a_Stream.ReadSingle(); }
|
||||
|
||||
int m_FontData_size = a_Stream.ReadInt32();
|
||||
if (m_FontData_size > 0)
|
||||
{
|
||||
m_FontData = new byte[m_FontData_size];
|
||||
a_Stream.Read(m_FontData, 0, m_FontData_size);
|
||||
|
||||
if (m_FontData[0] == 79 && m_FontData[1] == 84 && m_FontData[2] == 84 && m_FontData[3] == 79)
|
||||
{ extension = ".otf"; }
|
||||
else { extension = ".ttf"; }
|
||||
|
||||
}
|
||||
|
||||
float m_FontSize = a_Stream.ReadSingle();//problem here in minifootball
|
||||
float m_Ascent = a_Stream.ReadSingle();
|
||||
uint m_DefaultStyle = a_Stream.ReadUInt32();
|
||||
|
||||
int m_FontNames = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < m_FontNames; i++)
|
||||
{
|
||||
string m_FontName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 4)
|
||||
{
|
||||
int m_FallbackFonts = a_Stream.ReadInt32();
|
||||
for (int i = 0; i < m_FallbackFonts; i++)
|
||||
{
|
||||
PPtr m_FallbackFont = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
int m_FontRenderingMode = a_Stream.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
77
Unity Studio/Unity Classes/GameObject.cs
Normal file
77
Unity Studio/Unity Classes/GameObject.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class GameObject : TreeNode
|
||||
{
|
||||
public PPtr m_Transform;
|
||||
public PPtr m_Renderer;
|
||||
public PPtr m_MeshFilter;
|
||||
public PPtr m_SkinnedMeshRenderer;
|
||||
public int m_Layer;
|
||||
public string m_Name;
|
||||
public ushort m_Tag;
|
||||
public bool m_IsActive;
|
||||
|
||||
public string uniqueID = "0";//this way file and folder TreeNodes will be treated as FBX scene
|
||||
|
||||
public GameObject(AssetPreloadData preloadData)
|
||||
{
|
||||
if (preloadData != null)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
uniqueID = preloadData.uniqueID;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
int m_Component_size = a_Stream.ReadInt32();
|
||||
for (int j = 0; j < m_Component_size; j++)
|
||||
{
|
||||
int m_Component_type = a_Stream.ReadInt32();
|
||||
|
||||
switch (m_Component_type)
|
||||
{
|
||||
case 4:
|
||||
m_Transform = sourceFile.ReadPPtr();
|
||||
break;
|
||||
case 23:
|
||||
m_Renderer = sourceFile.ReadPPtr();
|
||||
break;
|
||||
case 33:
|
||||
m_MeshFilter = sourceFile.ReadPPtr();
|
||||
break;
|
||||
case 137:
|
||||
m_SkinnedMeshRenderer = sourceFile.ReadPPtr();
|
||||
break;
|
||||
default:
|
||||
PPtr m_Component = sourceFile.ReadPPtr();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_Layer = a_Stream.ReadInt32();
|
||||
int namesize = a_Stream.ReadInt32();
|
||||
m_Name = a_Stream.ReadAlignedString(namesize);
|
||||
if (m_Name == "") { m_Name = "GameObject #" + uniqueID; }
|
||||
m_Tag = a_Stream.ReadUInt16();
|
||||
m_IsActive = a_Stream.ReadBoolean();
|
||||
|
||||
base.Text = m_Name;
|
||||
//name should be unique
|
||||
base.Name = uniqueID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
97
Unity Studio/Unity Classes/Material.cs
Normal file
97
Unity Studio/Unity Classes/Material.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class Material
|
||||
{
|
||||
|
||||
public string m_Name;
|
||||
public PPtr m_Shader;
|
||||
public string[] m_ShaderKeywords;
|
||||
public int m_CustomRenderQueue;
|
||||
public TexEnv[] m_TexEnvs;
|
||||
public strFloatPair[] m_Floats;
|
||||
public strColorPair[] m_Colors;
|
||||
|
||||
public Material(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Shader = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] == 4 && (sourceFile.version[1] >= 2 || (sourceFile.version[1] == 1 && sourceFile.buildType[0] != "a")))
|
||||
{
|
||||
m_ShaderKeywords = new string[a_Stream.ReadInt32()];
|
||||
for (int i = 0; i < m_ShaderKeywords.Length; i++)
|
||||
{
|
||||
m_ShaderKeywords[i] = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
}
|
||||
else if (sourceFile.version[0] == 5)
|
||||
{
|
||||
m_ShaderKeywords = new string[1] { a_Stream.ReadAlignedString(a_Stream.ReadInt32()) };
|
||||
uint m_LightmapFlags = a_Stream.ReadUInt32();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] > 4 || (sourceFile.version[0] == 4 && sourceFile.version[1] >= 3)) { m_CustomRenderQueue = a_Stream.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 1)
|
||||
{
|
||||
string[][] stringTagMap = new string[a_Stream.ReadInt32()][];
|
||||
for (int i = 0; i < stringTagMap.Length; i++)
|
||||
{
|
||||
stringTagMap[i] = new string[2] { a_Stream.ReadAlignedString(a_Stream.ReadInt32()), a_Stream.ReadAlignedString(a_Stream.ReadInt32()) };
|
||||
}
|
||||
}
|
||||
|
||||
//m_SavedProperties
|
||||
m_TexEnvs = new TexEnv[a_Stream.ReadInt32()];
|
||||
for (int i = 0; i < m_TexEnvs.Length; i++)
|
||||
{
|
||||
TexEnv m_TexEnv = new TexEnv()
|
||||
{
|
||||
name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
m_Texture = sourceFile.ReadPPtr(),
|
||||
m_Scale = new float[2] { a_Stream.ReadSingle(), a_Stream.ReadSingle() },
|
||||
m_Offset = new float[2] { a_Stream.ReadSingle(), a_Stream.ReadSingle() }
|
||||
};
|
||||
m_TexEnvs[i] = m_TexEnv;
|
||||
}
|
||||
|
||||
m_Floats = new strFloatPair[a_Stream.ReadInt32()];
|
||||
for (int i = 0; i < m_Floats.Length; i++)
|
||||
{
|
||||
strFloatPair m_Float = new strFloatPair()
|
||||
{
|
||||
first = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
second = a_Stream.ReadSingle()
|
||||
};
|
||||
m_Floats[i] = m_Float;
|
||||
}
|
||||
|
||||
m_Colors = new strColorPair[a_Stream.ReadInt32()];
|
||||
for (int i = 0; i < m_Colors.Length; i++)
|
||||
{
|
||||
strColorPair m_Color = new strColorPair()
|
||||
{
|
||||
first = a_Stream.ReadAlignedString(a_Stream.ReadInt32()),
|
||||
second = new float[4] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() }
|
||||
};
|
||||
m_Colors[i] = m_Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1133
Unity Studio/Unity Classes/Mesh.cs
Normal file
1133
Unity Studio/Unity Classes/Mesh.cs
Normal file
File diff suppressed because it is too large
Load Diff
31
Unity Studio/Unity Classes/MeshFilter.cs
Normal file
31
Unity Studio/Unity Classes/MeshFilter.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class MeshFilter
|
||||
{
|
||||
public long preloadIndex;
|
||||
public PPtr m_GameObject = new PPtr();
|
||||
public PPtr m_Mesh = new PPtr();
|
||||
|
||||
public MeshFilter(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
m_Mesh = sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
}
|
47
Unity Studio/Unity Classes/PlayerSettings.cs
Normal file
47
Unity Studio/Unity Classes/PlayerSettings.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class PlayerSettings
|
||||
{
|
||||
public string companyName = "";
|
||||
public string productName = "";
|
||||
|
||||
public PlayerSettings(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.version[0] >= 3)
|
||||
{
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <2) { string AndroidLicensePublicKey = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); }
|
||||
else { bool AndroidProfiler = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
|
||||
int defaultScreenOrientation = a_Stream.ReadInt32();
|
||||
int targetDevice = a_Stream.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 1))
|
||||
{ int targetGlesGraphics = a_Stream.ReadInt32(); }
|
||||
|
||||
if ((sourceFile.version[0] == 5 && sourceFile.version[1] < 1) || (sourceFile.version[0] == 4 && sourceFile.version[1] == 6 && sourceFile.version[2] >= 3))
|
||||
{ int targetIOSGraphics = a_Stream.ReadInt32(); }
|
||||
|
||||
if (sourceFile.version[0] == 5 && (sourceFile.version[1] > 2 || (sourceFile.version[1] == 2 && sourceFile.version[2] >= 1)))
|
||||
{ bool useOnDemandResources = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
|
||||
int targetResolution = a_Stream.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 1) { bool OverrideIPodMusic = a_Stream.ReadBoolean(); a_Stream.AlignStream(4); }
|
||||
else if (sourceFile.version[0] == 3 && sourceFile.version[1] <= 4) { }
|
||||
else { int accelerometerFrequency = a_Stream.ReadInt32(); }//3.5.0 and up
|
||||
}
|
||||
//fail in Unity 5 beta
|
||||
companyName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
productName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
30
Unity Studio/Unity Classes/RectTransform.cs
Normal file
30
Unity Studio/Unity Classes/RectTransform.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class RectTransform
|
||||
{
|
||||
public Transform m_Transform;
|
||||
|
||||
public RectTransform(AssetPreloadData preloadData)
|
||||
{
|
||||
m_Transform = new Transform(preloadData);
|
||||
|
||||
//var sourceFile = preloadData.sourceFile;
|
||||
//var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
|
||||
/*
|
||||
float[2] AnchorsMin
|
||||
float[2] AnchorsMax
|
||||
float[2] Pivod
|
||||
float Width
|
||||
float Height
|
||||
float[2] ?
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
Unity Studio/Unity Classes/Renderer.cs
Normal file
63
Unity Studio/Unity Classes/Renderer.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class Renderer
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public bool m_Enabled;
|
||||
public byte m_CastShadows; //bool prior to Unity 5
|
||||
public bool m_ReceiveShadows;
|
||||
public ushort m_LightmapIndex;
|
||||
public ushort m_LightmapIndexDynamic;
|
||||
public PPtr[] m_Materials;
|
||||
|
||||
public Renderer(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
m_CastShadows = a_Stream.ReadByte();
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
m_LightmapIndex = a_Stream.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
m_CastShadows = a_Stream.ReadByte();
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = a_Stream.ReadUInt16();
|
||||
m_LightmapIndexDynamic = a_Stream.ReadUInt16();
|
||||
}
|
||||
|
||||
if (sourceFile.version[0] >= 3) { a_Stream.Position += 16; } //Vector4f m_LightmapTilingOffset
|
||||
if (sourceFile.version[0] >= 5) { a_Stream.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[a_Stream.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
136
Unity Studio/Unity Classes/SkinnedMeshRenderer.cs
Normal file
136
Unity Studio/Unity Classes/SkinnedMeshRenderer.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class SkinnedMeshRenderer
|
||||
{
|
||||
public PPtr m_GameObject;
|
||||
public bool m_Enabled;
|
||||
public byte m_CastShadows;
|
||||
public bool m_ReceiveShadows;
|
||||
public ushort m_LightmapIndex;
|
||||
public ushort m_LightmapIndexDynamic;
|
||||
public PPtr[] m_Materials;
|
||||
public PPtr m_Mesh;
|
||||
public PPtr[] m_Bones;
|
||||
|
||||
public SkinnedMeshRenderer(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var version = preloadData.sourceFile.version;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
if (sourceFile.version[0] < 5)
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
m_CastShadows = a_Stream.ReadByte();//bool
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
m_LightmapIndex = a_Stream.ReadByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Enabled = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
m_CastShadows = a_Stream.ReadByte();
|
||||
m_ReceiveShadows = a_Stream.ReadBoolean();
|
||||
a_Stream.AlignStream(4);
|
||||
|
||||
m_LightmapIndex = a_Stream.ReadUInt16();
|
||||
m_LightmapIndexDynamic = a_Stream.ReadUInt16();
|
||||
}
|
||||
|
||||
if (version[0] >= 3) { a_Stream.Position += 16; } //m_LightmapTilingOffset vector4d
|
||||
if (sourceFile.version[0] >= 5) { a_Stream.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic
|
||||
|
||||
m_Materials = new PPtr[a_Stream.ReadInt32()];
|
||||
for (int m = 0; m < m_Materials.Length; m++)
|
||||
{
|
||||
m_Materials[m] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] < 3) { a_Stream.Position += 16; } //m_LightmapTilingOffset vector4d
|
||||
else
|
||||
{
|
||||
int m_SubsetIndices_size = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_SubsetIndices_size * 4;
|
||||
PPtr m_StaticBatchRoot = sourceFile.ReadPPtr();
|
||||
|
||||
if (version[0] >= 4 || (version[0] == 3 && version[1] >= 5))
|
||||
{
|
||||
bool m_UseLightProbes = a_Stream.ReadBoolean();
|
||||
a_Stream.Position += 3; //alignment
|
||||
if (version[0] == 5) { int m_ReflectionProbeUsage = a_Stream.ReadInt32(); }
|
||||
//did I ever check if the anchor is conditioned by the bool?
|
||||
PPtr m_LightProbeAnchor = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] >= 5 || (version[0] == 4 && version[1] >= 3))
|
||||
{
|
||||
if (version[0] == 4 && version[1] <= 3) { int m_SortingLayer = a_Stream.ReadInt16(); }
|
||||
else { int m_SortingLayer = a_Stream.ReadInt32(); }
|
||||
|
||||
int m_SortingOrder = a_Stream.ReadInt16();
|
||||
a_Stream.AlignStream(4);
|
||||
}
|
||||
}
|
||||
|
||||
int m_Quality = a_Stream.ReadInt32();
|
||||
bool m_UpdateWhenOffscreen = a_Stream.ReadBoolean();
|
||||
bool m_SkinNormals = a_Stream.ReadBoolean(); //3.1.0 and below
|
||||
a_Stream.Position += 2;
|
||||
|
||||
if (version[0] == 2 && version[1] < 6)
|
||||
{
|
||||
//this would be the only error if mainVersion is not read in time for a unity 2.x game
|
||||
PPtr m_DisableAnimationWhenOffscreen = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Mesh = sourceFile.ReadPPtr();
|
||||
|
||||
m_Bones = new PPtr[a_Stream.ReadInt32()];
|
||||
for (int b = 0; b < m_Bones.Length; b++)
|
||||
{
|
||||
m_Bones[b] = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] < 3)
|
||||
{
|
||||
int m_BindPose = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_BindPose * 16 * 4;//Matrix4x4f
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version[0] >= 4 || (version[0] == 4 && version[1] >= 3))
|
||||
{
|
||||
int m_BlendShapeWeights = a_Stream.ReadInt32();
|
||||
a_Stream.Position += m_BlendShapeWeights * 4; //floats
|
||||
}
|
||||
|
||||
if (version[0] >= 4 || (version[0] >= 3 && version[1] >= 5))
|
||||
{
|
||||
PPtr m_RootBone = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
if (version[0] >= 4 || (version[0] == 3 && version[1] >= 4))
|
||||
{
|
||||
//AABB
|
||||
float[] m_Center = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
float[] m_Extent = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
bool m_DirtyAABB = a_Stream.ReadBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
Unity Studio/Unity Classes/TextAsset.cs
Normal file
60
Unity Studio/Unity Classes/TextAsset.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class TextAsset
|
||||
{
|
||||
public string m_Name;
|
||||
public byte[] m_Script;
|
||||
public string m_PathName;
|
||||
|
||||
public int exportSize;
|
||||
public string extension = ".txt";
|
||||
|
||||
public TextAsset(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
|
||||
int m_Script_size = a_Stream.ReadInt32();
|
||||
|
||||
if (readSwitch) //asset is read for preview or export
|
||||
{
|
||||
m_Script = new byte[m_Script_size];
|
||||
a_Stream.Read(m_Script, 0, m_Script_size);
|
||||
|
||||
if (m_Script[0] == 93) { m_Script = SevenZip.Compression.LZMA.SevenZipHelper.Decompress(m_Script); }
|
||||
if (m_Script[0] == 60 || (m_Script[0] == 239 && m_Script[1] == 187 && m_Script[2] == 191 && m_Script[3] == 60)) { extension = ".xml"; }
|
||||
}
|
||||
else
|
||||
{
|
||||
byte lzmaTest = a_Stream.ReadByte();
|
||||
if (lzmaTest == 93)
|
||||
{
|
||||
a_Stream.Position += 4;
|
||||
exportSize = a_Stream.ReadInt32(); //actualy int64
|
||||
a_Stream.Position -= 8;
|
||||
}
|
||||
else { exportSize = m_Script_size; }
|
||||
|
||||
a_Stream.Position += m_Script_size - 1;
|
||||
}
|
||||
a_Stream.AlignStream(4);
|
||||
|
||||
m_PathName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
}
|
||||
}
|
||||
}
|
337
Unity Studio/Unity Classes/Texture2D.cs
Normal file
337
Unity Studio/Unity Classes/Texture2D.cs
Normal file
@ -0,0 +1,337 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
class Texture2D
|
||||
{
|
||||
public string m_Name;
|
||||
public int m_Width;
|
||||
public int m_Height;
|
||||
public int m_CompleteImageSize;
|
||||
public int m_TextureFormat;
|
||||
public bool m_MipMap = false;
|
||||
public bool m_IsReadable;
|
||||
public bool m_ReadAllowed;
|
||||
public int m_ImageCount;
|
||||
public int m_TextureDimension;
|
||||
//m_TextureSettings
|
||||
public int m_FilterMode;
|
||||
public int m_Aniso;
|
||||
public float m_MipBias;
|
||||
public int m_WrapMode;
|
||||
public int m_LightmapFormat;
|
||||
public int m_ColorSpace;
|
||||
public byte[] image_data;
|
||||
|
||||
public int dwFlags = 0x1 + 0x2 + 0x4 + 0x1000;
|
||||
//public int dwHeight;
|
||||
//public int dwWidth;
|
||||
public int dwPitchOrLinearSize = 0x0;
|
||||
public int dwMipMapCount = 0x1;
|
||||
public int dwSize = 0x20;
|
||||
public int dwFlags2;
|
||||
public int dwFourCC = 0x0;
|
||||
public int dwRGBBitCount;
|
||||
public int dwRBitMask;
|
||||
public int dwGBitMask;
|
||||
public int dwBBitMask;
|
||||
public int dwABitMask;
|
||||
public int dwCaps = 0x1000;
|
||||
public int dwCaps2 = 0x0;
|
||||
|
||||
public int pvrVersion = 0x03525650;
|
||||
public int pvrFlags = 0x0;
|
||||
public long pvrPixelFormat;
|
||||
public int pvrColourSpace = 0x0;
|
||||
public int pvrChannelType = 0x0;
|
||||
//public int pvrHeight;
|
||||
//public int pvrWidth;
|
||||
public int pvrDepth = 0x1;
|
||||
public int pvrNumSurfaces = 0x1; //For texture arrays
|
||||
public int pvrNumFaces = 0x1; //For cube maps
|
||||
//public int pvrMIPMapCount;
|
||||
public int pvrMetaDataSize = 0x0;
|
||||
|
||||
public int image_data_size;
|
||||
string extension;
|
||||
|
||||
public Texture2D(AssetPreloadData preloadData, bool readSwitch)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
|
||||
m_Width = a_Stream.ReadInt32();
|
||||
m_Height = a_Stream.ReadInt32();
|
||||
m_CompleteImageSize = a_Stream.ReadInt32();
|
||||
m_TextureFormat = a_Stream.ReadInt32();
|
||||
|
||||
if (m_TextureFormat < 30) { extension = ".dds"; }
|
||||
else if (m_TextureFormat < 35) { extension = ".pvr"; }
|
||||
else { extension = "_" + m_Width.ToString() + "x" + m_Height.ToString() + "." + m_TextureFormat.ToString() + ".tex"; }
|
||||
|
||||
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 2))
|
||||
{ m_MipMap = a_Stream.ReadBoolean(); }
|
||||
else
|
||||
{
|
||||
dwFlags += 0x20000;
|
||||
dwMipMapCount = a_Stream.ReadInt32();//is this with or without main image?
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
m_IsReadable = a_Stream.ReadBoolean(); //2.6.0 and up
|
||||
m_ReadAllowed = a_Stream.ReadBoolean(); //3.0.0 and up
|
||||
a_Stream.AlignStream(4);
|
||||
|
||||
m_ImageCount = a_Stream.ReadInt32();
|
||||
m_TextureDimension = a_Stream.ReadInt32();
|
||||
//m_TextureSettings
|
||||
m_FilterMode = a_Stream.ReadInt32();
|
||||
m_Aniso = a_Stream.ReadInt32();
|
||||
m_MipBias = a_Stream.ReadSingle();
|
||||
m_WrapMode = a_Stream.ReadInt32();
|
||||
|
||||
if (sourceFile.version[0] >= 3)
|
||||
{
|
||||
m_LightmapFormat = a_Stream.ReadInt32();
|
||||
if (sourceFile.version[0] >= 4 || sourceFile.version[1] >= 5) { m_ColorSpace = a_Stream.ReadInt32(); } //3.5.0 and up
|
||||
}
|
||||
|
||||
image_data_size = a_Stream.ReadInt32();
|
||||
|
||||
if (m_MipMap)
|
||||
{
|
||||
dwFlags += 0x20000;
|
||||
dwMipMapCount = Convert.ToInt32(Math.Log(Math.Max(m_Width, m_Height)) / Math.Log(2));
|
||||
dwCaps += 0x400008;
|
||||
}
|
||||
|
||||
if (readSwitch)
|
||||
{
|
||||
|
||||
image_data = new byte[image_data_size];
|
||||
a_Stream.Read(image_data, 0, image_data_size);
|
||||
|
||||
switch (m_TextureFormat)
|
||||
{
|
||||
case 1: //Alpha8
|
||||
{
|
||||
dwFlags2 = 0x2;
|
||||
dwRGBBitCount = 0x8;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0xFF;
|
||||
break;
|
||||
}
|
||||
case 2: //A4R4G4B4
|
||||
{
|
||||
if (sourceFile.platform == 11) //swap bytes for Xbox confirmed, PS3 not encountered
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 2];
|
||||
image_data[i * 2] = image_data[i * 2 + 1];
|
||||
image_data[i * 2 + 1] = b0;
|
||||
}
|
||||
}
|
||||
else if (sourceFile.platform == 13) //swap bits for android
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte[] argb = BitConverter.GetBytes((BitConverter.ToInt32((new byte[4] { image_data[i * 2], image_data[i * 2 + 1], image_data[i * 2], image_data[i * 2 + 1] }), 0)) >> 4);
|
||||
image_data[i * 2] = argb[0];
|
||||
image_data[i * 2 + 1] = argb[1];
|
||||
}
|
||||
}
|
||||
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF00;
|
||||
dwGBitMask = 0xF0;
|
||||
dwBBitMask = 0xF;
|
||||
dwABitMask = 0xF000;
|
||||
break;
|
||||
}
|
||||
case 3: //B8G8R8 //confirmed on X360, iOS //PS3 unsure
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 3); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 3];
|
||||
image_data[i * 3] = image_data[i * 3 + 2];
|
||||
//image_data[i * 3 + 1] stays the same
|
||||
image_data[i * 3 + 2] = b0;
|
||||
|
||||
}
|
||||
|
||||
dwFlags2 = 0x40;
|
||||
dwRGBBitCount = 0x18;
|
||||
dwRBitMask = 0xFF0000;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = 0x0;
|
||||
break;
|
||||
}
|
||||
case 4: //G8R8A8B8 //confirmed on X360, iOS
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 4); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 4];
|
||||
image_data[i * 4] = image_data[i * 4 + 2];
|
||||
//image_data[i * 4 + 1] stays the same
|
||||
image_data[i * 4 + 2] = b0;
|
||||
//image_data[i * 4 + 3] stays the same
|
||||
|
||||
}
|
||||
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF0000;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = -16777216;
|
||||
break;
|
||||
}
|
||||
case 5: //B8G8R8A8 //confirmed on X360, PS3, Web, iOS
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 4); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 4];
|
||||
byte b1 = image_data[i * 4 + 1];
|
||||
image_data[i * 4] = image_data[i * 4 + 3];
|
||||
image_data[i * 4 + 1] = image_data[i * 4 + 2];
|
||||
image_data[i * 4 + 2] = b1;
|
||||
image_data[i * 4 + 3] = b0;
|
||||
|
||||
}
|
||||
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x20;
|
||||
dwRBitMask = 0xFF0000;
|
||||
dwGBitMask = 0xFF00;
|
||||
dwBBitMask = 0xFF;
|
||||
dwABitMask = -16777216;
|
||||
break;
|
||||
}
|
||||
case 7: //R5G6B5 //confirmed switched on X360; confirmed on iOS
|
||||
{
|
||||
if (sourceFile.platform == 11)
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 2];
|
||||
image_data[i * 2] = image_data[i * 2 + 1];
|
||||
image_data[i * 2 + 1] = b0;
|
||||
}
|
||||
}
|
||||
|
||||
dwFlags2 = 0x40;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF800;
|
||||
dwGBitMask = 0x7E0;
|
||||
dwBBitMask = 0x1F;
|
||||
dwABitMask = 0x0;
|
||||
break;
|
||||
}
|
||||
case 10: //DXT1
|
||||
{
|
||||
if (sourceFile.platform == 11) //X360 only, PS3 not
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 2];
|
||||
image_data[i * 2] = image_data[i * 2 + 1];
|
||||
image_data[i * 2 + 1] = b0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_MipMap) { dwPitchOrLinearSize = m_Height * m_Width / 2; }
|
||||
dwFlags2 = 0x4;
|
||||
dwFourCC = 0x31545844;
|
||||
dwRGBBitCount = 0x0;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0x0;
|
||||
break;
|
||||
}
|
||||
case 12: //DXT5
|
||||
{
|
||||
if (sourceFile.platform == 11) //X360, PS3 not
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte b0 = image_data[i * 2];
|
||||
image_data[i * 2] = image_data[i * 2 + 1];
|
||||
image_data[i * 2 + 1] = b0;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_MipMap) { dwPitchOrLinearSize = m_Height * m_Width / 2; }
|
||||
dwFlags2 = 0x4;
|
||||
dwFourCC = 0x35545844;
|
||||
dwRGBBitCount = 0x0;
|
||||
dwRBitMask = 0x0;
|
||||
dwGBitMask = 0x0;
|
||||
dwBBitMask = 0x0;
|
||||
dwABitMask = 0x0;
|
||||
break;
|
||||
}
|
||||
case 13: //R4G4B4A4, iOS (only?)
|
||||
{
|
||||
for (int i = 0; i < (image_data_size / 2); i++)
|
||||
{
|
||||
byte[] argb = BitConverter.GetBytes((BitConverter.ToInt32((new byte[4] { image_data[i * 2], image_data[i * 2 + 1], image_data[i * 2], image_data[i * 2 + 1] }), 0)) >> 4);
|
||||
image_data[i * 2] = argb[0];
|
||||
image_data[i * 2 + 1] = argb[1];
|
||||
}
|
||||
|
||||
dwFlags2 = 0x41;
|
||||
dwRGBBitCount = 0x10;
|
||||
dwRBitMask = 0xF00;
|
||||
dwGBitMask = 0xF0;
|
||||
dwBBitMask = 0xF;
|
||||
dwABitMask = 0xF000;
|
||||
break;
|
||||
}
|
||||
case 30: //PVRTC_RGB2
|
||||
{
|
||||
pvrPixelFormat = 0x0;
|
||||
break;
|
||||
}
|
||||
case 31: //PVRTC_RGBA2
|
||||
{
|
||||
pvrPixelFormat = 0x1;
|
||||
break;
|
||||
}
|
||||
case 32: //PVRTC_RGB4
|
||||
{
|
||||
pvrPixelFormat = 0x2;
|
||||
break;
|
||||
}
|
||||
case 33: //PVRTC_RGBA4
|
||||
{
|
||||
pvrPixelFormat = 0x3;
|
||||
break;
|
||||
}
|
||||
case 34: //ETC_RGB4
|
||||
{
|
||||
pvrPixelFormat = 0x16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
Unity Studio/Unity Classes/Transform.cs
Normal file
42
Unity Studio/Unity Classes/Transform.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public class Transform
|
||||
{
|
||||
public PPtr m_GameObject = new PPtr();
|
||||
public float[] m_LocalRotation;
|
||||
public float[] m_LocalPosition;
|
||||
public float[] m_LocalScale;
|
||||
public List<PPtr> m_Children = new List<PPtr>();
|
||||
public PPtr m_Father = new PPtr();//can be transform or type 224 (as seen in Minions)
|
||||
|
||||
public Transform(AssetPreloadData preloadData)
|
||||
{
|
||||
var sourceFile = preloadData.sourceFile;
|
||||
var a_Stream = preloadData.sourceFile.a_Stream;
|
||||
a_Stream.Position = preloadData.Offset;
|
||||
|
||||
if (sourceFile.platform == -2)
|
||||
{
|
||||
uint m_ObjectHideFlags = a_Stream.ReadUInt32();
|
||||
PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
|
||||
PPtr m_PrefabInternal = sourceFile.ReadPPtr();
|
||||
}
|
||||
|
||||
m_GameObject = sourceFile.ReadPPtr();
|
||||
m_LocalRotation = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
m_LocalPosition = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
m_LocalScale = new float[] { a_Stream.ReadSingle(), a_Stream.ReadSingle(), a_Stream.ReadSingle() };
|
||||
int m_ChildrenCount = a_Stream.ReadInt32();
|
||||
for (int j = 0; j < m_ChildrenCount; j++)
|
||||
{
|
||||
m_Children.Add(sourceFile.ReadPPtr());
|
||||
}
|
||||
m_Father = sourceFile.ReadPPtr();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user