14 Commits

Author SHA1 Message Date
Perfare
3b7b88be57 0.6.5b1 2017-01-20 20:14:25 +08:00
Perfare
05fd0588e8 0.6.5 2017-01-20 01:49:46 +08:00
Perfare
f60f7ac413 fixed bug in Mesh 2017-01-17 20:59:36 +08:00
Perfare
344f69fddc Merge branch 'master' of https://github.com/Perfare/UnityStudio.git 2017-01-17 04:12:17 +08:00
Perfare
dc5691aefc - improve export MonoBehaviour
- remove some code
2017-01-17 04:12:06 +08:00
Perfare
797216fed4 Update README.md 2017-01-17 00:30:07 +08:00
Perfare
4899d6d7d0 rebuild wrapper dll 2017-01-17 00:14:20 +08:00
Perfare
8637c31311 Update README.md 2017-01-16 17:07:50 +08:00
Perfare
ac33fd5ab8 update TextureFormat 2017-01-16 16:56:04 +08:00
Perfare
8ccfbcf66a fixed bug 2017-01-16 03:44:01 +08:00
Perfare
2e84b08494 fixed GameObject in Unity 5.5 2017-01-16 02:20:30 +08:00
Perfare
08bf84146b - support export m4a AudioClip
- fixed some bug
2017-01-16 01:26:39 +08:00
Perfare
fbfdb789f5 support export MonoBehaviour 2017-01-15 23:20:40 +08:00
Perfare
dcde8902f1 support Unity 5.5 2017-01-15 19:57:41 +08:00
24 changed files with 875 additions and 341 deletions

View File

@@ -1,32 +1,42 @@
**Unity Studio** is a tool for exploring, extracting and exporting assets from Unity games and apps.
It is the continuation of my Unity Importer script for 3ds Max, and comprises all my research and reverse engineering of Unity file formats. It has been thoroughly tested with Unity builds from most platforms, ranging from Web, PC, Linux, MacOS to Xbox360, PS3, Android and iOS, and it is currently maintained to be compatible with Unity builds from 2.5.0 up to the 5.4.x version.
It is the continuation of my Unity Importer script for 3ds Max, and comprises all my research and reverse engineering of Unity file formats. It has been thoroughly tested with Unity builds from most platforms, ranging from Web, PC, Linux, MacOS to Xbox360, PS3, Android and iOS, and it is currently maintained to be compatible with Unity builds from 2.5.0 up to the 5.5 version.
#### Current features
## Current features
* Extraction of assets that can be used as standalone resources:
* Textures:
* **Texture2D**:
* DDS (Alpha8, ARGB4444, RGB24, RGBA32, ARGB32, RGB565, DXT1, DXT5, RGBA4444, BGRA32)
* PVR (YUY2, PVRTC_RGB2, PVRTC_RGBA2, PVRTC_RGB4, PVRTC_RGBA4, ETC_RGB4, ETC2_RGB, ETC2_RGBA1, ETC2_RGBA8, EAC_R, EAC_R_SIGNED, EAC_RG, EAC_RG_SIGNED)
* KTX (RHalf, RGHalf, RGBAHalf, RFloat, RGFloat, RGBAFloat, ATC_RGB4, ATC_RGBA8)
* PVR (YUY2, PVRTC_RGB2, PVRTC_RGBA2, PVRTC_RGB4, PVRTC_RGBA4, ETC_RGB4, ETC2_RGB, ETC2_RGBA1, ETC2_RGBA8)
* KTX (RHalf, RGHalf, RGBAHalf, RFloat, RGFloat, RGBAFloat, ATC_RGB4, ATC_RGBA8, EAC_R, EAC_R_SIGNED, EAC_RG, EAC_RG_SIGNED)
* ASTC (ASTC_RGB_4x4, ASTC_RGB_5x5, ASTC_RGB_6x6, ASTC_RGB_8x8, ASTC_RGB_10x10, ASTC_RGB_12x12, ASTC_RGBA_4x4, ASTC_RGBA_5x5, ASTC_RGBA_6x6, ASTC_RGBA_8x8, ASTC_RGBA_10x10, ASTC_RGBA_12x12)
* Audio clips: fsb, mp3, ogg, wav, xbox wav (including streams from resource files)
* Fonts: ttf, otf
* Text Assets
* Shaders
* Support convert almost all textures to .bmp .png or .jpeg
* **AudioClip**: fsb, mp3, ogg, wav, m4a, xbox wav (including streams from resource files)
* **Font**: ttf, otf
* **TextAsset**
* **Shader**
* **MonoBehaviour**
* Support convert almost all textures to bmp, png or jpeg
* Support convert FSB file to wav
* Export to FBX, with complete hierarchy, transformations, materials and textures. Geometry is exported with normals, tangents, UV coordinates, vertex colors and deformers. Skeleton nodes can be exported either as bones or dummy deformers..
* Real-time preview window for the above-mentioned assets
* Diagnostics mode with useful tools for research
#### UI guide
## Usage
Requirements:
- [.NET Framework 4.0](https://www.microsoft.com/en-us/download/details.aspx?id=17718)
- [Microsoft Visual C++ 2013 Redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=40784)
- [Microsoft Visual C++ 2015 Redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=53840)
## UI guide
| Item | Action
| :---------------------------- | :----------------------------
| File -> Load file/folder | Open Assetfiles and load their assets. Load file can also decompress and load bundle files straight into memory
| File -> Extract bundle/folder | Extract Assetfiles from bundle files compressed with lzma or l4z
| File -> Extract bundle/folder | Extract Assetfiles from bundle files compressed with lzma or lz4
| Scene Hierarchy search box | Search nodes using * and ? wildcards. Press Enter to loop through results or Ctrl+Enter to select all matching nodes
| Asset List filter box | Enter a keyword to filter the list of available assets; wildcards are added automatically
| Diagnostics | press Ctrl+Alt+D to bring up a hidden menu and a new list

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
//using System.Diagnostics; //remove this later
using System.Text;
namespace Unity_Studio
{
@@ -31,6 +29,7 @@ namespace Unity_Studio
public SortedDictionary<int, ClassStrStruct> ClassStructures = new SortedDictionary<int, ClassStrStruct>();
private bool baseDefinitions = false;
private List<int[]> classIDs = new List<int[]>();//use for 5.5.0
public class UnityShared
{
@@ -84,7 +83,9 @@ namespace Unity_Studio
break;
}
case 14://5.0.0 beta and final
case 15://5.0.1 and up
case 15://5.0.1 - 5.4
case 16://??.. no sure
case 17://5.5.0 and up
{
a_Stream.Position += 4;//azero
m_Version = a_Stream.ReadStringToNull();
@@ -94,7 +95,7 @@ namespace Unity_Studio
}
default:
{
//MessageBox.Show("Unsupported Unity version!", "Unity Studio Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//MessageBox.Show("Unsupported Unity version!" + fileGen, "Unity Studio Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
@@ -163,10 +164,19 @@ namespace Unity_Studio
asset.Offset = a_Stream.ReadInt32();
asset.Offset += dataOffset;
asset.Size = a_Stream.ReadInt32();
asset.Type1 = a_Stream.ReadInt32();
asset.Type2 = a_Stream.ReadUInt16();
a_Stream.Position += 2;
if (fileGen >= 15)
if (fileGen > 15)
{
int index = a_Stream.ReadInt32();
asset.Type1 = classIDs[index][0];
asset.Type2 = (ushort)classIDs[index][1];
}
else
{
asset.Type1 = a_Stream.ReadInt32();
asset.Type2 = a_Stream.ReadUInt16();
a_Stream.Position += 2;
}
if (fileGen == 15)
{
byte unknownByte = a_Stream.ReadByte();
//this is a single byte, not an int32
@@ -184,7 +194,7 @@ namespace Unity_Studio
}
else
{
asset.TypeString = "unknown";
asset.TypeString = "Unknown Type " + asset.Type2;
}
asset.uniqueID = i.ToString(assetIDfmt);
@@ -258,68 +268,127 @@ namespace Unity_Studio
{
int classID = a_Stream.ReadInt32();
if (classID < 0) { a_Stream.Position += 16; }
if (fileGen > 15)
{
a_Stream.ReadByte();
int type1;
if ((type1 = a_Stream.ReadInt16()) >= 0)
{
type1 = -1 - type1;
a_Stream.Position += 16;
}
else
{
type1 = classID;
}
classIDs.Add(new int[] { type1, classID });
classID = type1;
}
a_Stream.Position += 16;
if (baseDefinitions)
{
#region cmmon string array
string[] baseStrings = new string[1007];
string[] baseStrings = new string[1016];
baseStrings[0] = "AABB";
baseStrings[5] = "AnimationClip";
baseStrings[19] = "AnimationCurve";
baseStrings[34] = "AnimationState";
baseStrings[49] = "Array";
baseStrings[55] = "Base";
baseStrings[60] = "BitField";
baseStrings[69] = "bitset";
baseStrings[76] = "bool";
baseStrings[81] = "char";
baseStrings[86] = "ColorRGBA";
baseStrings[96] = "Component";
baseStrings[106] = "data";
baseStrings[111] = "deque";
baseStrings[117] = "double";
baseStrings[124] = "dynamic_array";
baseStrings[138] = "FastPropertyName";
baseStrings[155] = "first";
baseStrings[161] = "float";
baseStrings[167] = "Font";
baseStrings[172] = "GameObject";
baseStrings[183] = "Generic Mono";
baseStrings[196] = "GradientNEW";
baseStrings[208] = "GUID";
baseStrings[213] = "GUIStyle";
baseStrings[222] = "int";
baseStrings[226] = "list";
baseStrings[231] = "long long";
baseStrings[241] = "map";
baseStrings[245] = "Matrix4x4f";
baseStrings[262] = "NavMeshSettings";
baseStrings[256] = "MdFour";
baseStrings[263] = "MonoBehaviour";
baseStrings[277] = "MonoScript";
baseStrings[288] = "m_ByteSize";
baseStrings[299] = "m_Curve";
baseStrings[307] = "m_EditorClassIdentifier";
baseStrings[331] = "m_EditorHideFlags";
baseStrings[349] = "m_Enabled";
baseStrings[359] = "m_ExtensionPtr";
baseStrings[374] = "m_GameObject";
baseStrings[387] = "m_Index";
baseStrings[395] = "m_IsArray";
baseStrings[405] = "m_IsStatic";
baseStrings[416] = "m_MetaFlag";
baseStrings[427] = "m_Name";
baseStrings[434] = "m_ObjectHideFlags";
baseStrings[452] = "m_PrefabInternal";
baseStrings[469] = "m_PrefabParentObject";
baseStrings[490] = "m_Script";
baseStrings[499] = "m_StaticEditorFlags";
baseStrings[519] = "m_Type";
baseStrings[526] = "m_Version";
baseStrings[536] = "Object";
baseStrings[543] = "pair";
baseStrings[548] = "PPtr<Component>";
baseStrings[564] = "PPtr<GameObject>";
baseStrings[581] = "PPtr<Material>";
baseStrings[596] = "PPtr<MonoBehaviour>";
baseStrings[616] = "PPtr<MonoScript>";
baseStrings[633] = "PPtr<Object>";
baseStrings[646] = "PPtr<Prefab>";
baseStrings[659] = "PPtr<Sprite>";
baseStrings[672] = "PPtr<TextAsset>";
baseStrings[688] = "PPtr<Texture>";
baseStrings[702] = "PPtr<Texture2D>";
baseStrings[718] = "PPtr<Transform>";
baseStrings[734] = "Prefab";
baseStrings[741] = "Quaternionf";
baseStrings[753] = "Rectf";
baseStrings[759] = "RectInt";
baseStrings[767] = "RectOffset";
baseStrings[778] = "second";
baseStrings[785] = "set";
baseStrings[789] = "short";
baseStrings[795] = "size";
baseStrings[800] = "SInt16";
baseStrings[814] = "int64";
baseStrings[807] = "SInt32";
baseStrings[814] = "SInt64";
baseStrings[821] = "SInt8";
baseStrings[827] = "staticvector";
baseStrings[840] = "string";
baseStrings[847] = "TextAsset";
baseStrings[857] = "TextMesh";
baseStrings[866] = "Texture";
baseStrings[874] = "Texture2D";
baseStrings[884] = "Transform";
baseStrings[894] = "TypelessData";
baseStrings[907] = "UInt16";
baseStrings[914] = "UInt32";
baseStrings[921] = "UInt64";
baseStrings[928] = "UInt8";
baseStrings[934] = "unsigned int";
baseStrings[947] = "unsigned long long";
baseStrings[966] = "unsigned short";
baseStrings[981] = "vector";
baseStrings[988] = "Vector2f";
baseStrings[997] = "Vector3f";
baseStrings[1006] = "Vector4f";
baseStrings[1015] = "m_ScriptingClassIdentifier";
#endregion
int varCount = a_Stream.ReadInt32();
@@ -328,8 +397,8 @@ namespace Unity_Studio
a_Stream.Position += varCount * 24;
string varStrings = Encoding.UTF8.GetString(a_Stream.ReadBytes(stringSize));
string className = "";
StringBuilder classVarStr = new StringBuilder();
var classVarStr = new StringBuilder();
var classVarStr2 = new StringBuilder();//用来export
//build Class Structures
a_Stream.Position -= varCount * 24 + stringSize;
for (int i = 0; i < varCount; i++)
@@ -357,18 +426,21 @@ namespace Unity_Studio
int num1 = a_Stream.ReadInt32();
if (index == 0) { className = varTypeStr + " " + varNameStr; }
else { classVarStr.AppendFormat("{0}{1} {2} {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, size); }
else
{
classVarStr.AppendFormat("{0}{1} {2} {3}\r\n", (new string('\t', level - 1)), varTypeStr, varNameStr, size);
classVarStr2.AppendFormat("{0}\t{1}\t{2}\r\n", level - 1, varTypeStr, varNameStr);
}
//for (int t = 0; t < level; t++) { Debug.Write("\t"); }
//Debug.WriteLine(varTypeStr + " " + varNameStr + " " + size);
}
a_Stream.Position += stringSize;
var aClass = new ClassStrStruct() { ID = classID, Text = className, members = classVarStr.ToString() };
var aClass = new ClassStrStruct() { ID = classID, Text = className, members = classVarStr.ToString(), members2 = classVarStr2.ToString() };
aClass.SubItems.Add(classID.ToString());
ClassStructures.Add(classID, aClass);
}
}
}

View File

@@ -10,6 +10,7 @@ namespace Unity_Studio
{
public int ID;
public string members;
public string members2;
}
public class ClassIDReference
@@ -208,6 +209,9 @@ namespace Unity_Studio
Names[272] = "AudioMixerSnapshot";
Names[273] = "AudioMixerGroup";
Names[290] = "AssetBundleManifest";
Names[300] = "RuntimeInitializeOnLoadManager";
Names[301] = "CloudWebServicesManager";
Names[310] = "UnityConnectSettings";
Names[1001] = "Prefab";
Names[1002] = "EditorExtensionImpl";
Names[1003] = "AssetImporter";

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
@@ -21,41 +20,9 @@ namespace Unity_Studio
public EndianStream(Stream stream, EndianType endian) : base(stream) { }
~EndianStream()
{
Dispose();
}
public long Position { get { return base.BaseStream.Position; } set { base.BaseStream.Position = value; } }
public new void Dispose()
{
base.Dispose();
}
public override bool ReadBoolean()
{
return base.ReadBoolean();
}
public override byte ReadByte()
{
try
{
return base.ReadByte();
}
catch
{
return 0;
}
}
public override char ReadChar()
{
return base.ReadChar();
}
public override Int16 ReadInt16()
public override short ReadInt16()
{
if (endian == EndianType.BigEndian)
{
@@ -65,7 +32,7 @@ namespace Unity_Studio
}
else return base.ReadInt16();
}
public override int ReadInt32()
{
if (endian == EndianType.BigEndian)
@@ -76,8 +43,8 @@ namespace Unity_Studio
}
else return base.ReadInt32();
}
public override Int64 ReadInt64()
public override long ReadInt64()
{
if (endian == EndianType.BigEndian)
{
@@ -87,8 +54,8 @@ namespace Unity_Studio
}
else return base.ReadInt64();
}
public override UInt16 ReadUInt16()
public override ushort ReadUInt16()
{
if (endian == EndianType.BigEndian)
{
@@ -98,8 +65,8 @@ namespace Unity_Studio
}
else return base.ReadUInt16();
}
public override UInt32 ReadUInt32()
public override uint ReadUInt32()
{
if (endian == EndianType.BigEndian)
{
@@ -110,7 +77,7 @@ namespace Unity_Studio
else return base.ReadUInt32();
}
public override UInt64 ReadUInt64()
public override ulong ReadUInt64()
{
if (endian == EndianType.BigEndian)
{
@@ -120,8 +87,8 @@ namespace Unity_Studio
}
else return base.ReadUInt64();
}
public override Single ReadSingle()
public override float ReadSingle()
{
if (endian == EndianType.BigEndian)
{
@@ -131,8 +98,8 @@ namespace Unity_Studio
}
else return base.ReadSingle();
}
public override Double ReadDouble()
public override double ReadDouble()
{
if (endian == EndianType.BigEndian)
{
@@ -143,14 +110,9 @@ namespace Unity_Studio
else return base.ReadDouble();
}
public override string ReadString()
{
return base.ReadString();
}
public string ReadASCII(int length)
{
return ASCIIEncoding.ASCII.GetString(base.ReadBytes(length));
return Encoding.ASCII.GetString(base.ReadBytes(length));
}
public void AlignStream(int alignment)
@@ -167,7 +129,7 @@ namespace Unity_Studio
{
byte[] stringData = new byte[length];
base.Read(stringData, 0, length);
var result = System.Text.Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3
var result = Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3
/*string result = "";
char c;
@@ -182,20 +144,14 @@ namespace Unity_Studio
}
else { return ""; }
}
public string ReadStringToNull()
{
string result = "";
char c;
for (int i = 0; i < base.BaseStream.Length; i++)
{
if ((c = (char)base.ReadByte()) == 0)
{
break;
}
result += c.ToString();
}
return result;
var bytes = new List<byte>();
byte b;
while ((b = ReadByte()) != 0)
bytes.Add(b);
return Encoding.UTF8.GetString(bytes.ToArray());
}
}
}

View File

@@ -72,9 +72,11 @@
this.includeBox.Controls.Add(this.camerasBox);
this.includeBox.Controls.Add(this.exportDeformers);
this.includeBox.Controls.Add(this.geometryBox);
this.includeBox.Location = new System.Drawing.Point(12, 12);
this.includeBox.Location = new System.Drawing.Point(16, 15);
this.includeBox.Margin = new System.Windows.Forms.Padding(4);
this.includeBox.Name = "includeBox";
this.includeBox.Size = new System.Drawing.Size(249, 266);
this.includeBox.Padding = new System.Windows.Forms.Padding(4);
this.includeBox.Size = new System.Drawing.Size(332, 334);
this.includeBox.TabIndex = 0;
this.includeBox.TabStop = false;
this.includeBox.Text = "Include";
@@ -82,9 +84,10 @@
// convertDummies
//
this.convertDummies.AutoSize = true;
this.convertDummies.Location = new System.Drawing.Point(14, 164);
this.convertDummies.Location = new System.Drawing.Point(19, 205);
this.convertDummies.Margin = new System.Windows.Forms.Padding(4);
this.convertDummies.Name = "convertDummies";
this.convertDummies.Size = new System.Drawing.Size(228, 16);
this.convertDummies.Size = new System.Drawing.Size(302, 20);
this.convertDummies.TabIndex = 5;
this.convertDummies.Text = "Convert Deforming Dummies to Bones";
this.convertDummies.UseVisualStyleBackColor = true;
@@ -94,9 +97,10 @@
//
this.embedBox.AutoSize = true;
this.embedBox.Enabled = false;
this.embedBox.Location = new System.Drawing.Point(14, 230);
this.embedBox.Location = new System.Drawing.Point(19, 288);
this.embedBox.Margin = new System.Windows.Forms.Padding(4);
this.embedBox.Name = "embedBox";
this.embedBox.Size = new System.Drawing.Size(90, 16);
this.embedBox.Size = new System.Drawing.Size(118, 20);
this.embedBox.TabIndex = 4;
this.embedBox.Text = "Embed Media";
this.embedBox.UseVisualStyleBackColor = true;
@@ -105,9 +109,10 @@
//
this.lightsBox.AutoSize = true;
this.lightsBox.Enabled = false;
this.lightsBox.Location = new System.Drawing.Point(14, 208);
this.lightsBox.Location = new System.Drawing.Point(19, 260);
this.lightsBox.Margin = new System.Windows.Forms.Padding(4);
this.lightsBox.Name = "lightsBox";
this.lightsBox.Size = new System.Drawing.Size(60, 16);
this.lightsBox.Size = new System.Drawing.Size(78, 20);
this.lightsBox.TabIndex = 3;
this.lightsBox.Text = "Lights";
this.lightsBox.UseVisualStyleBackColor = true;
@@ -116,9 +121,10 @@
//
this.camerasBox.AutoSize = true;
this.camerasBox.Enabled = false;
this.camerasBox.Location = new System.Drawing.Point(14, 186);
this.camerasBox.Location = new System.Drawing.Point(19, 232);
this.camerasBox.Margin = new System.Windows.Forms.Padding(4);
this.camerasBox.Name = "camerasBox";
this.camerasBox.Size = new System.Drawing.Size(66, 16);
this.camerasBox.Size = new System.Drawing.Size(86, 20);
this.camerasBox.TabIndex = 2;
this.camerasBox.Text = "Cameras";
this.camerasBox.UseVisualStyleBackColor = true;
@@ -126,9 +132,10 @@
// exportDeformers
//
this.exportDeformers.AutoSize = true;
this.exportDeformers.Location = new System.Drawing.Point(14, 142);
this.exportDeformers.Location = new System.Drawing.Point(19, 178);
this.exportDeformers.Margin = new System.Windows.Forms.Padding(4);
this.exportDeformers.Name = "exportDeformers";
this.exportDeformers.Size = new System.Drawing.Size(108, 16);
this.exportDeformers.Size = new System.Drawing.Size(142, 20);
this.exportDeformers.TabIndex = 1;
this.exportDeformers.Text = "Skin Deformers";
this.exportDeformers.UseVisualStyleBackColor = true;
@@ -141,9 +148,11 @@
this.geometryBox.Controls.Add(this.exportUVs);
this.geometryBox.Controls.Add(this.exportTangents);
this.geometryBox.Controls.Add(this.exportNormals);
this.geometryBox.Location = new System.Drawing.Point(7, 18);
this.geometryBox.Location = new System.Drawing.Point(9, 22);
this.geometryBox.Margin = new System.Windows.Forms.Padding(4);
this.geometryBox.Name = "geometryBox";
this.geometryBox.Size = new System.Drawing.Size(235, 121);
this.geometryBox.Padding = new System.Windows.Forms.Padding(4);
this.geometryBox.Size = new System.Drawing.Size(313, 161);
this.geometryBox.TabIndex = 0;
this.geometryBox.TabStop = false;
this.geometryBox.Text = "Geometry";
@@ -153,9 +162,10 @@
this.exportColors.AutoSize = true;
this.exportColors.Checked = true;
this.exportColors.CheckState = System.Windows.Forms.CheckState.Checked;
this.exportColors.Location = new System.Drawing.Point(7, 85);
this.exportColors.Location = new System.Drawing.Point(9, 106);
this.exportColors.Margin = new System.Windows.Forms.Padding(4);
this.exportColors.Name = "exportColors";
this.exportColors.Size = new System.Drawing.Size(102, 16);
this.exportColors.Size = new System.Drawing.Size(134, 20);
this.exportColors.TabIndex = 3;
this.exportColors.Text = "Vertex Colors";
this.exportColors.UseVisualStyleBackColor = true;
@@ -166,9 +176,10 @@
this.exportUVs.AutoSize = true;
this.exportUVs.Checked = true;
this.exportUVs.CheckState = System.Windows.Forms.CheckState.Checked;
this.exportUVs.Location = new System.Drawing.Point(7, 63);
this.exportUVs.Location = new System.Drawing.Point(9, 79);
this.exportUVs.Margin = new System.Windows.Forms.Padding(4);
this.exportUVs.Name = "exportUVs";
this.exportUVs.Size = new System.Drawing.Size(108, 16);
this.exportUVs.Size = new System.Drawing.Size(142, 20);
this.exportUVs.TabIndex = 2;
this.exportUVs.Text = "UV Coordinates";
this.exportUVs.UseVisualStyleBackColor = true;
@@ -177,9 +188,10 @@
// exportTangents
//
this.exportTangents.AutoSize = true;
this.exportTangents.Location = new System.Drawing.Point(7, 41);
this.exportTangents.Location = new System.Drawing.Point(9, 51);
this.exportTangents.Margin = new System.Windows.Forms.Padding(4);
this.exportTangents.Name = "exportTangents";
this.exportTangents.Size = new System.Drawing.Size(72, 16);
this.exportTangents.Size = new System.Drawing.Size(94, 20);
this.exportTangents.TabIndex = 1;
this.exportTangents.Text = "Tangents";
this.exportTangents.UseVisualStyleBackColor = true;
@@ -190,9 +202,10 @@
this.exportNormals.AutoSize = true;
this.exportNormals.Checked = true;
this.exportNormals.CheckState = System.Windows.Forms.CheckState.Checked;
this.exportNormals.Location = new System.Drawing.Point(7, 18);
this.exportNormals.Location = new System.Drawing.Point(9, 22);
this.exportNormals.Margin = new System.Windows.Forms.Padding(4);
this.exportNormals.Name = "exportNormals";
this.exportNormals.Size = new System.Drawing.Size(66, 16);
this.exportNormals.Size = new System.Drawing.Size(86, 20);
this.exportNormals.TabIndex = 0;
this.exportNormals.Text = "Normals";
this.exportNormals.UseVisualStyleBackColor = true;
@@ -205,9 +218,11 @@
this.advancedBox.Controls.Add(this.upAxis);
this.advancedBox.Controls.Add(this.scaleFactor);
this.advancedBox.Controls.Add(this.scaleLabel);
this.advancedBox.Location = new System.Drawing.Point(12, 284);
this.advancedBox.Location = new System.Drawing.Point(16, 355);
this.advancedBox.Margin = new System.Windows.Forms.Padding(4);
this.advancedBox.Name = "advancedBox";
this.advancedBox.Size = new System.Drawing.Size(249, 77);
this.advancedBox.Padding = new System.Windows.Forms.Padding(4);
this.advancedBox.Size = new System.Drawing.Size(332, 96);
this.advancedBox.TabIndex = 5;
this.advancedBox.TabStop = false;
this.advancedBox.Text = "Advanced Options";
@@ -215,9 +230,10 @@
// axisLabel
//
this.axisLabel.AutoSize = true;
this.axisLabel.Location = new System.Drawing.Point(6, 40);
this.axisLabel.Location = new System.Drawing.Point(8, 50);
this.axisLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.axisLabel.Name = "axisLabel";
this.axisLabel.Size = new System.Drawing.Size(53, 12);
this.axisLabel.Size = new System.Drawing.Size(72, 16);
this.axisLabel.TabIndex = 3;
this.axisLabel.Text = "Up Axis:";
//
@@ -226,10 +242,11 @@
this.upAxis.FormattingEnabled = true;
this.upAxis.Items.AddRange(new object[] {
"Y-up"});
this.upAxis.Location = new System.Drawing.Point(58, 37);
this.upAxis.Location = new System.Drawing.Point(88, 47);
this.upAxis.Margin = new System.Windows.Forms.Padding(4);
this.upAxis.MaxDropDownItems = 2;
this.upAxis.Name = "upAxis";
this.upAxis.Size = new System.Drawing.Size(70, 20);
this.upAxis.Size = new System.Drawing.Size(92, 23);
this.upAxis.TabIndex = 2;
//
// scaleFactor
@@ -240,9 +257,10 @@
0,
0,
131072});
this.scaleFactor.Location = new System.Drawing.Point(82, 13);
this.scaleFactor.Location = new System.Drawing.Point(128, 17);
this.scaleFactor.Margin = new System.Windows.Forms.Padding(4);
this.scaleFactor.Name = "scaleFactor";
this.scaleFactor.Size = new System.Drawing.Size(46, 21);
this.scaleFactor.Size = new System.Drawing.Size(61, 25);
this.scaleFactor.TabIndex = 1;
this.scaleFactor.Value = new decimal(new int[] {
254,
@@ -253,17 +271,19 @@
// scaleLabel
//
this.scaleLabel.AutoSize = true;
this.scaleLabel.Location = new System.Drawing.Point(6, 15);
this.scaleLabel.Location = new System.Drawing.Point(8, 19);
this.scaleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.scaleLabel.Name = "scaleLabel";
this.scaleLabel.Size = new System.Drawing.Size(83, 12);
this.scaleLabel.Size = new System.Drawing.Size(112, 16);
this.scaleLabel.TabIndex = 0;
this.scaleLabel.Text = "Scale Factor:";
//
// fbxOKbutton
//
this.fbxOKbutton.Location = new System.Drawing.Point(332, 364);
this.fbxOKbutton.Location = new System.Drawing.Point(443, 455);
this.fbxOKbutton.Margin = new System.Windows.Forms.Padding(4);
this.fbxOKbutton.Name = "fbxOKbutton";
this.fbxOKbutton.Size = new System.Drawing.Size(75, 21);
this.fbxOKbutton.Size = new System.Drawing.Size(100, 26);
this.fbxOKbutton.TabIndex = 6;
this.fbxOKbutton.Text = "OK";
this.fbxOKbutton.UseVisualStyleBackColor = true;
@@ -272,9 +292,10 @@
// fbxCancel
//
this.fbxCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.fbxCancel.Location = new System.Drawing.Point(420, 364);
this.fbxCancel.Location = new System.Drawing.Point(560, 455);
this.fbxCancel.Margin = new System.Windows.Forms.Padding(4);
this.fbxCancel.Name = "fbxCancel";
this.fbxCancel.Size = new System.Drawing.Size(75, 21);
this.fbxCancel.Size = new System.Drawing.Size(100, 26);
this.fbxCancel.TabIndex = 7;
this.fbxCancel.Text = "Cancel";
this.fbxCancel.UseVisualStyleBackColor = true;
@@ -288,9 +309,10 @@
// showExpOpt
//
this.showExpOpt.AutoSize = true;
this.showExpOpt.Location = new System.Drawing.Point(12, 367);
this.showExpOpt.Location = new System.Drawing.Point(16, 459);
this.showExpOpt.Margin = new System.Windows.Forms.Padding(4);
this.showExpOpt.Name = "showExpOpt";
this.showExpOpt.Size = new System.Drawing.Size(222, 16);
this.showExpOpt.Size = new System.Drawing.Size(294, 20);
this.showExpOpt.TabIndex = 8;
this.showExpOpt.Text = "Show this dialog for every export";
this.showExpOpt.UseVisualStyleBackColor = true;
@@ -300,9 +322,11 @@
this.groupBox1.Controls.Add(this.convertfsb);
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Controls.Add(this.converttexture);
this.groupBox1.Location = new System.Drawing.Point(267, 12);
this.groupBox1.Location = new System.Drawing.Point(356, 15);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(228, 349);
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
this.groupBox1.Size = new System.Drawing.Size(304, 436);
this.groupBox1.TabIndex = 9;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Convert";
@@ -312,9 +336,10 @@
this.convertfsb.AutoSize = true;
this.convertfsb.Checked = true;
this.convertfsb.CheckState = System.Windows.Forms.CheckState.Checked;
this.convertfsb.Location = new System.Drawing.Point(8, 81);
this.convertfsb.Location = new System.Drawing.Point(11, 101);
this.convertfsb.Margin = new System.Windows.Forms.Padding(4);
this.convertfsb.Name = "convertfsb";
this.convertfsb.Size = new System.Drawing.Size(132, 16);
this.convertfsb.Size = new System.Drawing.Size(174, 20);
this.convertfsb.TabIndex = 6;
this.convertfsb.Text = "Convert FSB to WAV";
this.convertfsb.UseVisualStyleBackColor = true;
@@ -324,17 +349,19 @@
this.panel1.Controls.Add(this.tojpg);
this.panel1.Controls.Add(this.topng);
this.panel1.Controls.Add(this.tobmp);
this.panel1.Location = new System.Drawing.Point(30, 42);
this.panel1.Location = new System.Drawing.Point(40, 52);
this.panel1.Margin = new System.Windows.Forms.Padding(4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(146, 30);
this.panel1.Size = new System.Drawing.Size(195, 38);
this.panel1.TabIndex = 5;
//
// tojpg
//
this.tojpg.AutoSize = true;
this.tojpg.Location = new System.Drawing.Point(97, 6);
this.tojpg.Location = new System.Drawing.Point(129, 8);
this.tojpg.Margin = new System.Windows.Forms.Padding(4);
this.tojpg.Name = "tojpg";
this.tojpg.Size = new System.Drawing.Size(47, 16);
this.tojpg.Size = new System.Drawing.Size(61, 20);
this.tojpg.TabIndex = 4;
this.tojpg.Text = "JPEG";
this.tojpg.UseVisualStyleBackColor = true;
@@ -343,9 +370,10 @@
//
this.topng.AutoSize = true;
this.topng.Checked = true;
this.topng.Location = new System.Drawing.Point(50, 6);
this.topng.Location = new System.Drawing.Point(67, 8);
this.topng.Margin = new System.Windows.Forms.Padding(4);
this.topng.Name = "topng";
this.topng.Size = new System.Drawing.Size(41, 16);
this.topng.Size = new System.Drawing.Size(53, 20);
this.topng.TabIndex = 3;
this.topng.TabStop = true;
this.topng.Text = "PNG";
@@ -354,9 +382,10 @@
// tobmp
//
this.tobmp.AutoSize = true;
this.tobmp.Location = new System.Drawing.Point(3, 6);
this.tobmp.Location = new System.Drawing.Point(4, 8);
this.tobmp.Margin = new System.Windows.Forms.Padding(4);
this.tobmp.Name = "tobmp";
this.tobmp.Size = new System.Drawing.Size(41, 16);
this.tobmp.Size = new System.Drawing.Size(53, 20);
this.tobmp.TabIndex = 2;
this.tobmp.Text = "BMP";
this.tobmp.UseVisualStyleBackColor = true;
@@ -366,9 +395,10 @@
this.converttexture.AutoSize = true;
this.converttexture.Checked = true;
this.converttexture.CheckState = System.Windows.Forms.CheckState.Checked;
this.converttexture.Location = new System.Drawing.Point(8, 20);
this.converttexture.Location = new System.Drawing.Point(11, 25);
this.converttexture.Margin = new System.Windows.Forms.Padding(4);
this.converttexture.Name = "converttexture";
this.converttexture.Size = new System.Drawing.Size(192, 16);
this.converttexture.Size = new System.Drawing.Size(254, 20);
this.converttexture.TabIndex = 1;
this.converttexture.Text = "Convert Texture (If support)";
this.converttexture.UseVisualStyleBackColor = true;
@@ -376,10 +406,10 @@
// ExportOptions
//
this.AcceptButton = this.fbxOKbutton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.fbxCancel;
this.ClientSize = new System.Drawing.Size(513, 392);
this.ClientSize = new System.Drawing.Size(684, 490);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.showExpOpt);
this.Controls.Add(this.fbxCancel);
@@ -387,6 +417,7 @@
this.Controls.Add(this.advancedBox);
this.Controls.Add(this.includeBox);
this.HelpButton = true;
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ExportOptions";

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.4.0")]
[assembly: AssemblyFileVersion("0.6.4.0")]
[assembly: AssemblyVersion("0.6.5.0")]
[assembly: AssemblyFileVersion("0.6.5.0")]

View File

@@ -164,9 +164,13 @@ namespace Unity_Studio
preloadData.extension = ".fsb";
preloadData.InfoText += "MP3";//not sure
break;
case 7:
preloadData.extension = ".m4a";
preloadData.InfoText += "M4a";
break;
}
if (preloadData.extension == "")
if (preloadData.extension == null)
{
preloadData.extension = ".AudioClip";
preloadData.InfoText += "Unknown";

View File

@@ -27,107 +27,162 @@ namespace Unity_Studio
if (readSwitch)
{
int m_AsciiStartOffset = a_Stream.ReadInt32();
if (sourceFile.version[0] <= 3)
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)
{
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++)
var m_LineSpacing = a_Stream.ReadSingle();
var m_DefaultMaterial = sourceFile.ReadPPtr();
var m_FontSize = a_Stream.ReadSingle();
var m_Texture = sourceFile.ReadPPtr();
int m_AsciiStartOffset = a_Stream.ReadInt32();
var m_Tracking = a_Stream.ReadSingle();
var m_CharacterSpacing = a_Stream.ReadInt32();
var m_CharacterPadding = a_Stream.ReadInt32();
var m_ConvertCase = a_Stream.ReadInt32();
int m_CharacterRects_size = a_Stream.ReadInt32();
for (int i = 0; i < m_CharacterRects_size; i++)
{
int first = a_Stream.ReadInt32();
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;
}
}
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();
}
var 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)
{ preloadData.extension = ".otf"; }
else { preloadData.extension = ".ttf"; }
}
}
else
{
int m_CharacterSpacing = a_Stream.ReadInt32();
int m_CharacterPadding = a_Stream.ReadInt32();
}
int m_AsciiStartOffset = a_Stream.ReadInt32();
int m_ConvertCase = a_Stream.ReadInt32();
PPtr m_DefaultMaterial = sourceFile.ReadPPtr();
if (sourceFile.version[0] <= 3)
{
int m_FontCountX = a_Stream.ReadInt32();
int m_FontCountY = a_Stream.ReadInt32();
}
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();
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)
{ preloadData.extension = ".otf"; }
else { preloadData.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)
{
bool flipped = a_Stream.ReadBoolean();
a_Stream.Position += 3;
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();
}
}
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)
{ preloadData.extension = ".otf"; }
else { preloadData.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();
}
}
else
{

View File

@@ -8,15 +8,16 @@ namespace Unity_Studio
{
public class GameObject : TreeNode
{
public List<PPtr> m_Components = new List<PPtr>();
public PPtr m_Transform;
public PPtr m_Renderer;
public PPtr m_MeshRenderer;
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)
@@ -39,25 +40,14 @@ namespace Unity_Studio
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)
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
{
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_Components.Add(sourceFile.ReadPPtr());
}
else
{
int first = a_Stream.ReadInt32();
m_Components.Add(sourceFile.ReadPPtr());
}
}
@@ -67,7 +57,7 @@ namespace Unity_Studio
if (m_Name == "") { m_Name = "GameObject #" + uniqueID; }
m_Tag = a_Stream.ReadUInt16();
m_IsActive = a_Stream.ReadBoolean();
base.Text = m_Name;
preloadData.Text = m_Name;
//name should be unique

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace Unity_Studio
{
class Renderer
class MeshRenderer
{
public PPtr m_GameObject;
public bool m_Enabled;
@@ -15,7 +15,7 @@ namespace Unity_Studio
public ushort m_LightmapIndexDynamic;
public PPtr[] m_Materials;
public Renderer(AssetPreloadData preloadData)
public MeshRenderer(AssetPreloadData preloadData)
{
var sourceFile = preloadData.sourceFile;
var a_Stream = preloadData.sourceFile.a_Stream;

View File

@@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Unity_Studio
{
class MonoBehaviour
{
public string serializedText;
public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch)
{
var sourceFile = preloadData.sourceFile;
var a_Stream = preloadData.sourceFile.a_Stream;
a_Stream.Position = preloadData.Offset;
var m_GameObject = sourceFile.ReadPPtr();
var m_Enabled = a_Stream.ReadByte();
a_Stream.AlignStream(4);
var m_Script = sourceFile.ReadPPtr();
var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
if (readSwitch)
{
preloadData.extension = ".txt";
a_Stream.Position = preloadData.Offset;
ClassStrStruct classStructure;
if (sourceFile.ClassStructures.TryGetValue(preloadData.Type1, out classStructure))
{
var member = classStructure.members2;
var strs = member.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
var sb = new StringBuilder();
Read(sb, strs, a_Stream);
serializedText = sb.ToString();
}
else
{
var str = "PPtr<GameObject> m_GameObject\r\n";
str += "\tint m_FileID = " + m_GameObject.m_FileID + "\r\n";
str += "\tint64 m_PathID = " + m_GameObject.m_PathID + "\r\n";
str += "UInt8 m_Enabled = " + m_Enabled + "\r\n";
str += "PPtr<MonoScript> m_Script\r\n";
str += "\tint m_FileID = " + m_Script.m_FileID + "\r\n";
str += "\tint64 m_PathID = " + m_Script.m_PathID + "\r\n";
str += "string m_Name = \"" + m_Name + "\"\r\n";
serializedText = str;
}
}
else
{
if (m_Name != "")
{
preloadData.Text = m_Name;
}
else
{
preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID;
}
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.Size.ToString() });
}
}
private void Read(StringBuilder sb, string[] strs, EndianStream a_Stream)
{
for (int i = 0; i < strs.Length; i++)
{
var strs2 = strs[i].Split('\t');
var level = int.Parse(strs2[0]);
var varTypeStr = strs2[1];
var varNameStr = strs2[2];
if (varTypeStr == "SInt8")//sbyte
{
var value = a_Stream.ReadSByte();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "UInt8")//byte
{
var value = a_Stream.ReadByte();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "short" || varTypeStr == "SInt16")//Int16
{
var value = a_Stream.ReadInt16();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "UInt16" || varTypeStr == "unsigned short")//UInt16
{
var value = a_Stream.ReadUInt16();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "int" || varTypeStr == "SInt32")//Int32
{
var value = a_Stream.ReadInt32();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "UInt32" || varTypeStr == "unsigned int")//UInt32
{
var value = a_Stream.ReadUInt32();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "long long" || varTypeStr == "SInt64")//Int64
{
var value = a_Stream.ReadInt64();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "UInt64" || varTypeStr == "unsigned long long")//UInt64
{
var value = a_Stream.ReadUInt64();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "float")//float
{
var value = a_Stream.ReadSingle();
sb.AppendFormat("{0}{1} {2} = {3:f}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "double")//double
{
var value = a_Stream.ReadDouble();
sb.AppendFormat("{0}{1} {2} = {3:f4}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "bool")//bool
{
var value = a_Stream.ReadBoolean();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
a_Stream.AlignStream(4);
}
else if (varTypeStr == "string")//string
{
var value = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
sb.AppendFormat("{0}{1} {2} = \"{3}\"\r\n", (new string('\t', level)), varTypeStr, varNameStr, value);
i += 3;//skip
}
else if (varTypeStr == "Array")//Array
{
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
var size = a_Stream.ReadInt32();
sb.AppendFormat("{0}{1} {2} = {3}\r\n", (new string('\t', level)), "int", "size", size);
var array = ReadArray(strs, level, i);
for (int j = 0; j < size; j++)
{
sb.AppendFormat("{0}[{1}]\r\n", (new string('\t', level + 1)), j);
Read(sb, array, a_Stream);
}
i += array.Length + 1;//skip
}
else
{
sb.AppendFormat("{0}{1} {2}\r\n", (new string('\t', level)), varTypeStr, varNameStr);
}
}
}
private string[] ReadArray(string[] strs, int level, int index)
{
List<string> strs3 = new List<string>();
for (int i = index + 2; i < strs.Length; i++)//skip int size
{
var strs2 = strs[i].Split('\t');
var level2 = int.Parse(strs2[0]);
if (level2 <= level)
{
return strs3.ToArray();
}
else
{
strs3.Add(strs[i]);
}
}
return strs3.ToArray();
}
}
}

View File

@@ -16,6 +16,15 @@ namespace Unity_Studio
var a_Stream = preloadData.sourceFile.a_Stream;
a_Stream.Position = preloadData.Offset;
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 nad up
{
//productGUID
a_Stream.ReadInt32();
a_Stream.ReadInt32();
a_Stream.ReadInt32();
a_Stream.ReadInt32();
}
if (sourceFile.version[0] >= 3)
{
if (sourceFile.version[0] == 3 && sourceFile.version[1] < 2) { string AndroidLicensePublicKey = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); }

View File

@@ -0,0 +1,73 @@
using System.Text;
namespace Unity_Studio
{
class Shader
{
public string m_Name;
public byte[] m_Script;
public string m_PathName;
public Shader(AssetPreloadData preloadData, bool readSwitch)
{
var sourceFile = preloadData.sourceFile;
var a_Stream = preloadData.sourceFile.a_Stream;
a_Stream.Position = preloadData.Offset;
preloadData.extension = ".txt";
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 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)
{
if (readSwitch)
{
m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
}
else
{
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.exportSize.ToString() });
}
}
else
{
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)) { preloadData.extension = ".xml"; }
}
else
{
byte lzmaTest = a_Stream.ReadByte();
if (lzmaTest == 93)
{
a_Stream.Position += 4;
preloadData.exportSize = a_Stream.ReadInt32(); //actualy int64
a_Stream.Position -= 8;
}
else { preloadData.exportSize = m_Script_size; }
a_Stream.Position += m_Script_size - 1;
if (m_Name != "") { preloadData.Text = m_Name; }
else { preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID; }
preloadData.SubItems.AddRange(new string[] { preloadData.TypeString, preloadData.exportSize.ToString() });
}
a_Stream.AlignStream(4);
m_PathName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
}
}
}
}

View File

@@ -60,14 +60,29 @@ namespace Unity_Studio
m_Materials[m] = sourceFile.ReadPPtr();
}
if (version[0] < 3) { a_Stream.Position += 16; } //m_LightmapTilingOffset vector4d
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;
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up
{
a_Stream.Position += 4;//m_StaticBatchInfo
}
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))
if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 4) || sourceFile.version[0] > 5)//5.4.0 and up
{
PPtr m_ProbeAnchor = sourceFile.ReadPPtr();
PPtr m_LightProbeVolumeOverride = sourceFile.ReadPPtr();
}
else if (version[0] >= 4 || (version[0] == 3 && version[1] >= 5))
{
bool m_UseLightProbes = a_Stream.ReadBoolean();
a_Stream.Position += 3; //alignment
@@ -80,7 +95,7 @@ namespace Unity_Studio
{
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);
}

View File

@@ -12,7 +12,7 @@ namespace Unity_Studio
public int m_Width;
public int m_Height;
public int m_CompleteImageSize;
public int m_TextureFormat;
public TextureFormat m_TextureFormat;
public bool m_MipMap = false;
public bool m_IsReadable;
public bool m_ReadAllowed;
@@ -78,13 +78,13 @@ namespace Unity_Studio
public int bytesOfKeyValueData = 0;
//KTX End
//ASTC Start
public byte[] astc_magicnum = { 0x13, 0xab, 0xa1, 0x5c };
public byte astc_x;
public byte astc_y;
public byte astc_z = 1;
public byte[] astc_width = new byte[3];
public byte[] astc_height = new byte[3];
public byte[] astc_length = new byte[3] { 1, 0, 0 };//I don't know what this is.
public byte[] astc_magic = { 0x13, 0xab, 0xa1, 0x5c };
public byte blockdim_x;
public byte blockdim_y;
public byte blockdim_z = 1;
public byte[] xsize = new byte[3];
public byte[] ysize = new byte[3];
public byte[] zsize = new byte[3] { 1, 0, 0 };
//ASTC END
//TextureConverter
public int q_format;
@@ -108,7 +108,7 @@ namespace Unity_Studio
m_Width = a_Stream.ReadInt32();
m_Height = a_Stream.ReadInt32();
m_CompleteImageSize = a_Stream.ReadInt32();
m_TextureFormat = a_Stream.ReadInt32();
m_TextureFormat = (TextureFormat)a_Stream.ReadInt32();
if (sourceFile.version[0] < 5 || (sourceFile.version[0] == 5 && sourceFile.version[1] < 2))
{ m_MipMap = a_Stream.ReadBoolean(); }
@@ -184,7 +184,7 @@ namespace Unity_Studio
a_Stream.Read(image_data, 0, image_data_size);
}
switch ((TextureFormat)m_TextureFormat)
switch (m_TextureFormat)
{
case TextureFormat.Alpha8: //test pass
{
@@ -391,44 +391,68 @@ namespace Unity_Studio
}
case TextureFormat.YUY2://Not sure
{
pvrPixelFormat = 0x11;
pvrPixelFormat = 17;
q_format = (int)QFORMAT.Q_FORMAT_YUYV_16;
break;
}
case TextureFormat.BC4:
{
glInternalFormat = KTXHeader.GL_COMPRESSED_RED_RGTC1;
glBaseInternalFormat = KTXHeader.GL_RED;
break;
}
case TextureFormat.BC5:
{
glInternalFormat = KTXHeader.GL_COMPRESSED_RG_RGTC2;
glBaseInternalFormat = KTXHeader.GL_RG;
break;
}
case TextureFormat.BC6H:
{
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT;
glBaseInternalFormat = KTXHeader.GL_RGB;
break;
}
case TextureFormat.BC7:
{
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_BPTC_UNORM;
glBaseInternalFormat = KTXHeader.GL_RGBA;
break;
}
case TextureFormat.DXT1Crunched: //DXT1 Crunched
case TextureFormat.DXT5Crunched: //DXT1 Crunched
break;
case TextureFormat.PVRTC_RGB2: //test pass
{
pvrPixelFormat = 0x0;
pvrPixelFormat = 0;
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
glBaseInternalFormat = KTXHeader.GL_RGB;
break;
}
case TextureFormat.PVRTC_RGBA2: //test pass
{
pvrPixelFormat = 0x1;
pvrPixelFormat = 1;
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
glBaseInternalFormat = KTXHeader.GL_RGBA;
break;
}
case TextureFormat.PVRTC_RGB4: //test pass
{
pvrPixelFormat = 0x2;
pvrPixelFormat = 2;
glInternalFormat = KTXHeader.GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
glBaseInternalFormat = KTXHeader.GL_RGB;
break;
}
case TextureFormat.PVRTC_RGBA4: //test pass
{
pvrPixelFormat = 0x3;
pvrPixelFormat = 3;
glInternalFormat = KTXHeader.GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
glBaseInternalFormat = KTXHeader.GL_RGBA;
break;
}
case TextureFormat.ETC_RGB4: //test pass
{
pvrPixelFormat = 0x16;
pvrPixelFormat = 6;
glInternalFormat = KTXHeader.GL_ETC1_RGB8_OES;
glBaseInternalFormat = KTXHeader.GL_RGB;
break;
@@ -440,37 +464,37 @@ namespace Unity_Studio
glBaseInternalFormat = KTXHeader.GL_RGB;
break;
}
case TextureFormat.ATC_RGBA8: //透明通道很奇怪?
case TextureFormat.ATC_RGBA8: //test pass
{
q_format = (int)QFORMAT.Q_FORMAT_ATC_RGBA_EXPLICIT_ALPHA;
glInternalFormat = KTXHeader.GL_ATC_RGBA_EXPLICIT_ALPHA_AMD;
q_format = (int)QFORMAT.Q_FORMAT_ATC_RGBA_INTERPOLATED_ALPHA;
glInternalFormat = KTXHeader.GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
glBaseInternalFormat = KTXHeader.GL_RGBA;
break;
}
case TextureFormat.EAC_R:
{
pvrPixelFormat = 25;
q_format = (int)QFORMAT.Q_FORMAT_EAC_R_UNSIGNED;
glInternalFormat = KTXHeader.GL_COMPRESSED_R11_EAC;
glBaseInternalFormat = KTXHeader.GL_RED;
break;
}
case TextureFormat.EAC_R_SIGNED:
{
pvrPixelFormat = 25;
q_format = (int)QFORMAT.Q_FORMAT_EAC_R_SIGNED;
glInternalFormat = KTXHeader.GL_COMPRESSED_SIGNED_R11_EAC;
glBaseInternalFormat = KTXHeader.GL_RED;
break;
}
case TextureFormat.EAC_RG:
{
pvrPixelFormat = 26;
q_format = (int)QFORMAT.Q_FORMAT_EAC_RG_UNSIGNED;
glInternalFormat = KTXHeader.GL_COMPRESSED_RG11_EAC;
glBaseInternalFormat = KTXHeader.GL_RG;
break;
}
case TextureFormat.EAC_RG_SIGNED:
{
pvrPixelFormat = 26;
q_format = (int)QFORMAT.Q_FORMAT_EAC_RG_SIGNED;
glInternalFormat = KTXHeader.GL_COMPRESSED_SIGNED_RG11_EAC;
glBaseInternalFormat = KTXHeader.GL_RG;
break;
@@ -499,43 +523,43 @@ namespace Unity_Studio
case TextureFormat.ASTC_RGB_4x4: //test pass
case TextureFormat.ASTC_RGBA_4x4: //test pass
{
astc_x = 4;
astc_y = 4;
blockdim_x = 4;
blockdim_y = 4;
break;
}
case TextureFormat.ASTC_RGB_5x5: //test pass
case TextureFormat.ASTC_RGBA_5x5: //test pass
{
astc_x = 5;
astc_y = 5;
blockdim_x = 5;
blockdim_y = 5;
break;
}
case TextureFormat.ASTC_RGB_6x6: //test pass
case TextureFormat.ASTC_RGBA_6x6: //test pass
{
astc_x = 6;
astc_y = 6;
blockdim_x = 6;
blockdim_y = 6;
break;
}
case TextureFormat.ASTC_RGB_8x8: //test pass
case TextureFormat.ASTC_RGBA_8x8: //test pass
{
astc_x = 8;
astc_y = 8;
blockdim_x = 8;
blockdim_y = 8;
break;
}
case TextureFormat.ASTC_RGB_10x10: //test pass
case TextureFormat.ASTC_RGBA_10x10: //test pass
{
astc_x = 10;
astc_y = 10;
blockdim_x = 10;
blockdim_y = 10;
break;
}
case TextureFormat.ASTC_RGB_12x12: //test pass
case TextureFormat.ASTC_RGBA_12x12: //test pass
{
astc_x = 12;
astc_y = 12;
blockdim_x = 12;
blockdim_y = 12;
break;
}
case TextureFormat.ETC_RGB4_3DS:
@@ -548,10 +572,10 @@ namespace Unity_Studio
preloadData.InfoText = "Width: " + m_Width.ToString() + "\nHeight: " + m_Height.ToString() + "\nFormat: ";
preloadData.exportSize = image_data_size;
string type = ((TextureFormat)m_TextureFormat).ToString();
string type = m_TextureFormat.ToString();
preloadData.InfoText += type;
switch ((TextureFormat)m_TextureFormat)
switch (m_TextureFormat)
{
case TextureFormat.Alpha8:
case TextureFormat.ARGB4444:
@@ -576,10 +600,6 @@ namespace Unity_Studio
case TextureFormat.ETC2_RGB:
case TextureFormat.ETC2_RGBA1:
case TextureFormat.ETC2_RGBA8:
case TextureFormat.EAC_R:
case TextureFormat.EAC_R_SIGNED:
case TextureFormat.EAC_RG:
case TextureFormat.EAC_RG_SIGNED:
preloadData.extension = ".pvr"; preloadData.exportSize += 52; break;
case TextureFormat.RHalf:
case TextureFormat.RGHalf:
@@ -587,8 +607,16 @@ namespace Unity_Studio
case TextureFormat.RFloat:
case TextureFormat.RGFloat:
case TextureFormat.RGBAFloat:
case TextureFormat.BC4:
case TextureFormat.BC5:
case TextureFormat.BC6H:
case TextureFormat.BC7:
case TextureFormat.ATC_RGB4:
case TextureFormat.ATC_RGBA8:
case TextureFormat.EAC_R:
case TextureFormat.EAC_R_SIGNED:
case TextureFormat.EAC_RG:
case TextureFormat.EAC_RG_SIGNED:
preloadData.extension = ".ktx"; preloadData.exportSize += 68; break;
case TextureFormat.ASTC_RGB_4x4:
case TextureFormat.ASTC_RGB_5x5:
@@ -651,6 +679,10 @@ namespace Unity_Studio
RGFloat,
RGBAFloat,
YUY2,
BC4 = 26,
BC5,
BC6H = 24,
BC7,
DXT1Crunched = 28,
DXT5Crunched,
PVRTC_RGB2,
@@ -713,6 +745,11 @@ public class KTXHeader
public static int GL_COMPRESSED_RG11_EAC = 0x9272;
public static int GL_COMPRESSED_SIGNED_RG11_EAC = 0x9273;
public static int GL_COMPRESSED_RED_RGTC1 = 0x8DBB;
public static int GL_COMPRESSED_RG_RGTC2 = 0x8DBD;
public static int GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F;
public static int GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
public static int GL_R16F = 0x822D;
public static int GL_RG16F = 0x822F;
public static int GL_RGBA16F = 0x881A;

View File

@@ -171,9 +171,11 @@
<Compile Include="Unity Classes\Mesh.cs" />
<Compile Include="Unity Classes\GameObject.cs" />
<Compile Include="helpers.cs" />
<Compile Include="Unity Classes\MonoBehaviour.cs" />
<Compile Include="Unity Classes\PlayerSettings.cs" />
<Compile Include="Unity Classes\RectTransform.cs" />
<Compile Include="Unity Classes\Renderer.cs" />
<Compile Include="Unity Classes\MeshRenderer.cs" />
<Compile Include="Unity Classes\Shader.cs" />
<Compile Include="Unity Classes\SkinnedMeshRenderer.cs" />
<Compile Include="Unity Classes\MeshFilter.cs" />
<Compile Include="Unity Classes\TextAsset.cs" />

View File

@@ -569,6 +569,7 @@ namespace Unity_Studio
break;
case 48:
case 49:
case 114:
textPreviewBox.Visible = !textPreviewBox.Visible;
break;
case 128:
@@ -700,6 +701,11 @@ namespace Unity_Studio
break;
}
case 48: //Shader
{
Shader m_Shader = new Shader(asset, false);
exportable = true;
break;
}
case 49: //TextAsset
{
TextAsset m_TextAsset = new TextAsset(asset, false);
@@ -712,7 +718,13 @@ namespace Unity_Studio
exportable = true;
break;
}
//case 89: //CubeMap
case 114: //MonoBehaviour
{
var m_MonoBehaviour = new MonoBehaviour(asset, false);
if (asset.Type1 != asset.Type2 && assetsFile.ClassStructures.ContainsKey(asset.Type1))
exportable = true;
break;
}
case 128: //Font
{
unityFont m_Font = new unityFont(asset, false);
@@ -725,19 +737,6 @@ namespace Unity_Studio
productName = plSet.productName;
break;
}
case 114: //MonoBehaviour
{
if (asset.Offset + 0x1c + 4 > asset.sourceFile.a_Stream.BaseStream.Length)
break;
asset.sourceFile.a_Stream.Position = asset.Offset + 0x1c;
var len = asset.sourceFile.a_Stream.ReadInt32();
if (len > 0 && len < asset.Size - 4 - 0x1c)
{
var bytes = asset.sourceFile.a_Stream.ReadBytes(len);
asset.Text = Encoding.UTF8.GetString(bytes);
}
break;
}
case 21: //Material
case 43: //Mesh
case 74: //AnimationClip
@@ -810,6 +809,8 @@ namespace Unity_Studio
foreach (var m_GameObject in assetsFile.GameObjectList.Values)
{
assetsfileList.ParseGameObject(m_GameObject);
var parentNode = fileNode;
Transform m_Transform;
@@ -1231,6 +1232,8 @@ namespace Unity_Studio
BitmapData bmd = imageTexture.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Ponvert(m_Texture2D.image_data, bmd.Scan0, m_Texture2D.m_Width, m_Texture2D.m_Height, m_Texture2D.image_data_size, m_Texture2D.q_format);
imageTexture.UnlockBits(bmd);
if (m_Texture2D.glBaseInternalFormat == KTXHeader.GL_RED || m_Texture2D.glBaseInternalFormat == KTXHeader.GL_RG)
FixAlpha(imageTexture);
imageTexture.RotateFlip(RotateFlipType.RotateNoneFlipY);
}
else
@@ -1286,13 +1289,23 @@ namespace Unity_Studio
break;
}
#endregion
#region Shader & TextAsset
#region Shader
case 48:
{
Shader m_TextAsset = new Shader(asset, true);
string m_Script_Text = Encoding.UTF8.GetString(m_TextAsset.m_Script);
m_Script_Text = Regex.Replace(m_Script_Text, "(?<!\r)\n", "\r\n");
textPreviewBox.Text = m_Script_Text;
textPreviewBox.Visible = true;
break;
}
#endregion
#region TextAsset
case 49:
{
TextAsset m_TextAsset = new TextAsset(asset, true);
string m_Script_Text = UnicodeEncoding.UTF8.GetString(m_TextAsset.m_Script);
string m_Script_Text = Encoding.UTF8.GetString(m_TextAsset.m_Script);
m_Script_Text = Regex.Replace(m_Script_Text, "(?<!\r)\n", "\r\n");
textPreviewBox.Text = m_Script_Text;
textPreviewBox.Visible = true;
@@ -1300,6 +1313,16 @@ namespace Unity_Studio
break;
}
#endregion
#region MonoBehaviour
case 114:
{
MonoBehaviour m_MonoBehaviour = new MonoBehaviour(asset, true);
textPreviewBox.Text = m_MonoBehaviour.serializedText;
textPreviewBox.Visible = true;
break;
}
#endregion
#region Font
case 128: //Font
{
@@ -1362,6 +1385,19 @@ namespace Unity_Studio
}
}
private void FixAlpha(Bitmap imageTexture)
{
for (int y = 0; y < imageTexture.Height; y++)
{
for (int x = 0; x < imageTexture.Width; x++)
{
var color = imageTexture.GetPixel(x, y);
color = Color.FromArgb(255, color.R, color.G, color.B);
imageTexture.SetPixel(x, y, color);
}
}
}
private byte[] Texture2DToDDS(Texture2D m_Texture2D)
{
byte[] imageBuffer = new byte[128 + m_Texture2D.image_data_size];
@@ -1411,15 +1447,15 @@ namespace Unity_Studio
{
var mstream = new MemoryStream();
var writer = new BinaryWriter(mstream);
Array.Copy(BitConverter.GetBytes(m_Texture2D.m_Width), 0, m_Texture2D.astc_width, 0, 3);
Array.Copy(BitConverter.GetBytes(m_Texture2D.m_Height), 0, m_Texture2D.astc_height, 0, 3);
writer.Write(m_Texture2D.astc_magicnum);
writer.Write(m_Texture2D.astc_x);
writer.Write(m_Texture2D.astc_y);
writer.Write(m_Texture2D.astc_z);
writer.Write(m_Texture2D.astc_width);
writer.Write(m_Texture2D.astc_height);
writer.Write(m_Texture2D.astc_length);
Array.Copy(BitConverter.GetBytes(m_Texture2D.m_Width), 0, m_Texture2D.xsize, 0, 3);
Array.Copy(BitConverter.GetBytes(m_Texture2D.m_Height), 0, m_Texture2D.ysize, 0, 3);
writer.Write(m_Texture2D.astc_magic);
writer.Write(m_Texture2D.blockdim_x);
writer.Write(m_Texture2D.blockdim_y);
writer.Write(m_Texture2D.blockdim_z);
writer.Write(m_Texture2D.xsize);
writer.Write(m_Texture2D.ysize);
writer.Write(m_Texture2D.zsize);
writer.Write(m_Texture2D.image_data);
var astcdata = mstream.ToArray();
writer.Close();
@@ -1924,7 +1960,7 @@ namespace Unity_Studio
break;
}
if (openAfterExport.Checked && File.Exists(saveFileDialog1.FileName)) { System.Diagnostics.Process.Start(saveFileDialog1.FileName); }
if (openAfterExport.Checked && File.Exists(saveFileDialog1.FileName)) { try { Process.Start(saveFileDialog1.FileName); } catch { } }
break;
}
}
@@ -1998,9 +2034,9 @@ namespace Unity_Studio
#region get Renderer
AssetPreloadData RendererPD;
if (assetsfileList.TryGetPD(m_GameObject.m_Renderer, out RendererPD))
if (assetsfileList.TryGetPD(m_GameObject.m_MeshRenderer, out RendererPD))
{
Renderer m_Renderer = new Renderer(RendererPD);
MeshRenderer m_Renderer = new MeshRenderer(RendererPD);
foreach (var MaterialPPtr in m_Renderer.m_Materials)
{
@@ -3129,9 +3165,9 @@ namespace Unity_Studio
}
break;
case 48:
if (!ExportFileExists(exportpath + asset.Text + ".txt", asset.TypeString))
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
{
ExportText(new TextAsset(asset, true), exportpath + asset.Text + ".txt");
ExportShader(new Shader(asset, true), exportpath + asset.Text + ".txt");
exportedCount++;
}
break;
@@ -3143,6 +3179,14 @@ namespace Unity_Studio
exportedCount++;
}
break;
case 114:
MonoBehaviour m_MonoBehaviour = new MonoBehaviour(asset, true);
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
{
ExportMonoBehaviour(m_MonoBehaviour, exportpath + asset.Text + asset.extension);
exportedCount++;
}
break;
case 128:
unityFont m_Font = new unityFont(asset, true);
if (!ExportFileExists(exportpath + asset.Text + asset.extension, asset.TypeString))
@@ -3282,6 +3326,8 @@ namespace Unity_Studio
var bmd = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Ponvert(m_Texture2D.image_data, bmd.Scan0, m_Texture2D.m_Width, m_Texture2D.m_Height, m_Texture2D.image_data_size, m_Texture2D.q_format);
bitmap.UnlockBits(bmd);
if (m_Texture2D.glBaseInternalFormat == KTXHeader.GL_RED || m_Texture2D.glBaseInternalFormat == KTXHeader.GL_RG)
FixAlpha(bitmap);
if (flip)
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
bitmap.Save(exportFullname, format);
@@ -3380,6 +3426,16 @@ namespace Unity_Studio
return true;
}
private void ExportMonoBehaviour(MonoBehaviour m_MonoBehaviour, string exportFilename)
{
File.WriteAllText(exportFilename, m_MonoBehaviour.serializedText);
}
private void ExportShader(Shader m_Shader, string exportFilename)
{
File.WriteAllBytes(exportFilename, m_Shader.m_Script);
}
private void ExportText(TextAsset m_TextAsset, string exportFilename)
{
File.WriteAllBytes(exportFilename, m_TextAsset.m_Script);

View File

@@ -24,13 +24,13 @@ namespace Unity_Studio
int FileID = a_Stream.ReadInt32();
if (FileID >= 0 && FileID < sourceFile.sharedAssetsList.Count)
{ result.m_FileID = sourceFile.sharedAssetsList[FileID].Index; }
if (sourceFile.fileGen < 14) { result.m_PathID = a_Stream.ReadInt32(); }
else { result.m_PathID = a_Stream.ReadInt64(); }
return result;
}
public static bool TryGetPD(this List<AssetsFile> assetsfileList, PPtr m_elm, out AssetPreloadData result)
{
result = null;
@@ -73,6 +73,44 @@ namespace Unity_Studio
return false;
}
public static void ParseGameObject(this List<AssetsFile> assetsfileList, GameObject m_GameObject)
{
foreach (var m_Component in m_GameObject.m_Components)
{
if (m_Component.m_FileID >= 0 && m_Component.m_FileID < assetsfileList.Count)
{
AssetsFile sourceFile = assetsfileList[m_Component.m_FileID];
AssetPreloadData asset;
if (sourceFile.preloadTable.TryGetValue(m_Component.m_PathID, out asset))
{
switch (asset.Type2)
{
case 4: //Transform
{
m_GameObject.m_Transform = m_Component;
break;
}
case 23: //MeshRenderer
{
m_GameObject.m_MeshRenderer = m_Component;
break;
}
case 33: //MeshFilter
{
m_GameObject.m_MeshFilter = m_Component;
break;
}
case 137: //SkinnedMeshRenderer
{
m_GameObject.m_SkinnedMeshRenderer = m_Component;
break;
}
}
}
}
}
}
}
class TexEnv